Elin Modding Docs Doc
Loading...
Searching...
No Matches
FoodEffect.cs
1using System;
2using System.Collections.Generic;
3using System.Runtime.CompilerServices;
4using UnityEngine;
5
6// Token: 0x020001F4 RID: 500
7public class FoodEffect : EClass
8{
9 // Token: 0x06000E54 RID: 3668 RVA: 0x0006BEB6 File Offset: 0x0006A0B6
10 public static bool IsHumanFlesh(Thing food)
11 {
12 return !food.HasTag(CTAG.notHumanMeat) && (FoodEffect.IsHumanFlesh(food.refCard) || FoodEffect.IsHumanFlesh(food.refCard2));
13 }
14
15 // Token: 0x06000E55 RID: 3669 RVA: 0x0006BEDE File Offset: 0x0006A0DE
16 public static bool IsUndeadFlesh(Thing food)
17 {
18 return FoodEffect.IsUndeadFlesh(food.refCard) || FoodEffect.IsUndeadFlesh(food.refCard2);
19 }
20
21 // Token: 0x06000E56 RID: 3670 RVA: 0x0006BEFC File Offset: 0x0006A0FC
22 public static bool IsHumanFlesh(CardRow r)
23 {
24 if (r == null)
25 {
26 return false;
27 }
28 if (r.id == "chara")
29 {
30 return EClass.pc.race.tag.Contains("human");
31 }
32 return r.isChara && EClass.sources.races.map[EClass.sources.charas.map[r.id].race].tag.Contains("human");
33 }
34
35 // Token: 0x06000E57 RID: 3671 RVA: 0x0006BF88 File Offset: 0x0006A188
36 public static bool IsUndeadFlesh(CardRow r)
37 {
38 if (r == null)
39 {
40 return false;
41 }
42 if (r.id == "chara")
43 {
44 return EClass.pc.race.tag.Contains("undead");
45 }
46 return r.isChara && EClass.sources.races.map[EClass.sources.charas.map[r.id].race].tag.Contains("undead");
47 }
48
49 // Token: 0x06000E58 RID: 3672 RVA: 0x0006C014 File Offset: 0x0006A214
50 public static void Proc(Chara c, Thing food)
51 {
52 FoodEffect.<>c__DisplayClass4_0 CS$<>8__locals1;
53 CS$<>8__locals1.c = c;
54 bool flag = EClass._zone.IsPCFaction && CS$<>8__locals1.c.IsInSpot<TraitSpotDining>();
55 float num = (float)(100 + (flag ? 10 : 0) + Mathf.Min(food.QualityLv * 10, 100)) / 200f;
56 if (num < 0.1f)
57 {
58 num = 0.1f;
59 }
60 int num2 = food.Evalue(10);
61 float num3 = 40f;
62 float num4 = 1f;
63 CS$<>8__locals1.idTaste = "";
64 bool flag2 = FoodEffect.IsHumanFlesh(food);
65 bool flag3 = FoodEffect.IsUndeadFlesh(food);
66 if (food.source._origin != "meat" && food.source._origin != "dish")
67 {
68 flag3 = (flag2 = false);
69 }
70 if (food.id == "deadbody")
71 {
72 flag2 = true;
73 }
74 string[] components = food.source.components;
75 for (int i = 0; i < components.Length; i++)
76 {
77 if (components[i].Contains("egg"))
78 {
79 flag2 = false;
80 }
81 }
82 bool flag4 = CS$<>8__locals1.c.HasElement(1205, 1);
83 bool flag5 = food.IsDecayed || flag3;
84 if (food.IsBlessed)
85 {
86 num *= 1.5f;
87 }
88 if (food.IsCursed)
89 {
90 num *= 0.5f;
91 }
92 if (flag4)
93 {
94 if (flag2)
95 {
96 num4 *= 2f;
97 num *= 1.5f;
98 }
99 else
100 {
101 num4 *= 0.5f;
102 num /= 2f;
103 num2 /= 2;
104 }
105 }
106 else if (flag2)
107 {
108 num4 = 0f;
109 num *= 0.5f;
110 }
111 if (CS$<>8__locals1.c.HasElement(1200, 1))
112 {
113 num *= 1.25f;
114 }
115 if (!CS$<>8__locals1.c.IsPC)
116 {
117 num *= 3f;
118 }
119 if (flag5 && !CS$<>8__locals1.c.HasElement(480, 1))
120 {
121 if (CS$<>8__locals1.c.IsPC)
122 {
123 if (flag3)
124 {
125 CS$<>8__locals1.c.Say("food_undead", null, null);
126 }
127 CS$<>8__locals1.c.Say("food_rot", null, null);
128 }
129 num4 = 0f;
130 num2 /= 2;
131 }
132 else
133 {
134 string text = food.source._origin;
135 if (!(text == "meat"))
136 {
137 if (!(text == "fish"))
138 {
139 if (text == "dough")
140 {
141 if (CS$<>8__locals1.c.IsPC)
142 {
143 CS$<>8__locals1.c.Say("food_raw_powder", null, null);
144 }
145 num *= 0.9f;
146 num4 = 0.5f;
147 }
148 }
149 else if (CS$<>8__locals1.c.IsHuman)
150 {
151 if (CS$<>8__locals1.c.IsPC)
152 {
153 CS$<>8__locals1.c.Say("food_raw_fish", null, null);
154 }
155 num *= 0.9f;
156 num4 = 0.5f;
157 }
158 }
159 else
160 {
161 if (CS$<>8__locals1.c.IsPC)
162 {
163 CS$<>8__locals1.c.Say("food_raw_meat", null, null);
164 }
165 num *= 0.7f;
166 num4 = 0.5f;
167 }
168 }
169 float num5 = (float)Mathf.Min(CS$<>8__locals1.c.hunger.value, num2);
170 if (CS$<>8__locals1.c.hunger.GetPhase() >= 3)
171 {
172 num5 *= 1.1f;
173 }
174 if (flag5 && !CS$<>8__locals1.c.HasElement(480, 1))
175 {
176 CS$<>8__locals1.c.ModExp(70, -300);
177 CS$<>8__locals1.c.ModExp(71, -300);
178 CS$<>8__locals1.c.ModExp(72, -200);
179 CS$<>8__locals1.c.ModExp(73, -200);
180 CS$<>8__locals1.c.ModExp(74, -200);
181 CS$<>8__locals1.c.ModExp(75, 500);
182 CS$<>8__locals1.c.ModExp(76, -200);
183 CS$<>8__locals1.c.ModExp(77, -300);
184 }
185 else
186 {
187 num = num * num5 / 10f;
188 if (CS$<>8__locals1.c.HasCondition<ConAnorexia>())
189 {
190 num = 0.01f;
191 }
192 List<Element> list = food.ListValidTraits(true, false);
193 foreach (Element element in food.elements.dict.Values)
194 {
195 if (!element.source.foodEffect.IsEmpty() && list.Contains(element))
196 {
197 string[] foodEffect = element.source.foodEffect;
198 int num6 = element.id;
199 float num7 = num * (float)element.Value;
200 if (element.source.category == "food" && CS$<>8__locals1.c.IsPC)
201 {
202 bool flag6 = num7 >= 0f;
203 string text2 = element.source.GetText(flag6 ? "textInc" : "textDec", true);
204 if (text2 != null)
205 {
206 Msg.SetColor(flag6 ? "positive" : "negative");
207 CS$<>8__locals1.c.Say(text2, null, null);
208 }
209 }
210 string text = foodEffect[0];
211 uint num8 = <PrivateImplementationDetails>.ComputeStringHash(text);
212 if (num8 <= 1923516200U)
213 {
214 if (num8 <= 893270296U)
215 {
216 if (num8 != 207713729U)
217 {
218 if (num8 == 893270296U)
219 {
220 if (text == "loseWeight")
221 {
222 CS$<>8__locals1.c.ModWeight(-EClass.rndHalf(element.Value), true);
223 }
224 }
225 }
226 else if (text == "little")
227 {
228 int @int = CS$<>8__locals1.c.GetInt(112, null);
229 if (@int < 30)
230 {
231 CS$<>8__locals1.c.Say("little_eat", CS$<>8__locals1.c, null, null);
232 CS$<>8__locals1.c.PlaySound("ding_potential", 1f, true);
233 int v = Mathf.Max(5 - @int / 2, 1);
234 Debug.Log("sister eaten:" + @int.ToString() + "/" + v.ToString());
235 foreach (Element element2 in CS$<>8__locals1.c.elements.dict.Values)
236 {
237 if (element2.IsMainAttribute)
238 {
239 CS$<>8__locals1.c.elements.ModPotential(element2.id, v);
240 }
241 }
242 if (CS$<>8__locals1.c.race.id == "mutant" && CS$<>8__locals1.c.elements.Base(1230) < 10)
243 {
244 CS$<>8__locals1.c.Say("little_adam", CS$<>8__locals1.c, null, null);
245 CS$<>8__locals1.c.SetFeat(1230, CS$<>8__locals1.c.elements.Base(1230) + 1, false);
246 }
247 CS$<>8__locals1.c.SetInt(112, @int + 1);
248 }
249 }
250 }
251 else if (num8 != 1429431836U)
252 {
253 if (num8 == 1923516200U)
254 {
255 if (text == "exp")
256 {
257 num6 = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : element.id);
258 int a = (int)(num7 * (float)((foodEffect.Length > 2) ? foodEffect[2].ToInt() : 4)) * 2 / 3;
259 CS$<>8__locals1.c.ModExp(num6, a);
260 }
261 }
262 }
263 else if (text == "pot")
264 {
265 num6 = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : element.id);
266 int vTempPotential = CS$<>8__locals1.c.elements.GetElement(num6).vTempPotential;
267 int num9 = EClass.rndHalf((int)(num7 / 5f) + 1);
268 num9 = num9 * 100 / Mathf.Max(100, vTempPotential * 2 / 3);
269 CS$<>8__locals1.c.elements.ModTempPotential(num6, num9, 8);
270 }
271 }
272 else if (num8 <= 2676017222U)
273 {
274 if (num8 != 2399918791U)
275 {
276 if (num8 == 2676017222U)
277 {
278 if (text == "gainWeight")
279 {
280 CS$<>8__locals1.c.ModWeight(EClass.rndHalf(element.Value), true);
281 }
282 }
283 }
284 else if (text == "karma")
285 {
286 if (CS$<>8__locals1.c.IsPCParty)
287 {
288 EClass.player.ModKarma(-5);
289 }
290 }
291 }
292 else if (num8 != 3470992305U)
293 {
294 if (num8 == 3576140497U)
295 {
296 if (text == "love")
297 {
298 ActEffect.LoveMiracle(CS$<>8__locals1.c, EClass.pc, element.Value * 10);
299 }
300 }
301 }
302 else if (text == "poison")
303 {
304 ActEffect.Poison(CS$<>8__locals1.c, EClass.pc, element.Value * 10);
305 if (CS$<>8__locals1.c.isDead)
306 {
307 return;
308 }
309 }
310 }
311 }
312 }
313 FoodEffect.ProcTrait(CS$<>8__locals1.c, food);
314 num3 += (float)food.Evalue(70);
315 num3 += (float)(food.Evalue(72) / 2);
316 num3 += (float)(food.Evalue(73) / 2);
317 num3 += (float)(food.Evalue(75) / 2);
318 num3 += (float)(food.Evalue(76) * 3 / 2);
319 num3 += (float)food.Evalue(440);
320 num3 += (float)(food.Evalue(445) / 2);
321 num3 -= (float)food.Evalue(71);
322 num3 -= (float)(num2 / 2);
323 num3 *= num4;
324 if (CS$<>8__locals1.idTaste.IsEmpty())
325 {
326 if (num3 > 100f)
327 {
328 CS$<>8__locals1.idTaste = "food_great";
329 }
330 else if (num3 > 70f)
331 {
332 CS$<>8__locals1.idTaste = "food_good";
333 }
334 else if (num3 > 50f)
335 {
336 CS$<>8__locals1.idTaste = "food_soso";
337 }
338 else if (num3 > 30f)
339 {
340 CS$<>8__locals1.idTaste = "food_average";
341 }
342 else
343 {
344 CS$<>8__locals1.idTaste = "food_bad";
345 }
346 if (CS$<>8__locals1.c.IsPC)
347 {
348 CS$<>8__locals1.c.Say(CS$<>8__locals1.idTaste, null, null);
349 if (flag2)
350 {
351 CS$<>8__locals1.c.Say(flag4 ? "food_human_pos" : "food_human_neg", null, null);
352 }
353 else if (flag4)
354 {
355 CS$<>8__locals1.c.Say("food_human_whine", null, null);
356 }
357 }
358 }
359 if (LangGame.Has(CS$<>8__locals1.idTaste + "2"))
360 {
361 CS$<>8__locals1.c.Say(CS$<>8__locals1.idTaste + "2", CS$<>8__locals1.c, food, null, null);
362 }
363 if (!CS$<>8__locals1.c.IsPCParty)
364 {
365 num2 *= 2;
366 }
367 num2 = num2 * (100 + CS$<>8__locals1.c.Evalue(1235) * 10) / (100 + CS$<>8__locals1.c.Evalue(1234) * 10);
368 CS$<>8__locals1.c.hunger.Mod(-num2);
369 if (flag2)
370 {
371 if (!flag4)
372 {
373 if (CS$<>8__locals1.c.IsHuman)
374 {
375 CS$<>8__locals1.c.AddCondition<ConInsane>(200, false);
376 CS$<>8__locals1.c.SAN.Mod(15);
377 }
378 if (EClass.rnd(CS$<>8__locals1.c.IsHuman ? 5 : 20) == 0)
379 {
380 CS$<>8__locals1.c.SetFeat(1205, 1, true);
381 flag4 = true;
382 }
383 }
384 if (flag4)
385 {
386 CS$<>8__locals1.c.SetInt(31, EClass.world.date.GetRaw(0) + 10080);
387 }
388 }
389 else if (flag4 && CS$<>8__locals1.c.GetInt(31, null) < EClass.world.date.GetRaw(0))
390 {
391 CS$<>8__locals1.c.SetFeat(1205, 0, true);
392 }
393 if (flag5 && !CS$<>8__locals1.c.HasElement(480, 1))
394 {
395 CS$<>8__locals1.c.AddCondition<ConParalyze>(100, false);
396 CS$<>8__locals1.c.AddCondition<ConConfuse>(200, false);
397 }
398 if (CS$<>8__locals1.c.HasCondition<ConAnorexia>())
399 {
400 CS$<>8__locals1.c.Vomit();
401 }
402 if (num2 > 20 && CS$<>8__locals1.c.HasElement(1413, 1))
403 {
404 Thing thing = ThingGen.Create("seed", -1, -1);
405 if (EClass.rnd(EClass.debug.enable ? 1 : 10) == 0)
406 {
407 TraitSeed.ApplySeed(thing, 90);
408 }
409 thing.SetNum(2 + EClass.rnd(3));
410 CS$<>8__locals1.c.Talk("vomit", null, null, false);
411 CS$<>8__locals1.c.Say("fairy_vomit", CS$<>8__locals1.c, thing, null, null);
412 CS$<>8__locals1.c.PickOrDrop(CS$<>8__locals1.c.pos, thing, true);
413 }
414 food.trait.OnEat(CS$<>8__locals1.c);
415 }
416
417 // Token: 0x06000E59 RID: 3673 RVA: 0x0006CD68 File Offset: 0x0006AF68
418 public static void ProcTrait(Chara c, Card t)
419 {
420 FoodEffect.<>c__DisplayClass5_0 CS$<>8__locals1;
421 CS$<>8__locals1.c = c;
422 foreach (Element element in t.elements.dict.Values)
423 {
424 if (element.IsTrait)
425 {
426 if (element.Value >= 0)
427 {
428 switch (element.id)
429 {
430 case 753:
431 CS$<>8__locals1.c.CureCondition<ConPoison>(element.Value * 2);
432 break;
433 case 754:
434 CS$<>8__locals1.c.AddCondition<ConPeace>(element.Value * 5, false);
435 break;
436 case 755:
437 CS$<>8__locals1.c.CureCondition<ConBleed>(element.Value);
438 break;
439 }
440 }
441 else
442 {
443 int id = element.id;
444 if (id != 753)
445 {
446 if (id == 754)
447 {
448 FoodEffect.<ProcTrait>g__SayTaste|5_0("food_mind", ref CS$<>8__locals1);
449 CS$<>8__locals1.c.AddCondition<ConConfuse>(-element.Value * 10, false);
450 CS$<>8__locals1.c.AddCondition<ConInsane>(-element.Value * 10, false);
451 CS$<>8__locals1.c.AddCondition<ConHallucination>(-element.Value * 20, false);
452 }
453 }
454 else
455 {
456 FoodEffect.<ProcTrait>g__SayTaste|5_0("food_poison", ref CS$<>8__locals1);
457 CS$<>8__locals1.c.AddCondition<ConPoison>(-element.Value * 10, false);
458 }
459 }
460 }
461 }
462 }
463
464 // Token: 0x06000E5B RID: 3675 RVA: 0x0006CEF0 File Offset: 0x0006B0F0
465 [CompilerGenerated]
466 internal static void <Proc>g__SayTaste|4_0(string _id, ref FoodEffect.<>c__DisplayClass4_0 A_1)
467 {
468 A_1.idTaste = _id;
469 if (A_1.c.IsPC)
470 {
471 A_1.c.Say(A_1.idTaste, null, null);
472 }
473 }
474
475 // Token: 0x06000E5C RID: 3676 RVA: 0x0006CF19 File Offset: 0x0006B119
476 [CompilerGenerated]
477 internal static void <ProcTrait>g__SayTaste|5_0(string _id, ref FoodEffect.<>c__DisplayClass5_0 A_1)
478 {
479 if (A_1.c.IsPC)
480 {
481 A_1.c.Say(_id, null, null);
482 }
483 }
484}
Definition Card.cs:13
Definition Chara.cs:12
Definition Msg.cs:7
Definition Thing.cs:10