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

Public Types

enum  MixType { General , Food }
 

Static Public Member Functions

static void ModRandomFoodEnc (Thing t)
 
static void AddRandomFoodEnc (Thing t)
 
static void MakeDish (Thing food, int lv, Chara crafter=null)
 
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 rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
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 

Definition at line 7 of file CraftUtil.cs.

Member Function Documentation

◆ AddRandomFoodEnc()

static void CraftUtil.AddRandomFoodEnc ( Thing  t)
inlinestatic

Definition at line 36 of file CraftUtil.cs.

37 {
38 List<SourceElement.Row> list = EClass.sources.elements.rows.Where((SourceElement.Row e) => e.foodEffect.Length > 1 && ListFoodEffect.Contains(e.foodEffect[0])).ToList();
39 list.ForeachReverse(delegate(SourceElement.Row e)
40 {
41 if (t.elements.dict.ContainsKey(e.id))
42 {
43 list.Remove(e);
44 }
45 });
46 if (list.Count != 0)
47 {
48 SourceElement.Row row = list.RandomItemWeighted((SourceElement.Row a) => a.chance);
49 t.elements.SetBase(row.id, 1);
50 t.c_seed = row.id;
51 }
52 }
ElementContainerCard elements
Definition: Card.cs:37
static string[] ListFoodEffect
Definition: CraftUtil.cs:13
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
Element SetBase(string alias, int v, int potential=0)
SourceElement elements

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

Referenced by TraitSeed.LevelSeed().

◆ MakeDish() [1/2]

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

Definition at line 79 of file CraftUtil.cs.

80 {
81 List<Thing> list = new List<Thing>();
82 bool flag = food.sourceCard.vals.Contains("fixed");
83 for (int i = 0; i < ings.Count; i++)
84 {
85 Thing thing = ings[i];
86 if (flag)
87 {
88 list.Add(thing);
89 break;
90 }
91 if (!IsIgnoreName(thing))
92 {
93 list.Add(thing);
94 }
95 }
96 if (list.Count > 0)
97 {
98 Thing thing2 = list.RandomItem();
99 if (thing2 != null)
100 {
101 food.MakeRefFrom(thing2);
102 if (thing2.c_idRefCard != null)
103 {
104 food.c_idRefCard = thing2.c_idRefCard;
105 food.c_altName = food.TryGetFoodName(thing2);
106 if (thing2.id == "_egg" || thing2.id == "egg_fertilized")
107 {
108 food.c_altName = "_egg".lang(food.c_altName);
109 }
110 }
111 }
112 }
113 MixIngredients(food, ings, MixType.Food, qualityBonus, crafter);
114 static bool IsIgnoreName(Card t)
115 {
116 if (t == null)
117 {
118 return true;
119 }
120 switch (t.sourceCard._origin)
121 {
122 case "dough":
123 case "dish":
124 case "dish_lunch":
125 return true;
126 default:
127 return false;
128 }
129 }
130 }
void Add(Act a, string s="")
Definition: ActPlan.cs:11
string _origin
Definition: CardRow.cs:15
Definition: Card.cs:11
string id
Definition: Card.cs:31
virtual CardRow sourceCard
Definition: Card.cs:2007
string c_idRefCard
Definition: Card.cs:1637
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:132
Definition: Thing.cs:8

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 
)
inlinestatic

Definition at line 54 of file CraftUtil.cs.

55 {
57 List<Thing> list = new List<Thing>();
58 RecipeSource recipeSource = RecipeManager.Get(food.id);
59 Debug.Log(recipeSource);
60 if (recipeSource == null)
61 {
62 return;
63 }
64 int num = Mathf.Min(EClass.rnd(lv), 50);
65 foreach (Recipe.Ingredient ingredient in recipeSource.GetIngredients())
66 {
67 Thing thing = ThingGen.Create(ingredient.id);
68 TraitSeed.LevelSeed(thing, null, EClass.rnd(lv / 4) + 1);
69 thing.SetEncLv(thing.encLV / 2);
70 if (num > 0 && EClass.rnd(3) == 0)
71 {
72 thing.elements.SetBase(2, num);
73 }
74 list.Add(thing);
75 }
76 MakeDish(food, list, num, crafter);
77 }
int encLV
Definition: Card.cs:310
void SetEncLv(int a)
Definition: Card.cs:3567
static void MakeDish(Thing food, int lv, Chara crafter=null)
Definition: CraftUtil.cs:54
static int rnd(int a)
Definition: EClass.cs:50
static void BuildList()
static RecipeSource Get(string id)
List< Recipe.Ingredient > GetIngredients()
Definition: Recipe.cs:7
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
static void LevelSeed(Thing t, SourceObj.Row obj, int num)
Definition: TraitSeed.cs:129

References RecipeManager.BuildList(), ThingGen.Create(), Debug, Card.elements, Card.encLV, food, RecipeManager.Get(), RecipeSource.GetIngredients(), TraitSeed.LevelSeed(), EClass.rnd(), ElementContainer.SetBase(), and Card.SetEncLv().

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

◆ MixIngredients() [1/2]

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

Definition at line 143 of file CraftUtil.cs.

144 {
145 bool isFood = type == MixType.Food;
146 int nutFactor = 100 - (ings.Count - 1) * 5;
147 if (crafter != null && crafter.Evalue(1650) >= 3)
148 {
149 nutFactor -= 10;
150 }
151 foreach (Element value2 in product.elements.dict.Values)
152 {
153 int id = value2.id;
154 if ((uint)(id - 914) > 1u && value2.Value >= 0 && (value2.HasTag("noInherit") || IsValidTrait(value2)))
155 {
156 product.elements.SetTo(value2.id, 0);
157 }
158 }
159 if (product.HasTag(CTAG.dish_bonus))
160 {
161 foreach (Element value3 in product.sourceCard.model.elements.dict.Values)
162 {
163 if (value3.IsFoodTraitMain)
164 {
165 product.elements.ModBase(value3.id, value3.Value);
166 }
167 }
168 }
169 if (isFood)
170 {
171 product.elements.SetTo(10, 5);
172 }
173 int num = 0;
174 int num2 = 0;
175 foreach (Thing ing in ings)
176 {
177 if (ing != null)
178 {
179 MixElements(ing);
180 if (isFood)
181 {
182 num += Mathf.Clamp(ing.SelfWeight * 80 / 100, 50, 400 + ing.SelfWeight / 20);
183 int value = ing.GetValue();
184 num2 += value;
185 }
186 }
187 }
188 if (isFood)
189 {
190 product.isWeightChanged = true;
191 product.c_weight = num;
192 product.c_priceAdd = num2;
193 }
194 if (product.HasElement(652))
195 {
196 product.ChangeWeight((isFood ? num : product.Thing.source.weight) * 100 / (100 + product.Evalue(652)));
197 }
198 if (product.elements.Value(2) > maxQuality)
199 {
200 product.elements.SetTo(2, maxQuality);
201 }
202 string id2 = product.id;
203 if (!(id2 == "zassouni"))
204 {
205 if (id2 == "map")
206 {
207 int num3 = 1 + product.Evalue(2) + product.Evalue(751);
208 if (num3 < 1)
209 {
210 num3 = 1;
211 }
212 foreach (Thing ing2 in ings)
213 {
214 if (ing2 != null && ing2.Thing != null && !(ing2.id != "gem"))
215 {
216 num3 *= ing2.Thing.material.hardness / 20 + 2;
217 }
218 }
219 if (num3 > EClass.pc.FameLv + 10 - 1)
220 {
221 num3 = EClass.pc.FameLv + 10 - 1;
222 }
223 product.SetInt(25, num3);
224 }
225 }
226 else
227 {
228 product.elements.ModBase(10, 6);
229 }
230 return product;
231 bool IsValidTrait(Element e)
232 {
233 if (e.HasTag("noInherit"))
234 {
235 return false;
236 }
237 switch (type)
238 {
239 case MixType.General:
240 if (e.IsTrait)
241 {
242 return true;
243 }
244 if (e.IsFoodTrait)
245 {
246 return product.ShowFoodEnc;
247 }
248 break;
249 case MixType.Food:
250 if (e.IsFoodTrait || e.IsTrait || e.id == 2)
251 {
252 return true;
253 }
254 break;
255 }
256 return false;
257 }
258 void MixElements(Card t)
259 {
260 if (t != null)
261 {
262 foreach (Element value4 in t.elements.dict.Values)
263 {
264 if (IsValidTrait(value4))
265 {
266 if (isFood && value4.IsFoodTraitMain)
267 {
268 product.elements.ModBase(value4.id, value4.Value);
269 }
270 else
271 {
272 int num4 = product.elements.Base(value4.id);
273 if ((num4 <= 0 && value4.Value < 0 && value4.Value < num4) || (value4.Value > 0 && value4.Value > num4))
274 {
275 product.elements.SetTo(value4.id, value4.Value);
276 }
277 }
278 }
279 }
280 if (isFood)
281 {
282 product.elements.ModBase(10, t.Evalue(10) * nutFactor / 100);
283 }
284 }
285 }
286 }
CTAG
Definition: CTAG.cs:2
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
Card model
Definition: CardRow.cs:60
int FameLv
Definition: Card.cs:2158
bool HasElement(int ele, int req=1)
Definition: Card.cs:5214
int GetValue(bool sell=false)
Definition: Card.cs:6387
bool HasTag(CTAG tag)
Definition: Card.cs:2455
void ChangeWeight(int a)
Definition: Card.cs:2424
virtual Thing Thing
Definition: Card.cs:1934
int Evalue(int ele)
Definition: Card.cs:2431
bool ShowFoodEnc
Definition: Card.cs:2054
static Chara pc
Definition: EClass.cs:14
Dictionary< int, Element > dict
int Value(int ele)
Element ModBase(int ele, int v)
void SetTo(int id, int v)
int id
Definition: ELEMENT.cs:240
bool HasTag(string tag)
Definition: ELEMENT.cs:463
int Value
Definition: ELEMENT.cs:282
bool IsFoodTrait
Definition: ELEMENT.cs:354
bool IsTrait
Definition: ELEMENT.cs:352
bool IsFoodTraitMain
Definition: ELEMENT.cs:357
SourceThing.Row source
Definition: Thing.cs:11
override int SelfWeight
Definition: Thing.cs:62

