Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitBrewery.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
5{
6 public enum Type
7 {
8 Food,
9 Drink,
11 }
12
13 public override int DecaySpeedChild => 500;
14
15 public virtual string idMsg => "brew";
16
17 public virtual Type type => Type.Drink;
18
19 public virtual bool IsFood => false;
20
21 public override bool CanChildDecay(Card c)
22 {
23 switch (c.id)
24 {
25 case "48":
26 case "cheese":
27 case "jerky":
28 return false;
29 default:
30 if (!(c.trait is TraitDrinkMilk))
31 {
32 return c.material.id == 94;
33 }
34 return true;
35 }
36 }
37
38 public override bool OnChildDecay(Card c, bool firstDecay)
39 {
40 switch (type)
41 {
42 case Type.Food:
43 case Type.Drink:
44 if (!firstDecay)
45 {
46 return true;
47 }
48 if (!c.IsFood && !(c.trait is TraitDrinkMilk))
49 {
50 return true;
51 }
52 if (c.category.IsChildOf("meal"))
53 {
54 return true;
55 }
56 break;
57 default:
58 if (!firstDecay)
59 {
60 return true;
61 }
62 break;
63 case Type.Fertilizer:
64 break;
65 }
66 string productID = GetProductID(c);
67 if (productID == null)
68 {
69 return true;
70 }
71 Thing thing = c.Duplicate(c.Num);
72 c.Destroy();
73 switch (type)
74 {
75 case Type.Food:
76 c = CraftUtil.MixIngredients(productID, new List<Thing> { c.Thing }, CraftUtil.MixType.Food, 0, EClass.pc).SetNum(thing.Num);
77 break;
78 case Type.Fertilizer:
79 {
80 int num = 20 + thing.SelfWeight;
81 if (num > 100)
82 {
83 num = 100 + (int)Mathf.Sqrt((num - 100) * 10);
84 }
85 int num2 = 0;
86 for (int i = 0; i < thing.Num; i++)
87 {
88 num2 += num / 100 + ((num % 100 > EClass.rnd(100)) ? 1 : 0);
89 }
90 if (num2 <= 0)
91 {
92 return false;
93 }
94 c = ((!thing.isCopy) ? ThingGen.Create(productID).SetNum(num2) : ThingGen.Create("ash3").SetNum(Mathf.Min(num2, 10)));
95 break;
96 }
97 default:
98 c = ThingGen.Create(productID).SetNum(thing.Num);
99 break;
100 }
101 if (type != Type.Fertilizer)
102 {
103 c.MakeFoodRef(thing);
104 }
105 if (type == Type.Drink)
106 {
107 c.c_priceAdd = thing.GetValue() * 125 / 100;
108 }
109 OnProduce(c);
111 owner.GetRootCard().Say(idMsg, thing, c);
112 return false;
113 }
114
115 public virtual string GetProductID(Card c)
116 {
117 switch (c.id)
118 {
119 case "crim":
120 case "drug_crim":
121 return "crimAle";
122 case "rice_plant":
123 case "rice":
124 case "692":
125 case "719":
126 case "720":
127 return "1134";
128 default:
129 if (c.category.IsChildOf("mushroom") || c.category.IsChildOf("nuts"))
130 {
131 return "54";
132 }
133 return "48";
134 }
135 }
136
137 public virtual void OnProduce(Card c)
138 {
139 }
140}
Definition: Card.cs:11
string id
Definition: Card.cs:31
bool isCopy
Definition: Card.cs:850
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:2901
Thing SetNum(int a)
Definition: Card.cs:3242
int GetValue(bool sell=false)
Definition: Card.cs:6387
bool IsFood
Definition: Card.cs:2051
void MakeFoodRef(Card c1, Card c2=null)
Definition: Card.cs:5009
Trait trait
Definition: Card.cs:49
void Destroy()
Definition: Card.cs:4538
virtual Thing Thing
Definition: Card.cs:1934
Card GetRootCard()
Definition: Card.cs:3173
Thing Duplicate(int num)
Definition: Card.cs:3191
int Num
Definition: Card.cs:154
SourceCategory.Row category
Definition: Card.cs:1925
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:132
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Chara pc
Definition: EClass.cs:14
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
override int SelfWeight
Definition: Thing.cs:62
override int DecaySpeedChild
Definition: TraitBrewery.cs:13
virtual string GetProductID(Card c)
override bool OnChildDecay(Card c, bool firstDecay)
Definition: TraitBrewery.cs:38
virtual void OnProduce(Card c)
override bool CanChildDecay(Card c)
Definition: TraitBrewery.cs:21
virtual Type type
Definition: TraitBrewery.cs:17
virtual string idMsg
Definition: TraitBrewery.cs:15
virtual bool IsFood
Definition: TraitBrewery.cs:19
Card owner
Definition: Trait.cs:26