Elin Modding Docs Doc
Loading...
Searching...
No Matches
TaskBuild.cs
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4using UnityEngine;
5
6// Token: 0x0200025F RID: 607
7public class TaskBuild : TaskBaseBuild
8{
9 // Token: 0x17000493 RID: 1171
10 // (get) Token: 0x0600110E RID: 4366 RVA: 0x000765D3 File Offset: 0x000747D3
11 public override int destDist
12 {
13 get
14 {
15 return 1;
16 }
17 }
18
19 // Token: 0x0600110F RID: 4367 RVA: 0x000765D6 File Offset: 0x000747D6
20 public override bool CanManualCancel()
21 {
22 return true;
23 }
24
25 // Token: 0x17000494 RID: 1172
26 // (get) Token: 0x06001110 RID: 4368 RVA: 0x000765D9 File Offset: 0x000747D9
27 public override bool CanPressRepeat
28 {
29 get
30 {
31 return this.useHeld && EClass.pc.held != null && EClass.pc.held.trait.CanExtendBuild;
32 }
33 }
34
35 // Token: 0x17000495 RID: 1173
36 // (get) Token: 0x06001111 RID: 4369 RVA: 0x00076607 File Offset: 0x00074807
37 public override bool HasProgress
38 {
39 get
40 {
41 return false;
42 }
43 }
44
45 // Token: 0x17000496 RID: 1174
46 // (get) Token: 0x06001112 RID: 4370 RVA: 0x0007660A File Offset: 0x0007480A
47 public override bool destIgnoreConnection
48 {
49 get
50 {
51 return this.recipe.IsFloorOrBridge;
52 }
53 }
54
55 // Token: 0x17000497 RID: 1175
56 // (get) Token: 0x06001113 RID: 4371 RVA: 0x00076617 File Offset: 0x00074817
57 public bool useHeld
58 {
59 get
60 {
61 return this.held != null;
62 }
63 }
64
65 // Token: 0x17000498 RID: 1176
66 // (get) Token: 0x06001114 RID: 4372 RVA: 0x00076622 File Offset: 0x00074822
67 public override int W
68 {
69 get
70 {
71 return this.recipe.W;
72 }
73 }
74
75 // Token: 0x17000499 RID: 1177
76 // (get) Token: 0x06001115 RID: 4373 RVA: 0x0007662F File Offset: 0x0007482F
77 public override int H
78 {
79 get
80 {
81 return this.recipe.H;
82 }
83 }
84
85 // Token: 0x1700049A RID: 1178
86 // (get) Token: 0x06001116 RID: 4374 RVA: 0x0007663C File Offset: 0x0007483C
87 public override bool isBlock
88 {
89 get
90 {
91 return this.recipe.IsBlock;
92 }
93 }
94
95 // Token: 0x06001117 RID: 4375 RVA: 0x0007664C File Offset: 0x0007484C
96 public override string GetText(string str = "")
97 {
98 if (this.useHeld && EClass.pc.held != null)
99 {
100 if (EClass.pc.held.category.id == "seed")
101 {
102 return "actInstallSeed".lang();
103 }
104 if (EClass.pc.held.id == "fertilizer")
105 {
106 return "actInstallFertilizer".lang();
107 }
108 }
109 return base.GetText(str);
110 }
111
112 // Token: 0x06001118 RID: 4376 RVA: 0x000766C8 File Offset: 0x000748C8
113 public override bool _CanPerformTask(Chara chara, int radius)
114 {
115 Recipe.Ingredient ingredient = this.recipe.ingredients[0];
116 if (!ingredient.IsThingSpecified && ingredient.thing == null)
117 {
118 ingredient.thing = EClass._map.Stocked.Find(ingredient.id, ingredient.mat, ingredient.refVal, false);
119 if (ingredient.thing == null)
120 {
121 base.TryLayer(30);
122 return false;
123 }
124 }
125 return true;
126 }
127
128 // Token: 0x06001119 RID: 4377 RVA: 0x00076734 File Offset: 0x00074934
129 public override void OnAdd()
130 {
131 if (this.reqs == null)
132 {
133 this.reqs = new int[this.recipe.ingredients.Count];
134 for (int i = 0; i < this.recipe.ingredients.Count; i++)
135 {
136 this.reqs[i] = this.recipe.ingredients[i].req;
137 }
138 }
139 }
140
141 // Token: 0x0600111A RID: 4378 RVA: 0x000767A0 File Offset: 0x000749A0
142 public override HitResult GetHitResult()
143 {
144 if (!this.pos.IsValid || (!this.pos.IsInBoundsPlus && !EClass.debug.ignoreBuildRule))
145 {
146 return HitResult.Invalid;
147 }
148 if (this.recipe == null)
149 {
150 Debug.Log("recipe is null");
151 return HitResult.Invalid;
152 }
153 if (this.useHeld)
154 {
155 if (EClass.pc.held == null || EClass.pc.held.GetRootCard() != EClass.pc || EClass.pc.held != this.held)
156 {
157 return HitResult.Invalid;
158 }
159 if (EClass.pc.held.TileType.IsBlockPass && this.pos.HasChara)
160 {
161 return HitResult.Invalid;
162 }
163 if (this.pos.HasBlock && EClass.pc.held.TileType.IsDoor && this.pos.HasWallOrFence && this.pos.cell.blockDir != 2)
164 {
165 this.recipe.SetDir((this.pos.cell.blockDir == 0) ? 0 : 1);
166 }
167 if (!EClass.debug.ignoreBuildRule && !EClass._zone.IsPCFaction)
168 {
169 if (!(EClass._zone is Zone_Tent) && !EClass._zone.IsPCFaction && EClass.pc.held.trait.CanBeOnlyBuiltInHome)
170 {
171 return HitResult.Invalid;
172 }
173 if (EClass._zone.RestrictBuild && !EClass.pc.held.trait.CanBuildInTown)
174 {
175 return HitResult.Invalid;
176 }
177 }
178 }
179 if (this.lastPos != null)
180 {
181 if (this.recipe.IsBlock && this.lastPos.x != this.pos.x && this.lastPos.z != this.pos.z)
182 {
183 return HitResult.Invalid;
184 }
185 if (this.recipe.IsWallOrFence && ((this.recipe._dir == 0 && this.pos.z != this.lastPos.z) || (this.recipe._dir == 1 && this.pos.x != this.lastPos.x)))
186 {
187 return HitResult.Invalid;
188 }
189 }
190 if (!false && this.recipe.HasSameTile(this.pos, this.recipe._dir, this.altitude, this.bridgeHeight))
191 {
192 return HitResult.Default;
193 }
194 if (this.recipe.IsThing)
195 {
196 CardRow cardRow = this.recipe.renderRow as CardRow;
197 if (cardRow != null && !base.CanPlaceCard(this.pos, cardRow.model))
198 {
199 return HitResult.Invalid;
200 }
201 if (this.recipe.MultiSize && this.useHeld)
202 {
203 Point point = new Point();
204 for (int i = 0; i < this.H; i++)
205 {
206 for (int j = 0; j < this.W; j++)
207 {
208 point.Set(this.pos.x - j, this.pos.z + i);
209 if (!point.IsValid)
210 {
211 return HitResult.Invalid;
212 }
213 HitResult hitResult = this._GetHitResult(point);
214 if (hitResult != HitResult.Valid && hitResult != HitResult.Warning)
215 {
216 return HitResult.Invalid;
217 }
218 }
219 }
220 return HitResult.Valid;
221 }
222 }
223 if (this.recipe.IsWallOrFence && this.pos.HasWallOrFence && AM_Adv.actCount == 0 && this.recipe._dir != this.pos.cell.blockDir)
224 {
225 return HitResult.Valid;
226 }
227 if (!this.useHeld && EClass.debug.ignoreBuildRule)
228 {
229 return HitResult.Valid;
230 }
231 if (EClass.scene.actionMode.IsRoofEditMode(null))
232 {
233 return HitResult.Valid;
234 }
235 return this._GetHitResult(this.pos);
236 }
237
238 // Token: 0x0600111B RID: 4379 RVA: 0x00076B24 File Offset: 0x00074D24
239 public HitResult _GetHitResult(Point p)
240 {
241 if (this.useHeld)
242 {
243 if (EClass.pc.held == null || EClass.pc.held.isDestroyed)
244 {
245 return HitResult.Invalid;
246 }
247 if (p.Installed != null)
248 {
249 if (p.Installed.trait is TraitSeed && !(EClass.pc.held.trait is TraitFertilizer))
250 {
251 return HitResult.Invalid;
252 }
253 if (EClass.pc.held.trait is TraitFertilizer && p.Things.LastItem<Thing>().trait is TraitFertilizer)
254 {
255 return HitResult.Invalid;
256 }
257 if (EClass.pc.held.trait is TraitSeed)
258 {
259 using (List<Thing>.Enumerator enumerator = p.Things.GetEnumerator())
260 {
261 while (enumerator.MoveNext())
262 {
263 if (enumerator.Current.trait is TraitSeed)
264 {
265 return HitResult.Invalid;
266 }
267 }
268 }
269 }
270 }
271 }
272 return this.recipe.tileType._HitTest(p, this.recipe.Mold, true);
273 }
274
275 // Token: 0x0600111C RID: 4380 RVA: 0x00076C44 File Offset: 0x00074E44
276 public override void OnProgressComplete()
277 {
278 if (this.useHeld)
279 {
280 if (EClass.pc.held == null || EClass.pc.held.GetRootCard() != EClass.pc || this.pos.Distance(EClass.pc.pos) > 1 || !this.pos.IsInBounds)
281 {
282 return;
283 }
284 ActionMode.Build.FixBridge(this.pos, this.recipe);
285 this.bridgeHeight = ActionMode.Build.bridgeHeight;
286 this.target = (EClass.pc.held.category.installOne ? EClass.pc.held.Split(1) : EClass.pc.held);
287 if (this.target.trait is TraitTile)
288 {
289 this.target.ModNum(-1, true);
290 }
291 this.dir = this.recipe._dir;
292 EClass.pc.LookAt(this.pos);
293 EClass.pc.renderer.PlayAnime(AnimeID.Attack_Place, this.pos);
294 if (this.target.id == "statue_weird")
295 {
296 EClass.pc.Say("statue_install", null, null);
297 }
298 }
299 this.lastPos = this.pos.Copy();
300 if (ActionMode.Build.IsActive && ActionMode.Build.IsFillMode())
301 {
302 if (this.recipe.IsBridge)
303 {
304 this.dir = this.pos.cell.floorDir;
305 this.bridgeHeight = (int)this.pos.cell.bridgeHeight;
306 this.altitude = 0;
307 }
308 else if (this.recipe.IsFloor)
309 {
310 this.dir = this.pos.cell.floorDir;
311 }
312 else if (this.recipe.IsBlock)
313 {
314 this.dir = this.pos.cell.blockDir;
315 }
316 }
317 else
318 {
319 Effect.Get("smoke").Play(this.pos, 0f, null, null);
320 Effect.Get("mine").Play(this.pos, 0f, null, null).SetParticleColor(this.recipe.GetColorMaterial().GetColor()).Emit(10 + EClass.rnd(10));
321 if (this.recipe.IsWallOrFence)
322 {
323 if (this.pos.HasWallOrFence && this.pos.cell.blockDir != 2 && this.pos.cell.blockDir != this.recipe._dir)
324 {
325 this.pos.cell.blockDir = 2;
326 EClass.pc.PlaySound(this.pos.matBlock.GetSoundImpact(null), 1f, true);
327 this.pos.RefreshTile();
328 return;
329 }
330 if (this.pos.sourceRoofBlock.tileType.IsWallOrFence && this.pos.cell._roofBlockDir % 4 != 2 && (int)(this.pos.cell._roofBlockDir % 4) != this.recipe._dir)
331 {
332 this.pos.cell._roofBlockDir = this.pos.cell._roofBlockDir / 4 * 4 + 2;
333 EClass.pc.PlaySound(this.pos.matBlock.GetSoundImpact(null), 1f, true);
334 this.pos.RefreshTile();
335 return;
336 }
337 }
338 }
339 if (this.bridgeHeight > 150)
340 {
341 this.bridgeHeight = 150;
342 }
343 this.recipe.Build(this);
344 this.resources.Clear();
345 EClass.player.flags.OnBuild(this.recipe);
346 EClass._map.RefreshShadow(this.pos.x, this.pos.z);
347 EClass._map.RefreshShadow(this.pos.x, this.pos.z - 1);
348 EClass._map.RefreshFOV(this.pos.x, this.pos.z, 6, false);
349 EClass.pc.renderer.SetFirst(true);
350 if (this.recipe.IsFloor)
351 {
352 foreach (Card card in this.pos.ListThings<TraitNewZone>(true))
353 {
354 bool isDownstairs = (card.trait as TraitNewZone).IsDownstairs;
355 }
356 }
357 }
358
359 // Token: 0x0600111D RID: 4381 RVA: 0x000770F0 File Offset: 0x000752F0
360 public override void OnDestroy()
361 {
362 foreach (Thing t in this.resources)
363 {
364 EClass._zone.AddCard(t, this.pos);
365 }
366 }
367
368 // Token: 0x0600111E RID: 4382 RVA: 0x00077150 File Offset: 0x00075350
369 public override void DrawMarker(int x, int z, RenderParam p)
370 {
371 this.recipe.OnRenderMarker(Point.shared.Set(x, z), this.owner != null, HitResult.Default, x == this.pos.x && z == this.pos.z, this.dir, this.bridgeHeight + this.altitude);
372 }
373
374 // Token: 0x04000DD5 RID: 3541
375 [JsonProperty]
376 public Recipe recipe;
377
378 // Token: 0x04000DD6 RID: 3542
379 [JsonProperty]
380 public int dir;
381
382 // Token: 0x04000DD7 RID: 3543
383 [JsonProperty]
384 public int bridgeHeight;
385
386 // Token: 0x04000DD8 RID: 3544
387 [JsonProperty]
388 public int altitude;
389
390 // Token: 0x04000DD9 RID: 3545
391 [JsonProperty]
392 public List<Thing> resources = new List<Thing>();
393
394 // Token: 0x04000DDA RID: 3546
395 [JsonProperty]
396 public int[] reqs;
397
398 // Token: 0x04000DDB RID: 3547
399 public Card held;
400
401 // Token: 0x04000DDC RID: 3548
402 public float fx;
403
404 // Token: 0x04000DDD RID: 3549
405 public float fy;
406
407 // Token: 0x04000DDE RID: 3550
408 public bool freePos;
409
410 // Token: 0x04000DDF RID: 3551
411 public Card target;
412
413 // Token: 0x04000DE0 RID: 3552
414 public Point lastPos;
415}
Definition Card.cs:13
Definition Chara.cs:12
Definition Point.cs:11
Definition Thing.cs:10