Elin Modding Docs Doc
Loading...
Searching...
No Matches
TraitWrench.cs
1using System;
2using UnityEngine;
3
4// Token: 0x02000425 RID: 1061
5public class TraitWrench : Trait
6{
7 // Token: 0x17000963 RID: 2403
8 // (get) Token: 0x06001E24 RID: 7716 RVA: 0x000ADFF6 File Offset: 0x000AC1F6
9 public string ID
10 {
11 get
12 {
13 return base.GetParam(1, null);
14 }
15 }
16
17 // Token: 0x17000964 RID: 2404
18 // (get) Token: 0x06001E25 RID: 7717 RVA: 0x000AE000 File Offset: 0x000AC200
19 public override bool IsTool
20 {
21 get
22 {
23 return true;
24 }
25 }
26
27 // Token: 0x06001E26 RID: 7718 RVA: 0x000AE004 File Offset: 0x000AC204
28 public bool IsValidTarget(Thing t)
29 {
30 if (!t.IsInstalled)
31 {
32 return false;
33 }
34 string id = this.ID;
35 if (id == "bed")
36 {
37 return t.trait is TraitBed;
38 }
39 if (!(id == "storage") && !(id == "fridge"))
40 {
41 return (id == "extend_v" || id == "extend_h") && !(t.trait is TraitMagicChest) && !(t.trait is TraitDeliveryChest) && !t.trait.IsSpecialContainer && t.IsContainer && t.trait is TraitContainer;
42 }
43 return t.trait is TraitMagicChest;
44 }
45
46 // Token: 0x06001E27 RID: 7719 RVA: 0x000AE0C8 File Offset: 0x000AC2C8
47 public bool Upgrade(Thing t)
48 {
49 string id = this.ID;
50 if (!(id == "bed"))
51 {
52 if (!(id == "storage"))
53 {
54 if (!(id == "fridge"))
55 {
56 if (id == "extend_v" || id == "extend_h")
57 {
58 bool flag = this.ID == "extend_v";
59 TraitContainer traitContainer = t.trait as TraitContainer;
60 if (t.things.GridSize == 0)
61 {
62 return false;
63 }
64 if (flag)
65 {
66 if (t.things.height != traitContainer.Height)
67 {
68 return false;
69 }
70 t.things.SetSize(t.things.width, t.things.height + 1);
71 }
72 else
73 {
74 if (t.things.width != traitContainer.Width)
75 {
76 return false;
77 }
78 t.things.SetSize(t.things.width + 1, t.things.height);
79 }
80 }
81 }
82 else
83 {
84 if (t.c_containerUpgrade.cool != 0)
85 {
86 return false;
87 }
88 t.c_containerUpgrade.cool = 1;
89 t.elements.SetBase(405, 50, 0);
90 }
91 }
92 else
93 {
94 t.c_containerUpgrade.cap += 20;
95 }
96 }
97 else
98 {
99 int c_containerSize = t.c_containerSize;
100 t.c_containerSize = c_containerSize + 1;
101 }
102 if (EClass.Branch != null)
103 {
104 EClass.Branch.resources.SetDirty();
105 }
106 return true;
107 }
108
109 // Token: 0x06001E28 RID: 7720 RVA: 0x000AE23C File Offset: 0x000AC43C
110 public override void TrySetHeldAct(ActPlan p)
111 {
112 p.pos.Things.ForEach(delegate(Thing t)
113 {
114 if (!this.IsValidTarget(t))
115 {
116 return;
117 }
118 p.TrySetAct("actWrench".lang(t.Name, null, null, null, null), delegate()
119 {
120 if (this.Upgrade(t))
121 {
122 Msg.Say("upgrade", t, this.owner.GetName(NameStyle.Full, 1), null, null);
123 SE.Play("build_area");
124 t.PlayEffect("buff", true, 0f, default(Vector3));
125 this.owner.ModNum(-1, true);
126 EClass._zone.RefreshElectricity();
127 }
128 else
129 {
130 Msg.Say("noMoreUpgrade", t, this.owner.GetName(NameStyle.Full, 1), null, null);
131 }
132 return false;
133 }, null, 1);
134 });
135 }
136}
Definition Msg.cs:7
Definition Thing.cs:10
Definition Trait.cs:9