Elin Decompiled Documentation EA 23.319 Nightly Patch 1
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 if (c.trait is TraitFoodFishSlice || c.HasElement(707))
41 {
42 return true;
43 }
44 switch (type)
45 {
46 case Type.Food:
47 case Type.Drink:
48 if (!firstDecay)
49 {
50 return true;
51 }
52 if (!c.IsFood && !(c.trait is TraitDrinkMilk))
53 {
54 return true;
55 }
56 if (c.category.IsChildOf("meal"))
57 {
58 return true;
59 }
60 if (c.category.IsChildOf("filling"))
61 {
62 return true;
63 }
64 break;
65 default:
66 if (!firstDecay)
67 {
68 return true;
69 }
70 break;
71 case Type.Fertilizer:
72 break;
73 }
74 string productID = GetProductID(c);
75 if (productID == null)
76 {
77 return true;
78 }
79 Thing thing = c.Duplicate(c.Num);
80 c.Destroy();
81 switch (type)
82 {
83 case Type.Food:
84 c = CraftUtil.MixIngredients(productID, new List<Thing> { c.Thing }, CraftUtil.MixType.Food, 0, EClass.pc).SetNum(thing.Num);
85 break;
86 case Type.Fertilizer:
87 {
88 int num = 20 + thing.SelfWeight;
89 if (num > 100)
90 {
91 num = 100 + (int)Mathf.Sqrt((num - 100) * 10);
92 }
93 int num2 = 0;
94 for (int i = 0; i < thing.Num; i++)
95 {
96 num2 += num / 100 + ((num % 100 > EClass.rnd(100)) ? 1 : 0);
97 }
98 if (num2 <= 0)
99 {
100 return false;
101 }
102 c = ((!thing.isCopy) ? ThingGen.Create(productID).SetNum(num2) : ThingGen.Create("ash3").SetNum(Mathf.Min(num2, 10)));
103 break;
104 }
105 default:
106 c = ThingGen.Create(productID).SetNum(thing.Num);
107 break;
108 }
109 if (type != Type.Fertilizer)
110 {
111 c.MakeFoodRef(thing);
112 }
113 if (type == Type.Drink)
114 {
115 c.c_priceAdd = thing.GetValue() * 125 / 100;
116 }
117 OnProduce(c);
119 owner.GetRootCard().Say(idMsg, thing, c);
120 return false;
121 }
122
123 public virtual string GetProductID(Card c)
124 {
125 switch (c.id)
126 {
127 case "crim":
128 case "drug_crim":
129 return "crimAle";
130 case "rice_plant":
131 case "rice":
132 case "692":
133 case "719":
134 case "720":
135 return "1134";
136 default:
137 if (c.category.IsChildOf("mushroom") || c.category.IsChildOf("nuts"))
138 {
139 return "54";
140 }
141 return "48";
142 }
143 }
144
145 public virtual void OnProduce(Card c)
146 {
147 }
148}
Definition: Card.cs:11
string id
Definition: Card.cs:36
bool isCopy
Definition: Card.cs:881
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3257
Thing SetNum(int a)
Definition: Card.cs:3653
bool IsFood
Definition: Card.cs:2229
void MakeFoodRef(Card c1, Card c2=null)
Definition: Card.cs:5875
Trait trait
Definition: Card.cs:54
void Destroy()
Definition: Card.cs:5268
virtual Thing Thing
Definition: Card.cs:2110
Card GetRootCard()
Definition: Card.cs:3584
Thing Duplicate(int num)
Definition: Card.cs:3602
int Num
Definition: Card.cs:161
SourceCategory.Row category
Definition: Card.cs:2101
int GetValue(PriceType priceType=PriceType.Default, bool sell=false)
Definition: Card.cs:7615
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6304
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7240
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:364
Definition: EClass.cs:6
static int rnd(long a)
Definition: EClass.cs:59
static Chara pc
Definition: EClass.cs:15
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:64
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:28