Elin Modding Docs Doc
Loading...
Searching...
No Matches
AM_Build.cs
1using System;
2using UnityEngine;
3
4// Token: 0x02000149 RID: 329
5public class AM_Build : AM_Designation<TaskBuild>
6{
7 // Token: 0x0600095C RID: 2396 RVA: 0x00039E51 File Offset: 0x00038051
8 public bool _IsRoofEditMode(Card c)
9 {
10 return Input.GetKey(KeyCode.LeftAlt) && (c == null || !c.trait.CanOnlyCarry);
11 }
12
13 // Token: 0x0600095D RID: 2397 RVA: 0x00039E74 File Offset: 0x00038074
14 public override bool IsRoofEditMode(Card c = null)
15 {
16 Recipe recipe = this.recipe;
17 return this._IsRoofEditMode((recipe != null) ? recipe.Mold : null);
18 }
19
20 // Token: 0x0600095E RID: 2398 RVA: 0x00039E8E File Offset: 0x0003808E
21 public override bool IsFillMode()
22 {
23 return !this.recipe.IsThing && Input.GetKey(KeyCode.LeftControl) && EClass.debug.godBuild;
24 }
25
26 // Token: 0x1700023D RID: 573
27 // (get) Token: 0x0600095F RID: 2399 RVA: 0x00039EB5 File Offset: 0x000380B5
28 public override BuildMenu.Mode buildMenuMode
29 {
30 get
31 {
32 return BuildMenu.Mode.Build;
33 }
34 }
35
36 // Token: 0x1700023E RID: 574
37 // (get) Token: 0x06000960 RID: 2400 RVA: 0x00039EB8 File Offset: 0x000380B8
38 public override int CostMoney
39 {
40 get
41 {
42 if (this.recipe == null || this.recipe.UseStock)
43 {
44 return 0;
45 }
46 return 10;
47 }
48 }
49
50 // Token: 0x1700023F RID: 575
51 // (get) Token: 0x06000961 RID: 2401 RVA: 0x00039ED3 File Offset: 0x000380D3
52 public override bool IsBuildMode
53 {
54 get
55 {
56 return true;
57 }
58 }
59
60 // Token: 0x17000240 RID: 576
61 // (get) Token: 0x06000962 RID: 2402 RVA: 0x00039ED6 File Offset: 0x000380D6
62 public override string idSound
63 {
64 get
65 {
66 return null;
67 }
68 }
69
70 // Token: 0x17000241 RID: 577
71 // (get) Token: 0x06000963 RID: 2403 RVA: 0x00039ED9 File Offset: 0x000380D9
72 public override bool AllowAutoClick
73 {
74 get
75 {
76 return this.recipe != null && !(this.recipe is RecipeCard);
77 }
78 }
79
80 // Token: 0x17000242 RID: 578
81 // (get) Token: 0x06000964 RID: 2404 RVA: 0x00039EF6 File Offset: 0x000380F6
82 public override bool AllowMiddleClickFunc
83 {
84 get
85 {
86 return false;
87 }
88 }
89
90 // Token: 0x17000243 RID: 579
91 // (get) Token: 0x06000965 RID: 2405 RVA: 0x00039EF9 File Offset: 0x000380F9
92 public override int SelectorHeight
93 {
94 get
95 {
96 return this.bridgeHeight;
97 }
98 }
99
100 // Token: 0x06000966 RID: 2406 RVA: 0x00039F01 File Offset: 0x00038101
101 public override int TopHeight(Point p)
102 {
103 return this.bridgeHeight + (this.recipe.tileType.AltitudeAsDir ? 0 : this.altitude);
104 }
105
106 // Token: 0x06000967 RID: 2407 RVA: 0x00039F25 File Offset: 0x00038125
107 public override HitResult HitResultOnDesignation(Point p)
108 {
109 CellDetail detail = p.detail;
110 if (((detail != null) ? detail.designation : null) is TaskBuild)
111 {
112 return HitResult.Warning;
113 }
114 return HitResult.Invalid;
115 }
116
117 // Token: 0x17000244 RID: 580
118 // (get) Token: 0x06000968 RID: 2408 RVA: 0x00039F43 File Offset: 0x00038143
119 public override BaseTileSelector.HitType hitType
120 {
121 get
122 {
123 Recipe recipe = this.recipe;
124 if (recipe == null)
125 {
126 return BaseTileSelector.HitType.None;
127 }
128 return recipe.tileType.HitType;
129 }
130 }
131
132 // Token: 0x17000245 RID: 581
133 // (get) Token: 0x06000969 RID: 2409 RVA: 0x00039F5B File Offset: 0x0003815B
134 public override BaseTileSelector.SelectType selectType
135 {
136 get
137 {
138 Recipe recipe = this.recipe;
139 if (recipe == null)
140 {
141 return BaseTileSelector.SelectType.Single;
142 }
143 return recipe.tileType.SelectType;
144 }
145 }
146
147 // Token: 0x17000246 RID: 582
148 // (get) Token: 0x0600096A RID: 2410 RVA: 0x00039F73 File Offset: 0x00038173
149 public override BaseTileSelector.BoxType boxType
150 {
151 get
152 {
153 Recipe recipe = this.recipe;
154 if (recipe == null)
155 {
156 return BaseTileSelector.BoxType.Box;
157 }
158 return recipe.GetBoxType();
159 }
160 }
161
162 // Token: 0x17000247 RID: 583
163 // (get) Token: 0x0600096B RID: 2411 RVA: 0x00039F86 File Offset: 0x00038186
164 public override int hitW
165 {
166 get
167 {
168 Recipe recipe = this.recipe;
169 if (recipe == null)
170 {
171 return 1;
172 }
173 return recipe.W;
174 }
175 }
176
177 // Token: 0x17000248 RID: 584
178 // (get) Token: 0x0600096C RID: 2412 RVA: 0x00039F99 File Offset: 0x00038199
179 public override int hitH
180 {
181 get
182 {
183 Recipe recipe = this.recipe;
184 if (recipe == null)
185 {
186 return 1;
187 }
188 return recipe.H;
189 }
190 }
191
192 // Token: 0x0600096D RID: 2413 RVA: 0x00039FAC File Offset: 0x000381AC
193 public override MeshPass GetGuidePass(Point point)
194 {
195 if (!this.recipe.IsBlock)
196 {
197 return EClass.screen.guide.passGuideFloor;
198 }
199 return EClass.screen.guide.passGuideBlock;
200 }
201
202 // Token: 0x0600096E RID: 2414 RVA: 0x00039FDA File Offset: 0x000381DA
203 public override bool ForcedInstaComplete(TaskBuild t)
204 {
205 return this.recipe.tileType.CanInstaComplete;
206 }
207
208 // Token: 0x0600096F RID: 2415 RVA: 0x00039FEC File Offset: 0x000381EC
209 public override void OnUpdateCursor()
210 {
211 base.SetCursorOnMap(CursorSystem.Build);
212 }
213
214 // Token: 0x06000970 RID: 2416 RVA: 0x00039FF9 File Offset: 0x000381F9
215 public override void OnActivate()
216 {
217 this.list = base.Designations.build;
218 base.OnActivate();
219 }
220
221 // Token: 0x06000971 RID: 2417 RVA: 0x0003A014 File Offset: 0x00038214
222 public override void OnDeactivate()
223 {
224 base.Summary.SetRecipe(null);
225 this.recipe = (this.mold.recipe = null);
226 this.houseBoard = null;
227 if (BuildMenu.Instance)
228 {
229 BuildMenu.Instance.Unselect();
230 }
231 }
232
233 // Token: 0x06000972 RID: 2418 RVA: 0x0003A05F File Offset: 0x0003825F
234 public override void OnCancel()
235 {
236 ActionMode.Inspect.Activate(true, false);
237 }
238
239 // Token: 0x06000973 RID: 2419 RVA: 0x0003A070 File Offset: 0x00038270
240 public void StartBuild(Recipe r, Func<ButtonGrid> _button)
241 {
242 this.recipe = r;
243 this.button = _button;
244 if (!base.IsActive)
245 {
246 base.Activate(true, false);
247 }
248 base.CreateNewMold(false);
249 this.bridgeHeight = -1;
250 this.SetAltitude(0);
251 base.Summary.SetRecipe(r);
252 EClass.ui.hud.hint.Refresh();
253 }
254
255 // Token: 0x06000974 RID: 2420 RVA: 0x0003A0D0 File Offset: 0x000382D0
256 public override void OnCreateMold(bool processing = false)
257 {
258 this.mold.recipe = (processing ? this._recipe : this.recipe);
259 this.SetAltitude(this.altitude);
260 }
261
262 // Token: 0x06000975 RID: 2421 RVA: 0x0003A0FC File Offset: 0x000382FC
263 public override HitResult HitTest(Point point, Point start)
264 {
265 if (start != null)
266 {
267 this.mold.bridgeHeight = (int)start.cell.bridgeHeight;
268 }
269 else
270 {
271 this.mold.bridgeHeight = (int)point.cell.bridgeHeight;
272 }
273 if (this.recipe == null)
274 {
275 return HitResult.Default;
276 }
277 if (this.IsRoofEditMode(null))
278 {
279 return HitResult.Valid;
280 }
281 if (this.IsFillMode())
282 {
283 Cell cell = point.cell;
284 if (this.recipe.IsBridge)
285 {
286 if (cell._bridge != start.cell._bridge)
287 {
288 return HitResult.NoTarget;
289 }
290 return HitResult.Valid;
291 }
292 else if (this.recipe.IsFloor)
293 {
294 if (cell._floor != start.cell._floor)
295 {
296 return HitResult.NoTarget;
297 }
298 return HitResult.Valid;
299 }
300 else if (this.recipe.IsBlock)
301 {
302 if (cell._block != start.cell._block)
303 {
304 return HitResult.NoTarget;
305 }
306 return HitResult.Valid;
307 }
308 }
309 if (this.recipe.IsBridge && this.recipe.tileType.SelectType == BaseTileSelector.SelectType.Multiple && !point.Equals(start) && (int)point.cell.height > this.bridgeHeight + this.altitude)
310 {
311 return HitResult.Invalid;
312 }
313 return base.HitTest(point, start);
314 }
315
316 // Token: 0x06000976 RID: 2422 RVA: 0x0003A224 File Offset: 0x00038424
317 public void FixBridge(Point point, Recipe recipe)
318 {
319 this.bridgeHeight = -1;
320 if (recipe.IsBridge)
321 {
322 this.bridgeHeight = (int)((byte)((point.cell.bridgeHeight == 0) ? ((int)point.cell.height + recipe.tileType.MinAltitude) : ((int)point.cell.bridgeHeight)));
323 }
324 }
325
326 // Token: 0x06000977 RID: 2423 RVA: 0x0003A278 File Offset: 0x00038478
327 public unsafe override void OnRenderTile(Point point, HitResult result, int dir)
328 {
329 if (this.recipe == null)
330 {
331 return;
332 }
333 if (this.recipe is RecipeBridgePillar)
334 {
335 base.OnRenderTile(point, result, dir);
336 return;
337 }
338 if (EClass.screen.tileSelector.start == null)
339 {
340 this.FixBridge(point, this.recipe);
341 }
342 if (this.recipe.IsFloorOrBridge && !this.recipe.IsBridge && point.cell.bridgeHeight != 0)
343 {
344 base.OnRenderTileFloor(point, result);
345 return;
346 }
347 if (result != HitResult.Valid && result != HitResult.Warning)
348 {
349 base.OnRenderTile(point, result, dir);
350 return;
351 }
352 if (this.bridgeHeight != -1)
353 {
354 Vector3 vector = *point.Position();
355 EClass.screen.guide.passGuideFloor.Add(vector.x, vector.y, vector.z - 0.01f, (float)result, 0f);
356 }
357 int desiredDir = this.recipe.tileType.GetDesiredDir(point, this.recipe._dir);
358 if (desiredDir != -1)
359 {
360 dir = (this.recipe._dir = desiredDir);
361 }
362 bool main = !base.tileSelector.multisize || (base.tileSelector.firstInMulti && base.Summary.count == base.Summary.countValid);
363 this.recipe.OnRenderMarker(point, false, result, main, dir, this.bridgeHeight + ((this.recipe.tileType.AltitudeAsDir && !this.IsRoofEditMode(null)) ? 0 : this.altitude));
364 }
365
366 // Token: 0x06000978 RID: 2424 RVA: 0x0003A3F3 File Offset: 0x000385F3
367 public override void OnBeforeProcessTiles()
368 {
369 this._recipe = this.recipe;
370 this._recipe._dir = this.recipe._dir;
371 this.mold.dir = this.recipe._dir;
372 base.OnBeforeProcessTiles();
373 }
374
375 // Token: 0x06000979 RID: 2425 RVA: 0x0003A434 File Offset: 0x00038634
376 public override void OnProcessTiles(Point point, int dir)
377 {
378 if (dir != -1)
379 {
380 this.mold.dir = dir;
381 }
382 else
383 {
384 this.mold.dir = this.recipe._dir;
385 }
386 if (point.HasDesignation)
387 {
388 TaskBuild taskBuild = point.detail.designation as TaskBuild;
389 if (taskBuild != null && this.recipe.IsWallOrFence && taskBuild.recipe.IsWallOrFence && taskBuild.dir != dir)
390 {
391 dir = (this.mold.dir = 2);
392 }
393 CellDetail detail = point.detail;
394 if (detail != null)
395 {
396 detail.designation.Destroy();
397 }
398 }
399 this.mold.bridgeHeight = this.bridgeHeight;
400 this.SetAltitude(this.altitude);
401 base.OnProcessTiles(point, dir);
402 }
403
404 // Token: 0x0600097A RID: 2426 RVA: 0x0003A4F4 File Offset: 0x000386F4
405 public override void OnFinishProcessTiles()
406 {
407 base.OnFinishProcessTiles();
408 ButtonGrid buttonGrid = this.button();
409 if (this.recipe.UseStock)
410 {
411 Thing thing = this.recipe.ingredients[0].thing;
412 if (thing == null || thing.isDestroyed || thing.ExistsOnMap || thing.Num <= 0)
413 {
414 ActionMode.ignoreSound = true;
415 if (buttonGrid)
416 {
417 buttonGrid.selected = false;
418 buttonGrid.DoNormalTransition(true);
419 }
420 BuildMenu.Instance.Unselect();
421 BuildMenu.Instance.RefreshCategory(EClass.player.pref.lastBuildCategory);
422 ActionMode.Inspect.Activate(true, false);
423 BuildMenu.Instance.Unselect();
424 return;
425 }
426 }
427 if (buttonGrid)
428 {
429 buttonGrid.SetRecipe();
430 }
431 if (this.recipe.IsBridge)
432 {
433 this.SetAltitude(0);
434 }
435 }
436
437 // Token: 0x0600097B RID: 2427 RVA: 0x0003A5CE File Offset: 0x000387CE
438 public override void RotateUnderMouse()
439 {
440 if (this.recipe != null && this.recipe.CanRotate)
441 {
442 SE.Rotate();
443 this.recipe.Rotate();
444 return;
445 }
446 }
447
448 // Token: 0x17000249 RID: 585
449 // (get) Token: 0x0600097C RID: 2428 RVA: 0x0003A5F6 File Offset: 0x000387F6
450 public int MaxAltitude
451 {
452 get
453 {
454 if (!this.IsRoofEditMode(null) || !(this.recipe.renderRow is SourceBlock.Row))
455 {
456 return this.recipe.MaxAltitude;
457 }
458 return 63;
459 }
460 }
461
462 // Token: 0x0600097D RID: 2429 RVA: 0x0003A621 File Offset: 0x00038821
463 public override void InputWheel(int wheel)
464 {
465 if (EInput.isAltDown || EInput.isCtrlDown)
466 {
467 return;
468 }
469 if (this.recipe.MaxAltitude > 0)
470 {
471 this.ModAltitude(wheel);
472 EClass.screen.tileSelector.RefreshMouseInfo(true);
473 return;
474 }
475 base.InputWheel(wheel);
476 }
477
478 // Token: 0x0600097E RID: 2430 RVA: 0x0003A660 File Offset: 0x00038860
479 public void ModAltitude(int a)
480 {
481 this.altitude += a;
482 if (this.altitude < (this.recipe.IsBridge ? -10 : 0))
483 {
484 this.altitude = this.MaxAltitude;
485 }
486 if (this.altitude > this.MaxAltitude)
487 {
488 this.altitude = (this.recipe.IsBridge ? -10 : 0);
489 }
490 this.SetAltitude(this.altitude);
491 }
492
493 // Token: 0x0600097F RID: 2431 RVA: 0x0003A6D4 File Offset: 0x000388D4
494 public void SetAltitude(int a)
495 {
496 this.mold.altitude = a;
497 this.altitude = a;
498 this.recipe.OnChangeAltitude(a);
499 if (this.recipe.tileType.AltitudeAsDir && !this.IsRoofEditMode(null))
500 {
501 this.mold.dir = (this.recipe._dir = this.altitude);
502 }
503 }
504
505 // Token: 0x040008E9 RID: 2281
506 public int bridgeHeight;
507
508 // Token: 0x040008EA RID: 2282
509 public int altitude;
510
511 // Token: 0x040008EB RID: 2283
512 public Recipe recipe;
513
514 // Token: 0x040008EC RID: 2284
515 public Recipe _recipe;
516
517 // Token: 0x040008ED RID: 2285
518 public Func<ButtonGrid> button;
519
520 // Token: 0x040008EE RID: 2286
521 public TraitHouseBoard houseBoard;
522}
Definition Card.cs:13
Definition Cell.cs:10
Definition Point.cs:11
Definition Thing.cs:10