Elin Modding Docs Doc
Loading...
Searching...
No Matches
BaseTileSelector.cs
1using System;
2using UnityEngine;
3
4// Token: 0x020001AE RID: 430
5public class BaseTileSelector : EMono
6{
7 // Token: 0x170002F5 RID: 757
8 // (get) Token: 0x06000C47 RID: 3143 RVA: 0x0005B9FA File Offset: 0x00059BFA
9 public ActionMode mode
10 {
11 get
12 {
13 return EMono.scene.actionMode;
14 }
15 }
16
17 // Token: 0x170002F6 RID: 758
18 // (get) Token: 0x06000C48 RID: 3144 RVA: 0x0005BA06 File Offset: 0x00059C06
19 public BaseTileSelector.SelectType selectType
20 {
21 get
22 {
23 return this.mode.selectType;
24 }
25 }
26
27 // Token: 0x170002F7 RID: 759
28 // (get) Token: 0x06000C49 RID: 3145 RVA: 0x0005BA13 File Offset: 0x00059C13
29 public BaseTileSelector.HitType hitType
30 {
31 get
32 {
33 return this.mode.hitType;
34 }
35 }
36
37 // Token: 0x170002F8 RID: 760
38 // (get) Token: 0x06000C4A RID: 3146 RVA: 0x0005BA20 File Offset: 0x00059C20
39 public BaseTileSelector.BoxType boxType
40 {
41 get
42 {
43 return this.mode.boxType;
44 }
45 }
46
47 // Token: 0x170002F9 RID: 761
48 // (get) Token: 0x06000C4B RID: 3147 RVA: 0x0005BA2D File Offset: 0x00059C2D
49 public int hitW
50 {
51 get
52 {
53 return this.mode.hitW;
54 }
55 }
56
57 // Token: 0x170002FA RID: 762
58 // (get) Token: 0x06000C4C RID: 3148 RVA: 0x0005BA3A File Offset: 0x00059C3A
59 public int hitH
60 {
61 get
62 {
63 return this.mode.hitH;
64 }
65 }
66
67 // Token: 0x170002FB RID: 763
68 // (get) Token: 0x06000C4D RID: 3149 RVA: 0x0005BA47 File Offset: 0x00059C47
69 public bool multisize
70 {
71 get
72 {
73 return this.hitW != 1 || this.hitH != 1;
74 }
75 }
76
77 // Token: 0x170002FC RID: 764
78 // (get) Token: 0x06000C4E RID: 3150 RVA: 0x0005BA60 File Offset: 0x00059C60
79 public int Width
80 {
81 get
82 {
83 if (!Scene.HitPoint.IsValid)
84 {
85 return 0;
86 }
87 if (this.start != null)
88 {
89 return Mathf.Abs(Scene.HitPoint.x - this.start.x) + 1;
90 }
91 return 1;
92 }
93 }
94
95 // Token: 0x170002FD RID: 765
96 // (get) Token: 0x06000C4F RID: 3151 RVA: 0x0005BA97 File Offset: 0x00059C97
97 public int Height
98 {
99 get
100 {
101 if (!Scene.HitPoint.IsValid)
102 {
103 return 0;
104 }
105 if (this.start != null)
106 {
107 return Mathf.Abs(Scene.HitPoint.z - this.start.z) + 1;
108 }
109 return 1;
110 }
111 }
112
113 // Token: 0x06000C50 RID: 3152 RVA: 0x0005BACE File Offset: 0x00059CCE
114 public void OnChangeActionMode()
115 {
116 this.start = null;
117 this.RefreshMouseInfo(true);
118 }
119
120 // Token: 0x06000C51 RID: 3153 RVA: 0x0005BADE File Offset: 0x00059CDE
121 public virtual void OnRenderTile(Point point, HitResult result, bool shouldHide)
122 {
123 }
124
125 // Token: 0x06000C52 RID: 3154 RVA: 0x0005BAE0 File Offset: 0x00059CE0
126 public void OnUpdate()
127 {
128 Point hitPoint = Scene.HitPoint;
129 if (!ActionMode.Adv.IsActive)
130 {
131 this.RefreshMouseInfo(true);
132 }
133 if (EInput.leftMouse.pressedLong && this.mode.AllowAutoClick)
134 {
135 this.autoClick = true;
136 }
137 if (this.autoClick && !EInput.leftMouse.pressing)
138 {
139 this.autoClick = false;
140 if (this.start != null)
141 {
142 this.mode.OnSelectEnd(true);
143 this.start = null;
144 this.RefreshSummary();
145 this.RefreshMouseInfo(true);
146 }
147 }
148 if (this.autoClick && hitPoint.Distance(this.lastClickPoint) > 1 && this.selectType == BaseTileSelector.SelectType.Multiple && this.start != null)
149 {
150 this.start = hitPoint.Copy();
151 this.mode.OnSelectStart(this.start);
152 this.RefreshMouseInfo(true);
153 this.lastClickPoint.Set(hitPoint);
154 }
155 if (((EInput.rightScroll && EInput.rightMouse.clicked) || (!EInput.rightScroll && EInput.rightMouse.down) || Input.GetKeyDown(KeyCode.Escape)) && !EMono.ui.wasActive)
156 {
157 if (this.selectType == BaseTileSelector.SelectType.Multiple && this.start != null)
158 {
159 this.mode.OnSelectEnd(true);
160 this.start = null;
161 this.RefreshSummary();
162 this.RefreshMouseInfo(true);
163 }
164 else
165 {
166 this.mode.OnCancel();
167 }
168 EMono.ui.hud.hint.UpdateText();
169 }
170 if (!hitPoint.IsValid || EMono.ui.isPointerOverUI || EMono.ui.wasActive || this.mode.selectType == BaseTileSelector.SelectType.None || !EMono.pc.ai.ShowCursor)
171 {
172 return;
173 }
174 if (this.mode.hitType != BaseTileSelector.HitType.None)
175 {
176 if (this.mode.IsFillMode())
177 {
178 this.start = null;
179 this.ProcessFillTiles(hitPoint, BaseTileSelector.ProcessMode.Render);
180 }
181 else
182 {
183 this.ProcessTiles(this.start ?? hitPoint, hitPoint, BaseTileSelector.ProcessMode.Render);
184 }
185 }
186 if (this.start == null && (this.mode.AreaHihlight == AreaHighlightMode.Edit || this.mode.AreaHihlight == AreaHighlightMode.Sim) && hitPoint.area != null)
187 {
188 hitPoint.area.OnHoverArea(EMono.screen.guide.passArea);
189 }
190 if ((this.autoClick || EInput.leftMouse.down || (this.mode.ContinuousClick && EInput.leftMouse.pressing)) && this.mode.CanSelectTile)
191 {
192 if (this.start != null || hitPoint.IsSeen)
193 {
194 if (this.mode.IsFillMode())
195 {
196 this.TryProcessTiles(hitPoint);
197 }
198 else if (this.selectType == BaseTileSelector.SelectType.Single)
199 {
200 HitResult hitResult = this.mode._HitTest(this.temp, this.start);
201 if ((hitResult == HitResult.Valid || hitResult == HitResult.Warning) && this.mode.CanProcessTiles())
202 {
203 this.TryProcessTiles(hitPoint);
204 }
205 else if (!this.autoClick)
206 {
207 SE.Beep();
208 }
209 }
210 else
211 {
212 if (this.start == null)
213 {
214 this.start = hitPoint.Copy();
215 this.mode.OnSelectStart(this.start);
216 this.RefreshMouseInfo(true);
217 if (this.autoClick)
218 {
219 this.TryProcessTiles(hitPoint);
220 }
221 }
222 else
223 {
224 this.TryProcessTiles(hitPoint);
225 }
226 if (this.autoClick)
227 {
228 this.start = hitPoint.Copy();
229 this.mode.OnSelectStart(this.start);
230 this.RefreshMouseInfo(true);
231 }
232 }
233 }
234 this.lastClickPoint.Set(hitPoint);
235 EMono.ui.hud.hint.UpdateText();
236 }
237 }
238
239 // Token: 0x06000C53 RID: 3155 RVA: 0x0005BE60 File Offset: 0x0005A060
240 public void TryProcessTiles(Point _end)
241 {
242 if (EInput.skipFrame > 0)
243 {
244 return;
245 }
246 if (!this.mode.CanProcessTiles())
247 {
248 if (!EMono.screen.tileSelector.autoClick)
249 {
250 SE.Beep();
251 }
252 return;
253 }
254 Point point = _end.Copy();
255 ActionMode mode = this.mode;
256 this.mode.OnBeforeProcessTiles();
257 if (this.mode.IsFillMode())
258 {
259 this.ProcessFillTiles(point, BaseTileSelector.ProcessMode.Prpcess);
260 }
261 else if (this.start == null)
262 {
263 this.mode.OnProcessTiles(point, -1);
264 }
265 else
266 {
267 this.ProcessTiles(this.start, point, BaseTileSelector.ProcessMode.Prpcess);
268 this.mode.OnSelectEnd(false);
269 }
270 if (this.mode != mode)
271 {
272 return;
273 }
274 this.mode.OnAfterProcessTiles(this.start, point);
275 this.start = null;
276 this.ExecuteSummary();
277 this.RefreshMouseInfo(true);
278 this.mode.OnFinishProcessTiles();
279 }
280
281 // Token: 0x06000C54 RID: 3156 RVA: 0x0005BF38 File Offset: 0x0005A138
282 public void ProcessTiles(Point start, Point end, BaseTileSelector.ProcessMode processMode)
283 {
284 new Point();
285 object obj = (start.x > end.x) ? start.x : end.x;
286 int num = (start.z < end.z) ? start.z : end.z;
287 int num2 = (start.x > end.x) ? end.x : start.x;
288 int num3 = (start.z < end.z) ? end.z : start.z;
289 object obj2 = obj;
290 int num4 = obj2 - num2 + 1;
291 int num5 = num3 - num + 1;
292 BaseTileSelector.BoxType boxType = this.boxType;
293 int num6 = -1;
294 int num7 = 0;
295 this.firstInMulti = false;
296 if (this.multisize && this.selectType == BaseTileSelector.SelectType.Single && processMode != BaseTileSelector.ProcessMode.Prpcess)
297 {
298 num2 -= this.hitW - 1;
299 num3 += this.hitH - 1;
300 num4 += this.hitW - 1;
301 num5 += this.hitH - 1;
302 }
303 if (processMode == BaseTileSelector.ProcessMode.Prpcess)
304 {
305 this.processing = true;
306 }
307 for (int i = obj2; i > num2 - 1; i--)
308 {
309 int j = num;
310 while (j < num3 + 1)
311 {
312 if (boxType != BaseTileSelector.BoxType.Fence || (num4 <= 1 && num5 <= 1))
313 {
314 goto IL_12A;
315 }
316 num6 = ((num4 > num5) ? 0 : 1);
317 if ((num6 != 0 || j == start.z) && (num6 != 1 || i == start.x))
318 {
319 goto IL_12A;
320 }
321 IL_15E:
322 j++;
323 continue;
324 IL_12A:
325 this.temp.Set(i, j);
326 if (start.x != i || start.z != j)
327 {
328 this._ProcessTile(start, this.temp, processMode, num6);
329 goto IL_15E;
330 }
331 goto IL_15E;
332 }
333 num7++;
334 if (num7 > 30000)
335 {
336 Debug.Log(num7);
337 break;
338 }
339 }
340 this.firstInMulti = true;
341 this._ProcessTile(start, start, processMode, num6);
342 this.processing = false;
343 }
344
345 // Token: 0x06000C55 RID: 3157 RVA: 0x0005C0F8 File Offset: 0x0005A2F8
346 public void ProcessFillTiles(Point start, BaseTileSelector.ProcessMode processMode)
347 {
348 EMono._map.ForeachPoint(delegate(Point dest)
349 {
350 if (!start.Equals(dest))
351 {
352 this._ProcessTile(start, dest, processMode, -1);
353 }
354 });
355 this._ProcessTile(start, start, processMode, -1);
356 }
357
358 // Token: 0x06000C56 RID: 3158 RVA: 0x0005C150 File Offset: 0x0005A350
359 private void _ProcessTile(Point start, Point dest, BaseTileSelector.ProcessMode processMode, int dir = -1)
360 {
361 if (!dest.IsValid)
362 {
363 return;
364 }
365 HitResult hitResult = this.mode._HitTest(dest, start);
366 switch (processMode)
367 {
368 case BaseTileSelector.ProcessMode.Render:
369 this.mode.OnRenderTile(dest, hitResult, dir);
370 this.firstInMulti = false;
371 return;
372 case BaseTileSelector.ProcessMode.Prpcess:
373 if (hitResult == HitResult.Valid || hitResult == HitResult.Warning)
374 {
375 this.mode.OnProcessTiles(dest, dir);
376 return;
377 }
378 break;
379 case BaseTileSelector.ProcessMode.Summary:
380 this.mode.OnRefreshSummary(dest, hitResult, this.summary);
381 break;
382 default:
383 return;
384 }
385 }
386
387 // Token: 0x06000C57 RID: 3159 RVA: 0x0005C1C8 File Offset: 0x0005A3C8
388 public bool IsInRange(int x, int z, Point end)
389 {
390 if (this.start.x > end.x)
391 {
392 if (x > this.start.x || x < end.x)
393 {
394 return false;
395 }
396 }
397 else if (x < this.start.x || x > end.x)
398 {
399 return false;
400 }
401 if (this.start.z > end.z)
402 {
403 if (z > this.start.z || z < end.z)
404 {
405 return false;
406 }
407 }
408 else if (z < this.start.z || z > end.z)
409 {
410 return false;
411 }
412 return true;
413 }
414
415 // Token: 0x06000C58 RID: 3160 RVA: 0x0005C260 File Offset: 0x0005A460
416 public unsafe void RefreshMouseInfo(bool force = false)
417 {
418 bool enable = true;
419 Point hitPoint = Scene.HitPoint;
420 if (EMono.ui.IsActive || EMono.ui.isPointerOverUI || !this.mode.enableMouseInfo || !hitPoint.IsValid)
421 {
422 enable = false;
423 }
424 else if (!hitPoint.Equals(this.lastPoint) || force)
425 {
426 if (this.start != null && !hitPoint.Equals(this.lastPoint))
427 {
428 SE.Play("highlight3");
429 }
430 this.RefreshSummary();
431 string text = "";
432 int num = 0;
433 if (this.start != null)
434 {
435 int num2 = Mathf.Abs(hitPoint.x - this.start.x) + 1;
436 int num3 = Mathf.Abs(hitPoint.z - this.start.z) + 1;
437 if (!hitPoint.IsValid)
438 {
439 num2 = 0;
440 num3 = 0;
441 }
442 text = string.Concat(new string[]
443 {
444 text,
445 "(",
446 num2.ToString(),
447 " x ",
448 num3.ToString(),
449 ")"
450 });
451 }
452 else if (this.selectType == BaseTileSelector.SelectType.Multiple)
453 {
454 text += "selectRange".lang();
455 }
456 if (this.selectType == BaseTileSelector.SelectType.Single)
457 {
458 num = this.mode.CostMoney;
459 }
460 else if (this.start != null)
461 {
462 num = this.summary.money;
463 }
464 EMono.ui.mouseInfo.textCost.SetActive(num != 0);
465 if (num != 0)
466 {
467 EMono.ui.mouseInfo.textCost.text = (num.ToString() ?? "");
468 }
469 if (this.mode.TopHeight(hitPoint) != -1)
470 {
471 text += "hintAltitude".lang(this.mode.TopHeight(hitPoint).ToString() ?? "", null, null, null, null);
472 }
473 if (EMono.scene.actionMode == ActionMode.Picker)
474 {
475 AM_Picker.Result result = ActionMode.Picker.Test(hitPoint, false);
476 if (result.IsValid)
477 {
478 text += result.GetText();
479 }
480 }
481 if (this.mode.IsRoofEditMode(null))
482 {
483 text = text + Environment.NewLine + "roofEdit".lang();
484 }
485 else if (this.mode.IsFillMode())
486 {
487 text = text + Environment.NewLine + "fillMode".lang();
488 }
489 text += "\n";
490 EMono.ui.mouseInfo.text.SetText(*this.mode.SetMouseInfo(ref text));
491 }
492 EMono.ui.mouseInfo.SetActive(enable);
493 this.lastPoint.Set(hitPoint);
494 }
495
496 // Token: 0x06000C59 RID: 3161 RVA: 0x0005C509 File Offset: 0x0005A709
497 public void ExecuteSummary()
498 {
499 if (!BuildMenu.Instance)
500 {
501 return;
502 }
503 this.summary.Execute();
504 BuildMenu.Instance.info1.Refresh();
505 this.RefreshSummary();
506 this.mode.SEExecuteSummary();
507 }
508
509 // Token: 0x06000C5A RID: 3162 RVA: 0x0005C544 File Offset: 0x0005A744
510 public void RefreshSummary()
511 {
512 Point hitPoint = Scene.HitPoint;
513 this.summary.Clear();
514 this.ProcessTiles(this.start ?? hitPoint, hitPoint, BaseTileSelector.ProcessMode.Summary);
515 if (BuildMenu.Instance)
516 {
517 BuildMenu.Instance.info1.RefreshBalance();
518 }
519 }
520
521 // Token: 0x04000C14 RID: 3092
522 public BaseTileSelector.HitType inspectHitType;
523
524 // Token: 0x04000C15 RID: 3093
525 public bool inspectorHighlight;
526
527 // Token: 0x04000C16 RID: 3094
528 public HitSummary summary = new HitSummary();
529
530 // Token: 0x04000C17 RID: 3095
531 [NonSerialized]
532 public Point start;
533
534 // Token: 0x04000C18 RID: 3096
535 [NonSerialized]
536 public Point temp = new Point();
537
538 // Token: 0x04000C19 RID: 3097
539 [NonSerialized]
540 public Point lastPoint = new Point();
541
542 // Token: 0x04000C1A RID: 3098
543 [NonSerialized]
544 public Point lastClickPoint = new Point();
545
546 // Token: 0x04000C1B RID: 3099
547 [NonSerialized]
548 public bool processing;
549
550 // Token: 0x04000C1C RID: 3100
551 [NonSerialized]
552 public bool autoClick;
553
554 // Token: 0x04000C1D RID: 3101
555 public bool firstInMulti;
556
557 // Token: 0x02000897 RID: 2199
558 public enum SelectType
559 {
560 // Token: 0x040024B0 RID: 9392
561 Single,
562 // Token: 0x040024B1 RID: 9393
563 Multiple,
564 // Token: 0x040024B2 RID: 9394
565 None
566 }
567
568 // Token: 0x02000898 RID: 2200
569 public enum HitType
570 {
571 // Token: 0x040024B4 RID: 9396
572 None,
573 // Token: 0x040024B5 RID: 9397
574 Default,
575 // Token: 0x040024B6 RID: 9398
576 Floor,
577 // Token: 0x040024B7 RID: 9399
578 Block,
579 // Token: 0x040024B8 RID: 9400
580 Inspect
581 }
582
583 // Token: 0x02000899 RID: 2201
584 public enum BoxType
585 {
586 // Token: 0x040024BA RID: 9402
587 Box,
588 // Token: 0x040024BB RID: 9403
589 Fence
590 }
591
592 // Token: 0x0200089A RID: 2202
593 public enum ProcessMode
594 {
595 // Token: 0x040024BD RID: 9405
596 Render,
597 // Token: 0x040024BE RID: 9406
598 Prpcess,
599 // Token: 0x040024BF RID: 9407
600 Summary
601 }
602}
Definition EMono.cs:6
Definition Point.cs:11
Definition Scene.cs:10