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

Public Types

enum  MixType { General , Food , NoMix }
 

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 rndSeed (int a, int seed)
 
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 
NoMix 

Definition at line 7 of file CraftUtil.cs.

Member Function Documentation

◆ AddRandomFoodEnc()

static void CraftUtil.AddRandomFoodEnc ( Thing  t)
inlinestatic

Definition at line 37 of file CraftUtil.cs.

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

92 {
93 List<Thing> list = new List<Thing>();
94 bool flag = food.sourceCard.vals.Contains("fixed");
95 for (int i = 0; i < ings.Count; i++)
96 {
97 Thing thing = ings[i];
98 if (flag)
99 {
100 list.Add(thing);
101 break;
102 }
103 if (!IsIgnoreName(thing))
104 {
105 list.Add(thing);
106 }
107 }
108 if (list.Count > 0)
109 {
110 Thing thing2 = list.RandomItem();
111 if (thing2 != null)
112 {
113 food.MakeRefFrom(thing2);
114 if (thing2.c_idRefCard != null)
115 {
116 food.c_idRefCard = thing2.c_idRefCard;
117 food.c_altName = food.TryGetFoodName(thing2);
118 if (thing2.id == "_egg" || thing2.id == "egg_fertilized")
119 {
120 food.c_altName = "_egg".lang(food.c_altName);
121 }
122 }
123 }
124 }
125 MixIngredients(food, ings, MixType.Food, qualityBonus, crafter);
126 static bool IsIgnoreName(Card t)
127 {
128 if (t == null)
129 {
130 return true;
131 }
132 switch (t.sourceCard._origin)
133 {
134 case "dough":
135 case "dish":
136 case "dish_lunch":
137 return true;
138 default:
139 return false;
140 }
141 }
142 }
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:2031
string c_idRefCard
Definition: Card.cs:1661
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:144
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 55 of file CraftUtil.cs.

56 {
58 List<Thing> list = new List<Thing>();
59 RecipeSource recipeSource = RecipeManager.Get(food.id);
60 Debug.Log(recipeSource);
61 if (recipeSource == null)
62 {
63 return;
64 }
65 int num = Mathf.Min(EClass.rnd(lv), 50);
66 foreach (Recipe.Ingredient ingredient in recipeSource.GetIngredients())
67 {
68 Thing thing = ThingGen.Create(ingredient.id);
69 TraitSeed.LevelSeed(thing, null, EClass.rnd(lv / 4) + 1);
70 thing.SetEncLv(thing.encLV / 2);
71 if (num > 0 && EClass.rnd(3) == 0)
72 {
73 thing.elements.SetBase(2, num);
74 }
75 list.Add(thing);
76 }
77 MakeDish(food, list, num, crafter);
78 if (crafter != null && crafter.id != "rodwyn")
79 {
80 if (food.HasElement(709))
81 {
82 food.elements.Remove(709);
83 }
84 if (food.HasElement(708) && !crafter.HasElement(1205))
85 {
86 food.elements.Remove(708);
87 }
88 }
89 }
bool HasElement(int ele, int req=1)
Definition: Card.cs:5395
int encLV
Definition: Card.cs:310
void SetEncLv(int a)
Definition: Card.cs:3611
static void MakeDish(Thing food, int lv, Chara crafter=null)
Definition: CraftUtil.cs:55
static int rnd(int a)
Definition: EClass.cs:58
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 155 of file CraftUtil.cs.

