Elin Decompiled Documentation EA 23.187 Stable
Loading...
Searching...
No Matches
TraitWrench.cs
Go to the documentation of this file.
1public class TraitWrench : Trait
2{
3 public string ID => GetParam(1);
4
5 public override bool IsTool => true;
6
7 public bool IsValidTarget(Thing t)
8 {
9 if (!t.IsInstalled)
10 {
11 return false;
12 }
13 switch (ID)
14 {
15 case "tent_seabed":
16 if (t.trait is TraitTent && (t.trait as TraitTent).zone != null)
17 {
18 return !(t.trait as TraitTent).zone.IsUnderwater;
19 }
20 return false;
21 case "tent_soil":
22 {
23 if (!(t.trait is TraitTent))
24 {
25 return false;
26 }
27 Zone zone = (t.trait as TraitTent).zone;
28 if (zone == null)
29 {
30 return false;
31 }
32 return zone.Evalue(2200) < 10;
33 }
34 case "tent_elec":
35 if (t.trait is TraitTent)
36 {
37 return (t.trait as TraitTent).zone != null;
38 }
39 return false;
40 case "bed":
41 return t.trait is TraitBed;
42 case "storage":
43 case "fridge":
44 return t.trait is TraitMagicChest;
45 case "extend_v":
46 case "extend_h":
48 {
49 return false;
50 }
51 if (t.IsContainer)
52 {
53 return t.trait is TraitContainer;
54 }
55 return false;
56 default:
57 return false;
58 }
59 }
60
61 public bool Upgrade(Thing t)
62 {
63 switch (ID)
64 {
65 case "tent_seabed":
66 (t.trait as TraitTent).zone.elements.ModBase(3606, 1);
67 break;
68 case "tent_elec":
69 (t.trait as TraitTent).zone.elements.ModBase(2201, 2);
70 break;
71 case "tent_soil":
72 (t.trait as TraitTent).zone.elements.ModBase(2200, 5);
73 break;
74 case "bed":
77 {
78 t.c_containerSize += 1000;
79 }
80 break;
81 case "storage":
82 t.c_containerUpgrade.cap += 20;
83 break;
84 case "fridge":
85 if (t.c_containerUpgrade.cool != 0)
86 {
87 return false;
88 }
89 t.c_containerUpgrade.cool = 1;
90 t.elements.SetBase(405, 50);
91 break;
92 case "extend_v":
93 case "extend_h":
94 {
95 bool flag = ID == "extend_v";
96 TraitContainer traitContainer = t.trait as TraitContainer;
97 if (t.things.GridSize == 0)
98 {
99 return false;
100 }
101 if (flag)
102 {
103 if (t.things.height != traitContainer.Height)
104 {
105 return false;
106 }
108 }
109 else
110 {
111 if (t.things.width != traitContainer.Width)
112 {
113 return false;
114 }
116 }
117 break;
118 }
119 }
120 if (EClass.Branch != null)
121 {
123 }
124 return true;
125 }
126
127 public override void TrySetHeldAct(ActPlan p)
128 {
129 p.pos.Things.ForeachReverse(delegate(Thing t)
130 {
131 if (IsValidTarget(t))
132 {
133 p.TrySetAct("actWrench".lang(t.Name), delegate
134 {
135 if (Upgrade(t))
136 {
137 Msg.Say("upgrade", t, owner.GetName(NameStyle.Full, 1));
138 SE.Play("build_area");
139 t.PlayEffect("buff");
140 owner.ModNum(-1);
141 EClass._zone.RefreshElectricity();
142 }
143 else
144 {
145 Msg.Say("noMoreUpgrade", t, owner.GetName(NameStyle.Full, 1));
146 }
147 return false;
148 }, t);
149 }
150 });
151 }
152}
Point pos
Definition: ActPlan.cs:150
bool TrySetAct(string lang, Func< bool > onPerform, Card tc, CursorInfo cursor=null, int dist=1, bool isHostileAct=false, bool localAct=true, bool canRepeat=false)
Definition: ActPlan.cs:366
ContainerUpgrade c_containerUpgrade
Definition: Card.cs:1843
ElementContainerCard elements
Definition: Card.cs:39
string Name
Definition: Card.cs:2099
int c_containerSize
Definition: Card.cs:1339
Trait trait
Definition: Card.cs:51
ThingContainer things
Definition: Card.cs:36
bool IsInstalled
Definition: Card.cs:2343
bool IsContainer
Definition: Card.cs:2051
bool enable
Definition: CoreDebug.cs:286
Definition: EClass.cs:5
static FactionBranch Branch
Definition: EClass.cs:22
static CoreDebug debug
Definition: EClass.cs:48
Element SetBase(string alias, int v, int potential=0)
HomeResourceManager resources
List< Thing > Things
Definition: Point.cs:326
void SetSize(int w, int h)
Definition: Thing.cs:8
bool Upgrade(Thing t)
Definition: TraitWrench.cs:61
bool IsValidTarget(Thing t)
Definition: TraitWrench.cs:7
string ID
Definition: TraitWrench.cs:3
override void TrySetHeldAct(ActPlan p)
Definition: TraitWrench.cs:127
override bool IsTool
Definition: TraitWrench.cs:5
Definition: Trait.cs:7
string GetParam(int i, string def=null)
Definition: Trait.cs:556
virtual bool IsSpecialContainer
Definition: Trait.cs:244
Definition: Zone.cs:12
int Evalue(int ele)
Definition: Zone.cs:524