References ElementContainer.dict, Card.elements, Card.Evalue(), Card.FameLv, Card.GetValue(), Element.HasTag(), Card.id, Element.id, Element.IsFoodTrait, Element.IsFoodTraitMain, Element.IsTrait, EClass.pc, Thing.SelfWeight, 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 132 of file CraftUtil.cs.

133 {
134 Thing thing = ThingGen.Create(idProduct);
135 if (idMat != 0)
136 {
137 thing.ChangeMaterial(idMat);
138 }
139 MixIngredients(thing, ings, type, 999, crafter);
140 return thing;
141 }
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:2838

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

16 {
17 List<Element> list = new List<Element>();
18 foreach (Element value in t.elements.dict.Values)
19 {
20 if (value.IsFoodTrait)
21 {
22 list.Add(value);
23 }
24 }
25 if (list.Count != 0)
26 {
27 Element element = list.RandomItem();
28 t.elements.ModBase(element.id, EClass.rnd(6) + 1);
29 if (element.Value > 60)
30 {
31 t.elements.SetTo(element.id, 60);
32 }
33 }
34 }

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

Referenced by TraitSeed.LevelSeed().

Member Data Documentation

◆ ListFoodEffect

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

Definition at line 13 of file CraftUtil.cs.

Referenced by AddRandomFoodEnc().


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