Elin Decompiled Documentation EA 23.130 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 {
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.id == "508") && !(c.id == "778") && !(c.id == "milk"))
53 {
54 return true;
55 }
56 if (c.category.IsChildOf("meal"))
57 {
58 return true;
59 }
60 break;
61 default:
62 if (!firstDecay)
63 {
64 return true;
65 }
66 break;
67 case Type.Fertilizer:
68 break;
69 }
70 string productID = GetProductID(c);
71 if (productID == null)
72 {
73 return true;
74 }
75 Thing thing = c.Duplicate(c.Num);
76 c.Destroy();
77 switch (type)
78 {
79 case Type.Food:
80 c = CraftUtil.MixIngredients(productID, new List<Thing> { c.Thing }, CraftUtil.MixType.Food, 0, EClass.pc).SetNum(thing.Num);
81 break;
82 case Type.Fertilizer:
83 {
84 int num = 20 + thing.SelfWeight;
85 if (num > 100)
86 {
87 num = 100 + (int)Mathf.Sqrt((num - 100) * 10);
88 }
89 int num2 = 0;
90 for (int i = 0; i < thing.Num; i++)
91 {
92 num2 += num / 100 + ((num % 100 > EClass.rnd(100)) ? 1 : 0);
93 }
94 if (num2 <= 0)
95 {
96 return false;
97 }
98 c = ((!thing.isCopy) ? ThingGen.Create(productID).SetNum(num2) : ThingGen.Create("ash3").SetNum(Mathf.Min(num2, 10)));
99 break;
100 }
101 default:
102 c = ThingGen.Create(productID).SetNum(thing.Num);
103 break;
104 }
105 if (type != Type.Fertilizer)
106 {
107 c.MakeFoodRef(thing);
108 }
109 if (type == Type.Drink)
110 {
111 c.c_priceAdd = thing.GetValue() * 125 / 100;
112 }
113 OnProduce(c);
115 owner.GetRootCard().Say(idMsg, thing, c);
116 return false;
117 }
118
119 public virtual string GetProductID(Card c)
120 {
121 switch (c.id)
122 {
123 case "crim":
124 case "drug_crim":
125 return "crimAle";
126 case "rice_plant":
127 case "rice":
128 case "692":
129 case "719":
130 case "720":
131 return "1134";
132 default:
133 if (c.category.IsChildOf("mushroom") || c.category.IsChildOf("nuts"))
134 {
135 return "54";
136 }
137 return "48";
138 }
139 }
140
141 public virtual void OnProduce(Card c)
142 {
143 }
144}
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:2950
Thing SetNum(int a)
Definition: Card.cs:3286
bool IsFood
Definition: Card.cs:2075
void MakeFoodRef(Card c1, Card c2=null)
Definition: Card.cs:5189
Trait trait
Definition: Card.cs:49
void Destroy()
Definition: Card.cs:4680
virtual Thing Thing
Definition: Card.cs:1958
Card GetRootCard()
Definition: Card.cs:3217
Thing Duplicate(int num)
Definition: Card.cs:3235
int Num
Definition: Card.cs:154
SourceCategory.Row category
Definition: Card.cs:1949
int GetValue(PriceType priceType=PriceType.Default, bool sell=false)
Definition: Card.cs:6598
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6232
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:144
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:58
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