13 return EMono.scene.actionMode;
19 public BaseTileSelector.SelectType selectType
23 return this.mode.selectType;
29 public BaseTileSelector.HitType hitType
33 return this.mode.hitType;
39 public BaseTileSelector.BoxType boxType
43 return this.mode.boxType;
53 return this.mode.hitW;
63 return this.mode.hitH;
73 return this.hitW != 1 || this.hitH != 1;
83 if (!
Scene.HitPoint.IsValid)
87 if (this.start !=
null)
89 return Mathf.Abs(
Scene.HitPoint.x -
this.start.x) + 1;
101 if (!
Scene.HitPoint.IsValid)
105 if (this.start !=
null)
107 return Mathf.Abs(
Scene.HitPoint.z -
this.start.z) + 1;
114 public void OnChangeActionMode()
117 this.RefreshMouseInfo(
true);
121 public virtual void OnRenderTile(
Point point, HitResult result,
bool shouldHide)
126 public void OnUpdate()
131 this.RefreshMouseInfo(
true);
133 if (EInput.leftMouse.pressedLong &&
this.mode.AllowAutoClick)
135 this.autoClick =
true;
137 if (this.autoClick && !EInput.leftMouse.pressing)
139 this.autoClick =
false;
140 if (this.start !=
null)
142 this.mode.OnSelectEnd(
true);
144 this.RefreshSummary();
145 this.RefreshMouseInfo(
true);
148 if (this.autoClick && hitPoint.Distance(
this.lastClickPoint) > 1 &&
this.selectType ==
BaseTileSelector.SelectType.Multiple &&
this.start !=
null)
150 this.start = hitPoint.Copy();
151 this.mode.OnSelectStart(this.start);
152 this.RefreshMouseInfo(
true);
153 this.lastClickPoint.Set(hitPoint);
155 if (((EInput.rightScroll && EInput.rightMouse.clicked) || (!EInput.rightScroll && EInput.rightMouse.down) || Input.GetKeyDown(KeyCode.Escape)) && !
EMono.ui.wasActive)
157 if (this.selectType ==
BaseTileSelector.SelectType.Multiple &&
this.start !=
null)
159 this.mode.OnSelectEnd(
true);
161 this.RefreshSummary();
162 this.RefreshMouseInfo(
true);
166 this.mode.OnCancel();
168 EMono.ui.hud.hint.UpdateText();
170 if (!hitPoint.IsValid ||
EMono.ui.isPointerOverUI ||
EMono.ui.wasActive ||
this.mode.selectType ==
BaseTileSelector.SelectType.None || !
EMono.pc.ai.ShowCursor)
176 if (this.mode.IsFillMode())
183 this.ProcessTiles(this.start ?? hitPoint, hitPoint,
BaseTileSelector.ProcessMode.Render);
186 if (this.start ==
null && (this.mode.AreaHihlight == AreaHighlightMode.Edit ||
this.mode.AreaHihlight == AreaHighlightMode.Sim) && hitPoint.area !=
null)
188 hitPoint.area.OnHoverArea(
EMono.screen.guide.passArea);
190 if ((this.autoClick || EInput.leftMouse.down || (
this.mode.ContinuousClick && EInput.leftMouse.pressing)) &&
this.mode.CanSelectTile)
192 if (this.start !=
null || hitPoint.IsSeen)
194 if (this.mode.IsFillMode())
196 this.TryProcessTiles(hitPoint);
200 HitResult hitResult = this.mode._HitTest(this.temp, this.start);
201 if ((hitResult == HitResult.Valid || hitResult == HitResult.Warning) &&
this.mode.CanProcessTiles())
203 this.TryProcessTiles(hitPoint);
205 else if (!this.autoClick)
212 if (this.start ==
null)
214 this.start = hitPoint.Copy();
215 this.mode.OnSelectStart(this.start);
216 this.RefreshMouseInfo(
true);
219 this.TryProcessTiles(hitPoint);
224 this.TryProcessTiles(hitPoint);
228 this.start = hitPoint.Copy();
229 this.mode.OnSelectStart(this.start);
230 this.RefreshMouseInfo(
true);
234 this.lastClickPoint.Set(hitPoint);
235 EMono.ui.hud.hint.UpdateText();
240 public void TryProcessTiles(
Point _end)
242 if (EInput.skipFrame > 0)
246 if (!this.mode.CanProcessTiles())
248 if (!
EMono.screen.tileSelector.autoClick)
254 Point point = _end.Copy();
256 this.mode.OnBeforeProcessTiles();
257 if (this.mode.IsFillMode())
261 else if (this.start ==
null)
263 this.mode.OnProcessTiles(point, -1);
268 this.mode.OnSelectEnd(
false);
270 if (this.mode != mode)
274 this.mode.OnAfterProcessTiles(this.start, point);
276 this.ExecuteSummary();
277 this.RefreshMouseInfo(
true);
278 this.mode.OnFinishProcessTiles();
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;
290 int num4 = obj2 - num2 + 1;
291 int num5 = num3 - num + 1;
292 BaseTileSelector.BoxType boxType = this.boxType;
295 this.firstInMulti =
false;
298 num2 -= this.hitW - 1;
299 num3 += this.hitH - 1;
300 num4 += this.hitW - 1;
301 num5 += this.hitH - 1;
305 this.processing =
true;
307 for (
int i = obj2; i > num2 - 1; i--)
316 num6 = ((num4 > num5) ? 0 : 1);
317 if ((num6 != 0 || j == start.z) && (num6 != 1 || i == start.x))
326 if (start.x != i || start.z != j)
328 this._ProcessTile(start, this.temp, processMode, num6);
340 this.firstInMulti =
true;
341 this._ProcessTile(start, start, processMode, num6);
342 this.processing =
false;
350 if (!start.Equals(dest))
352 this._ProcessTile(start, dest, processMode, -1);
355 this._ProcessTile(start, start, processMode, -1);
365 HitResult hitResult = this.mode._HitTest(dest, start);
369 this.mode.OnRenderTile(dest, hitResult, dir);
370 this.firstInMulti =
false;
373 if (hitResult == HitResult.Valid || hitResult == HitResult.Warning)
375 this.mode.OnProcessTiles(dest, dir);
380 this.mode.OnRefreshSummary(dest, hitResult, this.summary);
388 public bool IsInRange(
int x,
int z,
Point end)
390 if (this.start.x > end.x)
392 if (x > this.start.x || x < end.x)
397 else if (x < this.start.x || x > end.x)
401 if (this.start.z > end.z)
403 if (z > this.start.z || z < end.z)
408 else if (z < this.start.z || z > end.z)
416 public unsafe
void RefreshMouseInfo(
bool force =
false)
420 if (
EMono.ui.IsActive ||
EMono.ui.isPointerOverUI || !
this.mode.enableMouseInfo || !hitPoint.IsValid)
424 else if (!hitPoint.Equals(
this.lastPoint) || force)
426 if (this.start !=
null && !hitPoint.Equals(
this.lastPoint))
428 SE.Play(
"highlight3");
430 this.RefreshSummary();
433 if (this.start !=
null)
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)
442 text =
string.Concat(
new string[]
454 text +=
"selectRange".lang();
458 num = this.mode.CostMoney;
460 else if (this.start !=
null)
462 num = this.summary.money;
464 EMono.ui.mouseInfo.textCost.SetActive(num != 0);
467 EMono.ui.mouseInfo.textCost.text = (num.ToString() ??
"");
469 if (this.mode.TopHeight(hitPoint) != -1)
471 text +=
"hintAltitude".lang(this.mode.TopHeight(hitPoint).ToString() ??
"",
null,
null,
null,
null);
478 text += result.GetText();
481 if (this.mode.IsRoofEditMode(
null))
483 text = text + Environment.NewLine +
"roofEdit".lang();
485 else if (this.mode.IsFillMode())
487 text = text + Environment.NewLine +
"fillMode".lang();
490 EMono.ui.mouseInfo.text.SetText(*this.mode.SetMouseInfo(ref text));
492 EMono.ui.mouseInfo.SetActive(enable);
493 this.lastPoint.Set(hitPoint);
497 public void ExecuteSummary()
503 this.summary.Execute();
505 this.RefreshSummary();
506 this.mode.SEExecuteSummary();
510 public void RefreshSummary()
513 this.summary.Clear();
514 this.ProcessTiles(this.start ?? hitPoint, hitPoint,
BaseTileSelector.ProcessMode.Summary);
517 BuildMenu.Instance.info1.RefreshBalance();
522 public BaseTileSelector.HitType inspectHitType;
525 public bool inspectorHighlight;
548 public bool processing;
552 public bool autoClick;
555 public bool firstInMulti;
558 public enum SelectType
593 public enum ProcessMode