Elin Decompiled Documentation EA 23.320 Nyaightly Patch 1
Loading...
Searching...
No Matches
CraftUtil Class Reference
Inheritance diagram for CraftUtil:
EClass

Public Types

enum  MixType { General , Food , NoMix , Drink }
 
enum  WrapType { Love , Dark }
 

Static Public Member Functions

static void ModRandomFoodEnc (Thing t)
 
static void AddRandomFoodEnc (Thing t)
 
static void MakeDish (Thing food, int lv, Chara crafter=null, int seed=-1)
 
static string GetBloodText (Chara c)
 
static int GetFoodScore (Thing food)
 
static Thing MakeBloodMeal (Chara sucker, Chara feeder, bool msg=true)
 
static Thing MakeBloodSample (Chara sucker, Chara feeder)
 
static Thing MakeDarkSoup ()
 
static Thing GetRandomDarkSoupIngredient (Chara c)
 
static Thing MakeLoveLunch (Chara c)
 
static Thing GetRandomLoveLunchIngredient (Chara c)
 
static void WrapIngredient (Card product, Chara c, Card ing, WrapType wrapType)
 
static void MakeDish (Card food, List< Thing > ings, int qualityBonus, Chara crafter=null)
 
static Thing MixIngredients (string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
 
static Card MixIngredients (Card product, List< Thing > ings, MixType type, int maxQuality, Chara crafter=null)
 
- Static Public Member Functions inherited from EClass
static int rndSeed (int a, int seed)
 
static int rnd (long a)
 
static int rnd (int a)
 
static int curve (long _a, int start, int step, int rate=75)
 
static int sqrt (int a)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Static Public Attributes

static string[] ListFoodEffect = new string[2] { "exp", "pot" }
 
- Static Public Attributes inherited from EClass
static Core core
 

Additional Inherited Members

- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Detailed Description

Definition at line 5 of file CraftUtil.cs.

Member Enumeration Documentation

◆ MixType

Enumerator
General 
Food 
NoMix 
Drink 

Definition at line 7 of file CraftUtil.cs.

◆ WrapType

Enumerator
Love 
Dark 

Definition at line 15 of file CraftUtil.cs.

Member Function Documentation

◆ AddRandomFoodEnc()

static void CraftUtil.AddRandomFoodEnc ( Thing  t)
inlinestatic

Definition at line 44 of file CraftUtil.cs.

45 {
46 List<SourceElement.Row> list = EClass.sources.elements.rows.Where((SourceElement.Row e) => e.foodEffect.Length > 1 && ListFoodEffect.Contains(e.foodEffect[0])).ToList();
47 list.ForeachReverse(delegate(SourceElement.Row e)
48 {
49 if (t.elements.dict.ContainsKey(e.id))
50 {
51 list.Remove(e);
52 }
53 });
54 if (list.Count != 0)
55 {
56 SourceElement.Row row = list.RandomItemWeighted((SourceElement.Row a) => a.chance);
57 t.elements.SetBase(row.id, 1);
58 t.c_seed = row.id;
59 }
60 }
ElementContainerCard elements
Definition: Card.cs:42
static string[] ListFoodEffect
Definition: CraftUtil.cs:21
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:43
Element SetBase(string alias, int v, int potential=0)
SourceElement elements

References SourceManager.elements, ListFoodEffect, and EClass.sources.

Referenced by TraitSeed.LevelSeed().

◆ GetBloodText()

static string CraftUtil.GetBloodText ( Chara  c)
inlinestatic

Definition at line 118 of file CraftUtil.cs.

119 {
120 string text = "";
121 List<Element> list = MakeBloodMeal(EClass.pc, c, msg: false).elements.ListElements((Element e) => e.IsFoodTraitMain, (Element a, Element b) => b.Value - a.Value);
122 int num = Mathf.Min(list.Count(), 3, EClass.debug.godMode ? 3 : (1 + EClass.pc.Evalue(6607) / 15));
123 for (int i = 0; i < num; i++)
124 {
125 Element element = list[i];
126 string[] textArray = element.source.GetTextArray("textAlt");
127 int num2 = Mathf.Clamp(element.Value / 10 + 1, (element.Value < 0 || textArray.Length <= 2) ? 1 : 2, textArray.Length - 1);
128 string text2 = textArray[num2];
129 if (i != 0)
130 {
131 text += ", ";
132 }
133 text += text2;
134 }
135 if (!text.IsEmpty())
136 {
137 text = " (" + text + ")";
138 }
139 return text;
140 }
int Evalue(int ele)
Definition: Card.cs:2688
bool godMode
Definition: CoreDebug.cs:188
static Thing MakeBloodMeal(Chara sucker, Chara feeder, bool msg=true)
Definition: CraftUtil.cs:155
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
List< Element > ListElements(Func< Element, bool > shoudList=null, Comparison< Element > comparison=null)
SourceElement.Row source
Definition: ELEMENT.cs:280
int Value
Definition: ELEMENT.cs:299
bool IsFoodTraitMain
Definition: ELEMENT.cs:374

References EClass.debug, Card.Evalue(), CoreDebug.godMode, Element.IsFoodTraitMain, EClass.pc, Element.source, and Element.Value.

Referenced by Chara.GetHoverText().

◆ GetFoodScore()

static int CraftUtil.GetFoodScore ( Thing  food)
inlinestatic

Definition at line 142 of file CraftUtil.cs.

143 {
144 int num = 0;
145 foreach (Element value in food.elements.dict.Values)
146 {
147 if (value.IsFoodTraitMain)
148 {
149 num += value.Value;
150 }
151 }
152 return num;
153 }

References food, Element.IsFoodTraitMain, and Element.Value.

Referenced by AI_Idle.Run().

◆ GetRandomDarkSoupIngredient()

static Thing CraftUtil.GetRandomDarkSoupIngredient ( Chara  c)
inlinestatic

Definition at line 216 of file CraftUtil.cs.

217 {
218 return ThingGen.CreateFromFilter("darksoup", c.LV);
219 }
int LV
Definition: Card.cs:389
static Thing CreateFromFilter(string id, int lv=-1)
Definition: ThingGen.cs:63

References ThingGen.CreateFromFilter(), and Card.LV.

◆ GetRandomLoveLunchIngredient()

static Thing CraftUtil.GetRandomLoveLunchIngredient ( Chara  c)
inlinestatic

Definition at line 250 of file CraftUtil.cs.

251 {
252 Thing thing = null;
253 for (int i = 0; i < 3; i++)
254 {
255 thing = ThingGen.Create("dish", -1, c.Evalue(287) + 5 + (EClass.debug.enable ? c.LV : 0));
256 if (!thing.HasTag(CTAG.dish_fail))
257 {
258 break;
259 }
260 }
261 MakeDish(thing, c.LV, c);
262 return thing;
263 }
CTAG
Definition: CTAG.cs:2
bool HasTag(CTAG tag)
Definition: Card.cs:2712
bool enable
Definition: CoreDebug.cs:301
static void MakeDish(Thing food, int lv, Chara crafter=null, int seed=-1)
Definition: CraftUtil.cs:62
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8

References ThingGen.Create(), EClass.debug, CoreDebug.enable, Card.Evalue(), Card.HasTag(), and Card.LV.

◆ MakeBloodMeal()

static Thing CraftUtil.MakeBloodMeal ( Chara  sucker,
Chara  feeder,
bool  msg = true 
)
inlinestatic

Definition at line 155 of file CraftUtil.cs.

156 {
157 Thing c_bloodData = feeder.c_bloodData;
158 if (c_bloodData == null)
159 {
160 int num = ((feeder.GetInt(118) == 0) ? (EClass.game.seed + feeder.uid) : feeder.GetInt(118));
161 Rand.SetSeed(num);
162 c_bloodData = ThingGen.CreateFromCategory("meal", 100);
163 if (msg)
164 {
165 sucker.Say("food_blood", c_bloodData);
166 }
167 MakeDish(c_bloodData, 100, null, num + feeder.uid);
168 c_bloodData.elements.SetTo(709, 0);
169 c_bloodData.elements.SetTo(708, 0);
170 c_bloodData.elements.SetTo(701, 0);
171 feeder.c_bloodData = c_bloodData.Duplicate(1);
172 }
173 else
174 {
175 c_bloodData = c_bloodData.Duplicate(1);
176 if (msg)
177 {
178 sucker.Say("food_blood", c_bloodData);
179 }
180 }
181 c_bloodData.elements.SetTo(2, Mathf.Min(EClass.curve(feeder.LV, 30, 10, 65), 200));
182 c_bloodData.elements.ModBase(710, 15 + (int)Mathf.Min(Mathf.Sqrt(sucker.Evalue(6607) + Mathf.Max(sucker.LER, 0)), 55f));
183 return c_bloodData;
184 }
int LER
Definition: Card.cs:2395
Thing c_bloodData
Definition: Card.cs:1969
int uid
Definition: Card.cs:125
Thing Duplicate(int num)
Definition: Card.cs:3602
int GetInt(string id, int? defaultInt=null)
Definition: Card.cs:2551
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7240
static Game game
Definition: EClass.cs:9
static int curve(long _a, int start, int step, int rate=75)
Definition: EClass.cs:69
Element ModBase(int ele, int v)
void SetTo(int id, int v)
int seed
Definition: Game.cs:201
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:44
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75

References Card.c_bloodData, ThingGen.CreateFromCategory(), EClass.curve(), Card.Duplicate(), Card.elements, Card.Evalue(), EClass.game, Card.GetInt(), Card.LER, Card.LV, ElementContainer.ModBase(), Card.Say(), Game.seed, Rand.SetSeed(), ElementContainer.SetTo(), and Card.uid.

Referenced by AI_Fuck.Finish().

◆ MakeBloodSample()

static Thing CraftUtil.MakeBloodSample ( Chara  sucker,
Chara  feeder 
)
inlinestatic

Definition at line 186 of file CraftUtil.cs.

187 {
188 Thing thing = MakeBloodMeal(sucker, feeder);
189 Thing thing2 = ThingGen.Create("bloodsample");
190 foreach (Element value in thing.elements.dict.Values)
191 {
192 thing2.elements.SetTo(value.id, value.Value);
193 }
194 thing2.elements.SetTo(10, 0);
195 thing2.MakeRefFrom(feeder);
196 thing2.c_idRefCard = thing.id;
197 thing2.SetInt(118, EClass.game.seed + feeder.uid);
198 return thing2;
199 }
string id
Definition: Card.cs:36
void SetInt(string id, int value=0)
Definition: Card.cs:2570
Card MakeRefFrom(string id)
Definition: Card.cs:5960
Dictionary< int, Element > dict
int id
Definition: ELEMENT.cs:257

References ThingGen.Create(), Card.elements, EClass.game, Element.id, Game.seed, ElementContainer.SetTo(), and Element.Value.

◆ MakeDarkSoup()

static Thing CraftUtil.MakeDarkSoup ( )
inlinestatic

Definition at line 201 of file CraftUtil.cs.

202 {
203 Thing thing = ThingGen.Create("soup_dark");
204 for (int i = 0; i < 4 + EClass.rnd(4); i++)
205 {
206 Chara c = EClass._map.charas.RandomItem();
208 }
210 {
211 thing.c_IDTState = 1;
212 }
213 return thing;
214 }
Definition: Chara.cs:10
bool autoIdentify
Definition: CoreDebug.cs:204
static Thing GetRandomDarkSoupIngredient(Chara c)
Definition: CraftUtil.cs:216
static void WrapIngredient(Card product, Chara c, Card ing, WrapType wrapType)
Definition: CraftUtil.cs:265
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
List< Chara > charas
Definition: Map.cs:81

References EClass._map, CoreDebug.autoIdentify, Map.charas, ThingGen.Create(), EClass.debug, and EClass.rnd().

◆ MakeDish() [1/2]

static void CraftUtil.MakeDish ( Card  food,
List< Thing ings,
int  qualityBonus,
Chara  crafter = null 
)
inlinestatic

Definition at line 311 of file CraftUtil.cs.

312 {
313 List<Thing> list = new List<Thing>();
314 bool flag = food.sourceCard.vals.Contains("fixed");
315 for (int i = 0; i < ings.Count; i++)
316 {
317 Thing thing = ings[i];
318 if (flag)
319 {
320 list.Add(thing);
321 break;
322 }
323 if (!IsIgnoreName(thing))
324 {
325 list.Add(thing);
326 }
327 }
328 if (list.Count > 0)
329 {
330 Thing thing2 = list.RandomItem();
331 if (thing2 != null)
332 {
333 food.MakeRefFrom(thing2);
334 if (thing2.c_idRefCard != null)
335 {
336 food.c_idRefCard = thing2.c_idRefCard;
337 food.c_altName = food.TryGetFoodName(thing2);
338 if (thing2.id == "_egg" || thing2.id == "egg_fertilized")
339 {
340 food.c_altName = "_egg".lang(food.c_altName);
341 }
342 }
343 }
344 }
345 MixIngredients(food, ings, MixType.Food, qualityBonus, crafter);
346 static bool IsIgnoreName(Card t)
347 {
348 if (t == null)
349 {
350 return true;
351 }
352 switch (t.sourceCard._origin)
353 {
354 case "dough":
355 case "dish":
356 case "dish_lunch":
357 return true;
358 default:
359 return false;
360 }
361 }
362 }
void Add(Act a, string s="")
Definition: ActPlan.cs:11
string _origin
Definition: CardRow.cs:15
Definition: Card.cs:11
virtual CardRow sourceCard
Definition: Card.cs:2183
string c_idRefCard
Definition: Card.cs:1777
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:364

References CardRow._origin, Card.Add(), Card.c_idRefCard, food, Card.id, and Card.sourceCard.

◆ MakeDish() [2/2]

static void CraftUtil.MakeDish ( Thing  food,
int  lv,
Chara  crafter = null,
int  seed = -1 
)
inlinestatic

Definition at line 62 of file CraftUtil.cs.

63 {
65 List<Thing> list = new List<Thing>();
66 RecipeSource recipeSource = RecipeManager.Get(food.id);
67 if (recipeSource == null || !recipeSource.IsCraftable())
68 {
69 return;
70 }
71 SetSeed();
72 int num = Mathf.Min(EClass.rnd(lv), 50);
73 foreach (Recipe.Ingredient ingredient in recipeSource.GetIngredients())
74 {
75 SetSeed();
76 Thing thing = ThingGen.Create(ingredient.id, -1, lv);
77 if (thing.id == "deadbody")
78 {
79 thing = ThingGen.Create("_meat");
80 }
81 SetSeed();
82 thing = thing.TryMakeRandomItem(lv, TryMakeRandomItemSource.Cooking, crafter);
83 SetSeed();
84 TraitSeed.LevelSeed(thing, null, EClass.rnd(lv / 4) + 1);
85 thing.SetEncLv(thing.encLV / 2);
86 if (num > 0 && EClass.rnd(3) == 0)
87 {
88 thing.elements.SetBase(2, num);
89 }
90 list.Add(thing);
91 }
92 MakeDish(food, list, num, crafter);
93 if (crafter != null && crafter.id != "rodwyn")
94 {
95 if (food.HasElement(709))
96 {
97 food.elements.Remove(709);
98 }
99 if (food.HasElement(708) && !crafter.HasElement(1205))
100 {
101 food.elements.Remove(708);
102 }
103 }
104 if (seed != -1)
105 {
106 Rand.SetSeed();
107 }
108 void SetSeed()
109 {
110 if (seed != -1)
111 {
113 seed++;
114 }
115 }
116 }
@ seed
TryMakeRandomItemSource
Thing TryMakeRandomItem(int lv=-1, TryMakeRandomItemSource itemSource=TryMakeRandomItemSource.Default, Chara crafter=null)
Definition: Card.cs:5691
int encLV
Definition: Card.cs:329
void SetEncLv(int a)
Definition: Card.cs:4022
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6304
static void BuildList()
static RecipeSource Get(string id)
List< Recipe.Ingredient > GetIngredients()
bool IsCraftable()
Definition: Recipe.cs:7
static void LevelSeed(Thing t, SourceObj.Row obj, int num)
Definition: TraitSeed.cs:184

References RecipeManager.BuildList(), ThingGen.Create(), Card.elements, Card.encLV, food, RecipeManager.Get(), RecipeSource.GetIngredients(), Card.id, RecipeSource.IsCraftable(), TraitSeed.LevelSeed(), EClass.rnd(), seed, ElementContainer.SetBase(), Card.SetEncLv(), Rand.SetSeed(), and Card.TryMakeRandomItem().

Referenced by FactionBranch.DailyOutcome(), RecipeCard.MakeDish(), Trait.OnBarter(), Map.TryShatter(), and TraitFoodEgg.Update().

◆ MakeLoveLunch()

static Thing CraftUtil.MakeLoveLunch ( Chara  c)
inlinestatic

Definition at line 221 of file CraftUtil.cs.

222 {
223 Thing thing = ThingGen.Create("lunch_love");
224 thing.MakeRefFrom(c);
225 int num = c.uid + EClass.world.date.year * 10000 + EClass.world.date.month * 100;
226 Rand.SetSeed(num);
227 float num2 = Mathf.Clamp(1f + Mathf.Sqrt(c.Evalue(287) / 5), 2f, 6f);
229 {
230 thing.c_IDTState = 5;
231 }
232 for (int i = 0; (float)i < num2; i++)
233 {
234 Rand.SetSeed(num + i);
236 }
237 thing.elements.SetBase(701, 0);
238 if (thing.Evalue(753) < 0)
239 {
240 thing.elements.SetBase(753, 0);
241 }
242 if (EClass.pc.HasElement(1250) && !thing.HasElement(710))
243 {
244 thing.elements.SetBase(710, 1);
245 }
246 Rand.SetSeed();
247 return thing;
248 }
static Thing GetRandomLoveLunchIngredient(Chara c)
Definition: CraftUtil.cs:250

References CoreDebug.autoIdentify, ThingGen.Create(), EClass.debug, Card.elements, Card.Evalue(), Card.HasElement(), Card.MakeRefFrom(), EClass.pc, ElementContainer.SetBase(), and Rand.SetSeed().

Referenced by Trait.OnBarter(), and Chara.ShowDialog().

◆ MixIngredients() [1/2]

static Card CraftUtil.MixIngredients ( Card  product,
List< Thing ings,
MixType  type,
int  maxQuality,
Chara  crafter = null 
)
inlinestatic

Definition at line 375 of file CraftUtil.cs.

376 {
377 bool noMix = type == MixType.NoMix || product.HasTag(CTAG.noMix);
378 bool isFood = type == MixType.Food;
379 bool isDrink = type == MixType.Drink;
380 bool isFoodOrDrink = isFood || isDrink;
381 int nutFactor = 100 - (ings.Count - 1) * 5;
382 Thing thing = ((ings.Count > 0) ? ings[0] : null);
383 bool creative = crafter?.HasElement(487) ?? false;
384 if (crafter != null && crafter.Evalue(1650) >= 3)
385 {
386 nutFactor -= 10;
387 }
388 if (isDrink)
389 {
390 nutFactor = 100 / ings.Count;
391 }
392 if (!noMix)
393 {
394 foreach (Element value2 in product.elements.dict.Values)
395 {
396 int id = value2.id;
397 if ((uint)(id - 914) > 1u && value2.Value >= 0 && (value2.HasTag("noInherit") || IsValidTrait(value2)))
398 {
399 product.elements.SetTo(value2.id, 0);
400 }
401 }
402 }
403 if (product.HasCraftBonusTrait())
404 {
405 foreach (Element item in product.ListCraftBonusTraits())
406 {
407 product.elements.ModBase(item.id, item.Value);
408 }
409 }
410 if (isDrink)
411 {
412 product.elements.SetTo(10, 0);
413 }
414 if (isFood)
415 {
416 product.elements.SetTo(10, 5);
417 }
418 int num = 0;
419 int num2 = 0;
420 int num3 = 0;
421 foreach (Thing ing in ings)
422 {
423 if (ing != null)
424 {
425 MixElements(ing);
426 num3 += ing.c_priceCopy;
427 if (isFood)
428 {
429 num += Mathf.Clamp(ing.SelfWeight * 80 / 100, 50, 400 + ing.SelfWeight / 20);
430 int value = ing.GetValue();
431 num2 += value;
432 }
433 if (product.id == "1300" && product.GetInt(118) == 0)
434 {
435 product.SetInt(118, ing.GetInt(118));
436 product.c_idRefCard = ing.c_idRefCard;
437 }
438 }
439 }
440 if (isFood)
441 {
442 product.isWeightChanged = true;
443 product.c_weight = num;
444 product.c_priceAdd = num2;
445 }
446 product.c_priceCopy = num3;
447 if (thing != null && product.trait is TraitFoodFishSlice)
448 {
449 product.elements.SetTo(10, thing.Evalue(10) / 4);
450 product.isWeightChanged = true;
451 product.c_weight = Mathf.Min(thing.SelfWeight / 6, 1000);
452 product.c_idRefCard = thing.id;
453 product.c_priceCopy = ((thing.c_priceCopy == 0) ? thing.GetValue() : thing.c_priceCopy);
454 product.c_fixedValue = ((thing.c_fixedValue == 0) ? thing.sourceCard.value : thing.c_fixedValue) / 4;
455 product.c_priceAdd = 0;
456 product.decay = thing.decay;
457 product.elements.SetBase(707, 1);
458 product.SetTier(thing.tier, setTraits: false);
459 product.idSkin = ((thing.trait is TraitFoodFishSlice) ? thing.idSkin : (thing.HasTag(CTAG.bigFish) ? 1 : 0));
460 }
461 if (product.HasElement(652))
462 {
463 product.ChangeWeight((isFood ? num : product.Thing.source.weight) * 100 / (100 + product.Evalue(652)));
464 }
465 if (product.elements.Value(2) > maxQuality)
466 {
467 product.elements.SetTo(2, maxQuality);
468 }
469 string id2 = product.id;
470 if (!(id2 == "zassouni"))
471 {
472 if (id2 == "map")
473 {
474 int num4 = 1 + product.Evalue(2) + product.Evalue(751);
475 if (num4 < 1)
476 {
477 num4 = 1;
478 }
479 foreach (Thing ing2 in ings)
480 {
481 if (ing2 != null && ing2.Thing != null && !(ing2.id != "gem"))
482 {
483 num4 *= ing2.Thing.material.hardness / 20 + 2;
484 }
485 }
486 if (num4 > EClass.pc.FameLv + 10 - 1)
487 {
488 num4 = EClass.pc.FameLv + 10 - 1;
489 }
490 product.SetInt(25, num4);
491 }
492 }
493 else
494 {
495 product.elements.ModBase(10, 6);
496 }
497 if (product.HasElement(762))
498 {
499 product.elements.ModBase(10, product.Evalue(762) / 5);
500 if (product.Evalue(10) < 1)
501 {
502 product.elements.SetTo(10, 1);
503 }
504 }
505 if (creative && isFood && product.category.IsChildOf("meal"))
506 {
507 product.elements.SetBase(764, 1);
508 }
509 return product;
510 bool IsValidTrait(Element e)
511 {
512 if (e.HasTag("noInherit"))
513 {
514 return false;
515 }
516 switch (type)
517 {
518 case MixType.General:
519 if (e.IsTrait)
520 {
521 return true;
522 }
523 if (e.IsFoodTrait)
524 {
525 return product.IsInheritFoodTraits;
526 }
527 break;
528 case MixType.Food:
529 case MixType.Drink:
530 if (e.IsFoodTrait || e.IsTrait || e.id == 2)
531 {
532 return true;
533 }
534 break;
535 }
536 return false;
537 }
538 void MixElements(Card t)
539 {
540 if (t != null)
541 {
542 foreach (Element value3 in t.elements.dict.Values)
543 {
544 if (IsValidTrait(value3) && (!noMix || value3.id == 2))
545 {
546 if (isFoodOrDrink && value3.IsFoodTraitMain)
547 {
548 int num5 = value3.Value;
549 if (product.id == "lunch_dystopia")
550 {
551 num5 *= -1;
552 }
553 if (creative && num5 > 500)
554 {
555 num5 = 500;
556 }
557 product.elements.ModBase(value3.id, num5);
558 }
559 else
560 {
561 int num6 = product.elements.Base(value3.id);
562 if ((num6 <= 0 && value3.Value < 0 && value3.Value < num6) || (value3.Value > 0 && value3.Value > num6))
563 {
564 product.elements.SetTo(value3.id, value3.Value);
565 }
566 }
567 }
568 }
569 if (isFood)
570 {
571 product.elements.ModBase(10, t.Evalue(10) * nutFactor / 100);
572 }
573 if (isDrink)
574 {
575 product.elements.ModBase(10, Mathf.CeilToInt((float)t.Evalue(10) * (float)nutFactor / 100f));
576 }
577 }
578 }
579 }
@ noMix
void SetTier(int a, bool setTraits=true)
Definition: Card.cs:4027
int FameLv
Definition: Card.cs:2352
int tier
Definition: Card.cs:413
bool IsInheritFoodTraits
Definition: Card.cs:2232
int c_fixedValue
Definition: Card.cs:1200
int c_priceCopy
Definition: Card.cs:1188
int decay
Definition: Card.cs:221
Trait trait
Definition: Card.cs:54
void ChangeWeight(int a)
Definition: Card.cs:2681
bool HasCraftBonusTrait()
Definition: Card.cs:7379
virtual Thing Thing
Definition: Card.cs:2110
int idSkin
Definition: Card.cs:365
List< Element > ListCraftBonusTraits()
Definition: Card.cs:7384
SourceCategory.Row category
Definition: Card.cs:2101
int GetValue(PriceType priceType=PriceType.Default, bool sell=false)
Definition: Card.cs:7615
int Value(int ele)
bool HasTag(string tag)
Definition: ELEMENT.cs:480
bool IsFoodTrait
Definition: ELEMENT.cs:371
bool IsTrait
Definition: ELEMENT.cs:369
int value
Definition: RenderRow.cs:20
SourceThing.Row source
Definition: Thing.cs:11
override int SelfWeight
Definition: Thing.cs:64
override CardRow sourceCard
Definition: Thing.cs:47

References Card.c_idRefCard, Card.c_priceCopy, ElementContainer.dict, Card.elements, Card.Evalue(), Card.FameLv, Card.GetInt(), Card.GetValue(), Card.HasCraftBonusTrait(), Card.HasElement(), Card.HasTag(), Element.HasTag(), Card.id, Element.id, Element.IsFoodTrait, Element.IsFoodTraitMain, Element.IsTrait, item, Card.ListCraftBonusTraits(), ElementContainer.ModBase(), noMix, EClass.pc, Thing.SelfWeight, ElementContainer.SetTo(), Card.Thing, and Element.Value.

◆ MixIngredients() [2/2]

static Thing CraftUtil.MixIngredients ( string  idProduct,
List< Thing ings,
MixType  type,
int  idMat = 0,
Chara  crafter = null 
)
inlinestatic

Definition at line 364 of file CraftUtil.cs.

365 {
366 Thing thing = ThingGen.Create(idProduct);
367 if (idMat != 0)
368 {
369 thing.ChangeMaterial(idMat);
370 }
371 MixIngredients(thing, ings, type, 999, crafter);
372 return thing;
373 }
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3194

References Card.ChangeMaterial(), and ThingGen.Create().

Referenced by TraitCrafter.Craft(), RecipeCard.MixIngredients(), TraitBrewery.OnChildDecay(), and TaskChopWood.OnCreateProgress().

◆ ModRandomFoodEnc()

static void CraftUtil.ModRandomFoodEnc ( Thing  t)
inlinestatic

Definition at line 23 of file CraftUtil.cs.

24 {
25 List<Element> list = new List<Element>();
26 foreach (Element value in t.elements.dict.Values)
27 {
28 if (value.IsFoodTrait)
29 {
30 list.Add(value);
31 }
32 }
33 if (list.Count != 0)
34 {
35 Element element = list.RandomItem();
36 t.elements.ModBase(element.id, EClass.rnd(6) + 1);
37 if (element.Value > 60)
38 {
39 t.elements.SetTo(element.id, 60);
40 }
41 }
42 }

References Element.id, Element.IsFoodTrait, EClass.rnd(), and Element.Value.

Referenced by TraitSeed.LevelSeed().

◆ WrapIngredient()

static void CraftUtil.WrapIngredient ( Card  product,
Chara  c,
Card  ing,
WrapType  wrapType 
)
inlinestatic

Definition at line 265 of file CraftUtil.cs.

266 {
267 if (product.c_mixedFoodData == null)
268 {
269 product.c_mixedFoodData = new MixedFoodData();
270 }
271 product.c_mixedFoodData.texts.Add(ing.Name + ((wrapType == WrapType.Dark) ? "isMixedBy".lang(c.NameSimple) : ""));
272 foreach (Element value in ing.elements.dict.Values)
273 {
274 if (!IsValidTrait(value))
275 {
276 continue;
277 }
278 if (value.IsFoodTraitMain)
279 {
280 int num = value.Value;
281 if (ing.id == "lunch_dystopia" && (wrapType == WrapType.Dark || num < 0))
282 {
283 num *= -1;
284 }
285 product.elements.ModBase(value.id, num);
286 }
287 else
288 {
289 int num2 = product.elements.Base(value.id);
290 if ((num2 <= 0 && value.Value < 0 && value.Value < num2) || (value.Value > 0 && value.Value > num2))
291 {
292 product.elements.SetTo(value.id, value.Value);
293 }
294 }
295 }
296 product.elements.ModBase(10, ing.Evalue(10));
297 static bool IsValidTrait(Element e)
298 {
299 if (e.HasTag("noInherit"))
300 {
301 return false;
302 }
303 if (e.IsFoodTrait || e.IsTrait || e.id == 2)
304 {
305 return true;
306 }
307 return false;
308 }
309 }
string Name
Definition: Card.cs:2191
MixedFoodData c_mixedFoodData
Definition: Card.cs:1957
string NameSimple
Definition: Card.cs:2193
List< string > texts
Definition: MixedFoodData.cs:7

References Card.c_mixedFoodData, Element.HasTag(), Element.id, Element.IsFoodTrait, Element.IsFoodTraitMain, Element.IsTrait, Card.Name, Card.NameSimple, MixedFoodData.texts, and Element.Value.

Member Data Documentation

◆ ListFoodEffect

string [] CraftUtil.ListFoodEffect = new string[2] { "exp", "pot" }
static

Definition at line 21 of file CraftUtil.cs.

Referenced by AddRandomFoodEnc().


The documentation for this class was generated from the following file: