Elin Decompiled Documentation EA 23.244 Nightly
Loading...
Searching...
No Matches
CraftUtil Class Reference
Inheritance diagram for CraftUtil:
EClass

Public Types

enum  MixType { General , Food , NoMix }
 
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 (int _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 

Definition at line 7 of file CraftUtil.cs.

◆ WrapType

Enumerator
Love 
Dark 

Definition at line 14 of file CraftUtil.cs.

Member Function Documentation

◆ AddRandomFoodEnc()

static void CraftUtil.AddRandomFoodEnc ( Thing  t)
inlinestatic

Definition at line 43 of file CraftUtil.cs.

44 {
45 List<SourceElement.Row> list = EClass.sources.elements.rows.Where((SourceElement.Row e) => e.foodEffect.Length > 1 && ListFoodEffect.Contains(e.foodEffect[0])).ToList();
46 list.ForeachReverse(delegate(SourceElement.Row e)
47 {
48 if (t.elements.dict.ContainsKey(e.id))
49 {
50 list.Remove(e);
51 }
52 });
53 if (list.Count != 0)
54 {
55 SourceElement.Row row = list.RandomItemWeighted((SourceElement.Row a) => a.chance);
56 t.elements.SetBase(row.id, 1);
57 t.c_seed = row.id;
58 }
59 }
ElementContainerCard elements
Definition: Card.cs:41
static string[] ListFoodEffect
Definition: CraftUtil.cs:20
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 117 of file CraftUtil.cs.

118 {
119 string text = "";
120 List<Element> list = MakeBloodMeal(EClass.pc, c, msg: false).elements.ListElements((Element e) => e.IsFoodTraitMain, (Element a, Element b) => b.Value - a.Value);
121 int num = Mathf.Min(list.Count(), 3, EClass.debug.godMode ? 3 : (1 + EClass.pc.Evalue(6607) / 15));
122 for (int i = 0; i < num; i++)
123 {
124 Element element = list[i];
125 string[] textArray = element.source.GetTextArray("textAlt");
126 int num2 = Mathf.Clamp(element.Value / 10 + 1, (element.Value < 0 || textArray.Length <= 2) ? 1 : 2, textArray.Length - 1);
127 string text2 = textArray[num2];
128 if (i != 0)
129 {
130 text += ", ";
131 }
132 text += text2;
133 }
134 if (!text.IsEmpty())
135 {
136 text = " (" + text + ")";
137 }
138 return text;
139 }
int Evalue(int ele)
Definition: Card.cs:2571
bool godMode
Definition: CoreDebug.cs:173
static Thing MakeBloodMeal(Chara sucker, Chara feeder, bool msg=true)
Definition: CraftUtil.cs:154
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:273
int Value
Definition: ELEMENT.cs:292
bool IsFoodTraitMain
Definition: ELEMENT.cs:367

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 141 of file CraftUtil.cs.

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

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

Referenced by AI_Idle.Run().

◆ GetRandomDarkSoupIngredient()

static Thing CraftUtil.GetRandomDarkSoupIngredient ( Chara  c)
inlinestatic

Definition at line 215 of file CraftUtil.cs.

216 {
217 return ThingGen.CreateFromFilter("darksoup", c.LV);
218 }
int LV
Definition: Card.cs:386
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 249 of file CraftUtil.cs.

250 {
251 Thing thing = null;
252 for (int i = 0; i < 3; i++)
253 {
254 thing = ThingGen.Create("dish", -1, c.Evalue(287) + 5 + (EClass.debug.enable ? c.LV : 0));
255 if (!thing.HasTag(CTAG.dish_fail))
256 {
257 break;
258 }
259 }
260 MakeDish(thing, c.LV, c);
261 return thing;
262 }
CTAG
Definition: CTAG.cs:2
bool HasTag(CTAG tag)
Definition: Card.cs:2595
bool enable
Definition: CoreDebug.cs:286
static void MakeDish(Thing food, int lv, Chara crafter=null, int seed=-1)
Definition: CraftUtil.cs:61
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 154 of file CraftUtil.cs.

155 {
156 Thing c_bloodData = feeder.c_bloodData;
157 if (c_bloodData == null)
158 {
159 int num = ((feeder.GetInt(118) == 0) ? (EClass.game.seed + feeder.uid) : feeder.GetInt(118));
160 Rand.SetSeed(num);
161 c_bloodData = ThingGen.CreateFromCategory("meal", 100);
162 if (msg)
163 {
164 sucker.Say("food_blood", c_bloodData);
165 }
166 MakeDish(c_bloodData, 100, null, num + feeder.uid);
167 c_bloodData.elements.SetTo(709, 0);
168 c_bloodData.elements.SetTo(708, 0);
169 c_bloodData.elements.SetTo(701, 0);
170 feeder.c_bloodData = c_bloodData.Duplicate(1);
171 }
172 else
173 {
174 c_bloodData = c_bloodData.Duplicate(1);
175 if (msg)
176 {
177 sucker.Say("food_blood", c_bloodData);
178 }
179 }
180 c_bloodData.elements.SetTo(2, Mathf.Min(EClass.curve(feeder.LV, 30, 10, 65), 200));
181 c_bloodData.elements.ModBase(710, 15 + (int)Mathf.Min(Mathf.Sqrt(sucker.Evalue(6607) + Mathf.Max(sucker.LER, 0)), 55f));
182 return c_bloodData;
183 }
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
int LER
Definition: Card.cs:2341
Thing c_bloodData
Definition: Card.cs:1917
int uid
Definition: Card.cs:122
Thing Duplicate(int num)
Definition: Card.cs:3444
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6797
static Game game
Definition: EClass.cs:9
static int curve(int _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:200
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37
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, BaseCard.GetInt(), Card.LER, Card.LV, ElementContainer.ModBase(), Card.Say(), Game.seed, Rand.SetSeed(), ElementContainer.SetTo(), and Card.uid.

Referenced by AI_Fuck.Finish(), and CoreDebug.UpdateInput().

◆ MakeBloodSample()

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

Definition at line 185 of file CraftUtil.cs.

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

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 200 of file CraftUtil.cs.

201 {
202 Thing thing = ThingGen.Create("soup_dark");
203 for (int i = 0; i < 4 + EClass.rnd(4); i++)
204 {
205 Chara c = EClass._map.charas.RandomItem();
207 }
209 {
210 thing.c_IDTState = 1;
211 }
212 return thing;
213 }
Definition: Chara.cs:10
bool autoIdentify
Definition: CoreDebug.cs:189
static Thing GetRandomDarkSoupIngredient(Chara c)
Definition: CraftUtil.cs:215
static void WrapIngredient(Card product, Chara c, Card ing, WrapType wrapType)
Definition: CraftUtil.cs:264
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 310 of file CraftUtil.cs.

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

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 61 of file CraftUtil.cs.

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

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 220 of file CraftUtil.cs.

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

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(), Chara.ShowDialog(), and CoreDebug.UpdateInput().

◆ MixIngredients() [1/2]

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

Definition at line 374 of file CraftUtil.cs.

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

References Card.c_idRefCard, Card.c_priceCopy, ElementContainer.dict, Card.elements, Card.Evalue(), Card.FameLv, BaseCard.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 363 of file CraftUtil.cs.

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

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 22 of file CraftUtil.cs.

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

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 264 of file CraftUtil.cs.

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

Referenced by AddRandomFoodEnc().


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