Elin Decompiled Documentation EA 23.102 Nightly
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_soil":
16 {
17 if (!(t.trait is TraitTent))
18 {
19 return false;
20 }
21 Zone zone = (t.trait as TraitTent).zone;
22 if (zone == null)
23 {
24 return false;
25 }
26 return zone.Evalue(2200) < 10;
27 }
28 case "tent_elec":
29 if (t.trait is TraitTent)
30 {
31 return (t.trait as TraitTent).zone != null;
32 }
33 return false;
34 case "bed":
35 return t.trait is TraitBed;
36 case "storage":
37 case "fridge":
38 return t.trait is TraitMagicChest;
39 case "extend_v":
40 case "extend_h":
42 {
43 return false;
44 }
45 if (t.IsContainer)
46 {
47 return t.trait is TraitContainer;
48 }
49 return false;
50 default:
51 return false;
52 }
53 }
54
55 public bool Upgrade(Thing t)
56 {
57 switch (ID)
58 {
59 case "tent_elec":
60 (t.trait as TraitTent).zone.elements.ModBase(2201, 2);
61 break;
62 case "tent_soil":
63 (t.trait as TraitTent).zone.elements.ModBase(2200, 5);
64 break;
65 case "bed":
68 {
69 t.c_containerSize += 1000;
70 }
71 break;
72 case "storage":
73 t.c_containerUpgrade.cap += 20;
74 break;
75 case "fridge":
76 if (t.c_containerUpgrade.cool != 0)
77 {
78 return false;
79 }
80 t.c_containerUpgrade.cool = 1;
81 t.elements.SetBase(405, 50);
82 break;
83 case "extend_v":
84 case "extend_h":
85 {
86 bool flag = ID == "extend_v";
87 TraitContainer traitContainer = t.trait as TraitContainer;
88 if (t.things.GridSize == 0)
89 {
90 return false;
91 }
92 if (flag)
93 {
94 if (t.things.height != traitContainer.Height)
95 {
96 return false;
97 }
99 }
100 else
101 {
102 if (t.things.width != traitContainer.Width)
103 {
104 return false;
105 }
107 }
108 break;
109 }
110 }
111 if (EClass.Branch != null)
112 {
114 }
115 return true;
116 }
117
118 public override void TrySetHeldAct(ActPlan p)
119 {
120 p.pos.Things.ForEach(delegate(Thing t)
121 {
122 if (IsValidTarget(t))
123 {
124 p.TrySetAct("actWrench".lang(t.Name), delegate
125 {
126 if (Upgrade(t))
127 {
128 Msg.Say("upgrade", t, owner.GetName(NameStyle.Full, 1));
129 SE.Play("build_area");
130 t.PlayEffect("buff");
131 owner.ModNum(-1);
132 EClass._zone.RefreshElectricity();
133 }
134 else
135 {
136 Msg.Say("noMoreUpgrade", t, owner.GetName(NameStyle.Full, 1));
137 }
138 return false;
139 }, t);
140 }
141 });
142 }
143}
Point pos
Definition: ActPlan.cs:149
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:344
ContainerUpgrade c_containerUpgrade
Definition: Card.cs:1769
ElementContainerCard elements
Definition: Card.cs:37
string Name
Definition: Card.cs:2013
int c_containerSize
Definition: Card.cs:1289
Trait trait
Definition: Card.cs:49
ThingContainer things
Definition: Card.cs:34
bool IsInstalled
Definition: Card.cs:2241
bool IsContainer
Definition: Card.cs:1965
bool enable
Definition: CoreDebug.cs:285
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:314
void SetSize(int w, int h)
Definition: Thing.cs:8
bool Upgrade(Thing t)
Definition: TraitWrench.cs:55
bool IsValidTarget(Thing t)
Definition: TraitWrench.cs:7
string ID
Definition: TraitWrench.cs:3
override void TrySetHeldAct(ActPlan p)
Definition: TraitWrench.cs:118
override bool IsTool
Definition: TraitWrench.cs:5
Definition: Trait.cs:7
string GetParam(int i, string def=null)
Definition: Trait.cs:515
virtual bool IsSpecialContainer
Definition: Trait.cs:237
Definition: Zone.cs:12
int Evalue(int ele)
Definition: Zone.cs:518