156 {
157 bool noMix = type == MixType.NoMix || product.HasTag(CTAG.noMix);
158 bool isFood = type == MixType.Food;
159 int nutFactor = 100 - (ings.Count - 1) * 5;
160 Thing thing = ((ings.Count > 0) ? ings[0] : null);
161 if (crafter != null && crafter.Evalue(1650) >= 3)
162 {
163 nutFactor -= 10;
164 }
165 if (!noMix)
166 {
167 foreach (Element value2 in product.elements.dict.Values)
168 {
169 int id = value2.id;
170 if ((uint)(id - 914) > 1u && value2.Value >= 0 && (value2.HasTag("noInherit") || IsValidTrait(value2)))
171 {
172 product.elements.SetTo(value2.id, 0);
173 }
174 }
175 }
176 if (product.HasCraftBonusTrait())
177 {
178 foreach (Element item in product.ListCraftBonusTraits())
179 {
180 product.elements.ModBase(item.id, item.Value);
181 }
182 }
183 if (isFood)
184 {
185 product.elements.SetTo(10, 5);
186 }
187 int num = 0;
188 int num2 = 0;
189 int num3 = 0;
190 foreach (Thing ing in ings)
191 {
192 if (ing != null)
193 {
194 MixElements(ing);
195 num3 += ing.c_priceCopy;
196 if (isFood)
197 {
198 num += Mathf.Clamp(ing.SelfWeight * 80 / 100, 50, 400 + ing.SelfWeight / 20);
199 int value = ing.GetValue();
200 num2 += value;
201 }
202 }
203 }
204 if (isFood)
205 {
206 product.isWeightChanged = true;
207 product.c_weight = num;
208 product.c_priceAdd = num2;
209 }
210 product.c_priceCopy = num3;
211 if (thing != null && product.trait is TraitFoodFishSlice)
212 {
213 product.elements.SetTo(10, thing.Evalue(10) / 4);
214 product.isWeightChanged = true;
215 product.c_weight = Mathf.Min(thing.SelfWeight / 6, 1000);
216 product.c_idRefCard = thing.id;
217 product.c_priceCopy = ((thing.c_priceCopy == 0) ? thing.GetValue() : thing.c_priceCopy);
218 product.c_fixedValue = ((thing.c_fixedValue == 0) ? thing.sourceCard.value : thing.c_fixedValue) / 4;
219 product.c_priceAdd = 0;
220 product.decay = thing.decay;
221 product.elements.SetBase(707, 1);
222 product.SetTier(thing.tier, setTraits: false);
223 product.idSkin = ((thing.trait is TraitFoodFishSlice) ? thing.idSkin : (thing.HasTag(CTAG.bigFish) ? 1 : 0));
224 }
225 if (product.HasElement(652))
226 {
227 product.ChangeWeight((isFood ? num : product.Thing.source.weight) * 100 / (100 + product.Evalue(652)));
228 }
229 if (product.elements.Value(2) > maxQuality)
230 {
231 product.elements.SetTo(2, maxQuality);
232 }
233 string id2 = product.id;
234 if (!(id2 == "zassouni"))
235 {
236 if (id2 == "map")
237 {
238 int num4 = 1 + product.Evalue(2) + product.Evalue(751);
239 if (num4 < 1)
240 {
241 num4 = 1;
242 }
243 foreach (Thing ing2 in ings)
244 {
245 if (ing2 != null && ing2.Thing != null && !(ing2.id != "gem"))
246 {
247 num4 *= ing2.Thing.material.hardness / 20 + 2;
248 }
249 }
250 if (num4 > EClass.pc.FameLv + 10 - 1)
251 {
252 num4 = EClass.pc.FameLv + 10 - 1;
253 }
254 product.SetInt(25, num4);
255 }
256 }
257 else
258 {
259 product.elements.ModBase(10, 6);
260 }
261 if (product.HasElement(762))
262 {
263 product.elements.ModBase(10, product.Evalue(762) / 5);
264 if (product.Evalue(10) < 1)
265 {
266 product.elements.SetTo(10, 1);
267 }
268 }
269 return product;
270 bool IsValidTrait(Element e)
271 {
272 if (e.HasTag("noInherit"))
273 {
274 return false;
275 }
276 switch (type)
277 {
278 case MixType.General:
279 if (e.IsTrait)
280 {
281 return true;
282 }
283 if (e.IsFoodTrait)
284 {
285 return product.IsInheritFoodTraits;
286 }
287 break;
288 case MixType.Food:
289 if (e.IsFoodTrait || e.IsTrait || e.id == 2)
290 {
291 return true;
292 }
293 break;
294 }
295 return false;
296 }
297 void MixElements(Card t)
298 {
299 if (t != null)
300 {
301 foreach (Element value3 in t.elements.dict.Values)
302 {
303 if (IsValidTrait(value3) && (!noMix || value3.id == 2))
304 {
305 if (isFood && value3.IsFoodTraitMain)
306 {
307 product.elements.ModBase(value3.id, value3.Value);
308 }
309 else
310 {
311 int num5 = product.elements.Base(value3.id);
312 if ((num5 <= 0 && value3.Value < 0 && value3.Value < num5) || (value3.Value > 0 && value3.Value > num5))
313 {
314 product.elements.SetTo(value3.id, value3.Value);
315 }
316 }
317 }
318 }
319 if (isFood)
320 {
321 product.elements.ModBase(10, t.Evalue(10) * nutFactor / 100);
322 }
323 }
324 }
325 }
CTAG
Definition: CTAG.cs:2
@ noMix
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
void SetTier(int a, bool setTraits=true)
Definition: Card.cs:3616
int FameLv
Definition: Card.cs:2198
int tier
Definition: Card.cs:394
bool IsInheritFoodTraits
Definition: Card.cs:2078
int c_fixedValue
Definition: Card.cs:1133
int c_priceCopy
Definition: Card.cs:1121
int decay
Definition: Card.cs:202
bool HasTag(CTAG tag)
Definition: Card.cs:2495
Trait trait
Definition: Card.cs:49
void ChangeWeight(int a)
Definition: Card.cs:2464
bool HasCraftBonusTrait()
Definition: Card.cs:6362
virtual Thing Thing
Definition: Card.cs:1958
int Evalue(int ele)
Definition: Card.cs:2471
int idSkin
Definition: Card.cs:346
List< Element > ListCraftBonusTraits()
Definition: Card.cs:6367
int GetValue(PriceType priceType=PriceType.Default, bool sell=false)
Definition: Card.cs:6598
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:246
bool HasTag(string tag)
Definition: ELEMENT.cs:469
int Value
Definition: ELEMENT.cs:288
bool IsFoodTrait
Definition: ELEMENT.cs:360
bool IsTrait
Definition: ELEMENT.cs:358
bool IsFoodTraitMain
Definition: ELEMENT.cs:363
int value
Definition: RenderRow.cs:20
SourceThing.Row source
Definition: Thing.cs:11
override int SelfWeight
Definition: Thing.cs:62
override CardRow sourceCard
Definition: Thing.cs:47

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

145 {
146 Thing thing = ThingGen.Create(idProduct);
147 if (idMat != 0)
148 {
149 thing.ChangeMaterial(idMat);
150 }
151 MixIngredients(thing, ings, type, 999, crafter);
152 return thing;
153 }
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:2887

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

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

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

Referenced by AddRandomFoodEnc().


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