Elin Modding Docs Doc
Loading...
Searching...
No Matches
TraitDoor.cs
1using System;
2
3// Token: 0x020003EF RID: 1007
4public class TraitDoor : Trait
5{
6 // Token: 0x17000917 RID: 2327
7 // (get) Token: 0x06001D44 RID: 7492 RVA: 0x000AB44B File Offset: 0x000A964B
8 public override bool CanBeOnlyBuiltInHome
9 {
10 get
11 {
12 return true;
13 }
14 }
15
16 // Token: 0x17000918 RID: 2328
17 // (get) Token: 0x06001D45 RID: 7493 RVA: 0x000AB44E File Offset: 0x000A964E
18 public override bool CanBuildInTown
19 {
20 get
21 {
22 return false;
23 }
24 }
25
26 // Token: 0x17000919 RID: 2329
27 // (get) Token: 0x06001D46 RID: 7494 RVA: 0x000AB451 File Offset: 0x000A9651
28 public override bool CanBeDisassembled
29 {
30 get
31 {
32 return !this.owner.IsInstalled;
33 }
34 }
35
36 // Token: 0x1700091A RID: 2330
37 // (get) Token: 0x06001D47 RID: 7495 RVA: 0x000AB461 File Offset: 0x000A9661
38 public override Trait.TileMode tileMode
39 {
40 get
41 {
42 return Trait.TileMode.Door;
43 }
44 }
45
46 // Token: 0x1700091B RID: 2331
47 // (get) Token: 0x06001D48 RID: 7496 RVA: 0x000AB464 File Offset: 0x000A9664
48 public override bool HaveUpdate
49 {
50 get
51 {
52 return true;
53 }
54 }
55
56 // Token: 0x1700091C RID: 2332
57 // (get) Token: 0x06001D49 RID: 7497 RVA: 0x000AB467 File Offset: 0x000A9667
58 public override bool IsOpenSight
59 {
60 get
61 {
62 return this.IsOpen();
63 }
64 }
65
66 // Token: 0x1700091D RID: 2333
67 // (get) Token: 0x06001D4A RID: 7498 RVA: 0x000AB46F File Offset: 0x000A966F
68 public override bool IsDoor
69 {
70 get
71 {
72 return true;
73 }
74 }
75
76 // Token: 0x1700091E RID: 2334
77 // (get) Token: 0x06001D4B RID: 7499 RVA: 0x000AB472 File Offset: 0x000A9672
78 public override bool ShouldRefreshTile
79 {
80 get
81 {
82 return true;
83 }
84 }
85
86 // Token: 0x1700091F RID: 2335
87 // (get) Token: 0x06001D4C RID: 7500 RVA: 0x000AB475 File Offset: 0x000A9675
88 public virtual string idSound
89 {
90 get
91 {
92 return "door1";
93 }
94 }
95
96 // Token: 0x06001D4D RID: 7501 RVA: 0x000AB47C File Offset: 0x000A967C
97 public override void Update()
98 {
99 this.TryAutoClose();
100 }
101
102 // Token: 0x06001D4E RID: 7502 RVA: 0x000AB484 File Offset: 0x000A9684
103 public void ForceClose()
104 {
105 if (this.IsOpen())
106 {
107 this.ToggleDoor(true, true);
108 }
109 }
110
111 // Token: 0x06001D4F RID: 7503 RVA: 0x000AB498 File Offset: 0x000A9698
112 public void TryOpen(Chara c)
113 {
114 if (this.IsOpen())
115 {
116 return;
117 }
118 this.ToggleDoor(true, true);
119 c.Say("openDoor", c, this.owner, null, null);
120 if (this.owner.Cell.Front.FirstThing != null)
121 {
122 foreach (Thing thing in this.owner.Cell.Front.Things)
123 {
124 thing.trait.OnOpenDoor(c);
125 }
126 }
127 if (this.owner.Cell.Right.FirstThing != null)
128 {
129 foreach (Thing thing2 in this.owner.Cell.Right.Things)
130 {
131 thing2.trait.OnOpenDoor(c);
132 }
133 }
134 }
135
136 // Token: 0x06001D50 RID: 7504 RVA: 0x000AB5A4 File Offset: 0x000A97A4
137 public void TryAutoClose()
138 {
139 this.count++;
140 if (this.count > 5 && this.CanClose() && this.IsOpen())
141 {
142 this.ToggleDoor(false, true);
143 }
144 }
145
146 // Token: 0x06001D51 RID: 7505 RVA: 0x000AB5D8 File Offset: 0x000A97D8
147 public virtual bool CanClose()
148 {
149 int num = 0;
150 foreach (Thing thing in this.owner.pos.Things)
151 {
152 if (!thing.isRoofItem && !thing.isHidden && thing.TileType != TileType.Illumination)
153 {
154 num++;
155 if (num > 1)
156 {
157 return false;
158 }
159 }
160 }
161 return !this.owner.pos.HasChara;
162 }
163
164 // Token: 0x06001D52 RID: 7506 RVA: 0x000AB670 File Offset: 0x000A9870
165 public virtual bool IsOpen()
166 {
167 int dir = this.owner.dir;
168 Cell cell = this.owner.pos.cell;
169 return (!cell.Right.HasFullBlockOrWallOrFence && (dir == 0 || dir == 2) && cell.Front.HasFullBlockOrWallOrFence) || (!cell.Front.HasFullBlockOrWallOrFence && (dir == 1 || dir == 3) && cell.Right.HasFullBlockOrWallOrFence);
170 }
171
172 // Token: 0x06001D53 RID: 7507 RVA: 0x000AB6E4 File Offset: 0x000A98E4
173 public bool IsValid()
174 {
175 int dir = this.owner.dir;
176 Cell cell = this.owner.pos.cell;
177 if (!cell.HasBlock)
178 {
179 return false;
180 }
181 bool hasFullBlockOrWallOrFence = cell.Left.HasFullBlockOrWallOrFence;
182 bool hasFullBlockOrWallOrFence2 = cell.Right.HasFullBlockOrWallOrFence;
183 bool hasFullBlockOrWallOrFence3 = cell.Front.HasFullBlockOrWallOrFence;
184 bool hasFullBlockOrWallOrFence4 = cell.Back.HasFullBlockOrWallOrFence;
185 return (hasFullBlockOrWallOrFence ? 1 : 0) + (hasFullBlockOrWallOrFence2 ? 1 : 0) + (hasFullBlockOrWallOrFence3 ? 1 : 0) + (hasFullBlockOrWallOrFence4 ? 1 : 0) < 3 && ((hasFullBlockOrWallOrFence && hasFullBlockOrWallOrFence2) || (hasFullBlockOrWallOrFence3 && hasFullBlockOrWallOrFence4));
186 }
187
188 // Token: 0x06001D54 RID: 7508 RVA: 0x000AB780 File Offset: 0x000A9980
189 public virtual void ToggleDoor(bool sound = true, bool refresh = true)
190 {
191 if (sound)
192 {
193 this.owner.PlaySound(this.idSound, 1f, true);
194 }
195 this.RotateDoor();
196 this.count = 0;
197 if (refresh)
198 {
199 EClass._map.RefreshSingleTile(this.owner.pos.x, this.owner.pos.z);
200 EClass._map.RefreshFOV(this.owner.pos.x, this.owner.pos.z, 6, false);
201 }
202 }
203
204 // Token: 0x06001D55 RID: 7509 RVA: 0x000AB810 File Offset: 0x000A9A10
205 public void RotateDoor()
206 {
207 if (this.owner.dir == 0)
208 {
209 this.owner.dir = 1;
210 }
211 else if (this.owner.dir == 1)
212 {
213 this.owner.dir = 0;
214 }
215 else if (this.owner.dir == 2)
216 {
217 this.owner.dir = 3;
218 }
219 else
220 {
221 this.owner.dir = 2;
222 }
223 this.owner.renderer.RefreshSprite();
224 }
225
226 // Token: 0x06001D56 RID: 7510 RVA: 0x000AB88C File Offset: 0x000A9A8C
227 public override void TrySetAct(ActPlan p)
228 {
229 if (!this.owner.IsInstalled)
230 {
231 return;
232 }
233 if (this.owner.c_lockLv > 0)
234 {
235 p.TrySetAct(new AI_OpenLock
236 {
237 target = this.owner.Thing
238 }, this.owner);
239 return;
240 }
241 if (!this.IsOpen())
242 {
243 p.TrySetAct("actOpen", delegate()
244 {
245 EClass.pc.Say("openDoor", EClass.pc, this.owner, null, null);
246 this.ToggleDoor(true, true);
247 return true;
248 }, this.owner, CursorSystem.Door, 1, false, true, false);
249 return;
250 }
251 if (this.CanClose() && p.altAction)
252 {
253 p.TrySetAct("actClose", delegate()
254 {
255 EClass.pc.Say("close", EClass.pc, this.owner, null, null);
256 this.ToggleDoor(true, true);
257 return true;
258 }, this.owner, CursorSystem.Door, 1, false, true, false);
259 }
260 }
261
262 // Token: 0x040010C5 RID: 4293
263 public int count;
264}
Definition Cell.cs:10
Definition Chara.cs:12
Definition Thing.cs:10
Definition Trait.cs:9