12 public override BaseTileSelector.SelectType selectType
16 if (this.partialMap !=
null)
26 public override bool IsBuildMode
36 public override BuildMenu.Mode buildMenuMode
46 public override bool UseSubMenu
56 public override bool SubMenuAsGroup
66 public virtual AM_Copy.Mode mode
85 public override string OnSetSubMenuButton(
int a, UIButton b)
92 return "copyRelative";
96 public override void OnClickSubMenu(
int a)
102 public override HitResult HitTest(
Point point,
Point start)
104 if (!base.Summary.CanExecute())
106 return HitResult.Invalid;
108 if (this.partialMap ==
null)
110 using (List<Thing>.Enumerator enumerator = point.cell.Things.GetEnumerator())
112 while (enumerator.MoveNext())
114 if (!enumerator.Current.trait.CanCopyInBlueprint)
116 return HitResult.Warning;
120 return HitResult.Valid;
122 return HitResult.Valid;
126 public override void OnSelectStart(
Point point)
128 this.RefreshMenu(
false);
132 public override void OnSelectEnd(
bool cancel)
136 this.RefreshMenu(
true);
141 public override void OnAfterProcessTiles(
Point start,
Point end)
143 if (this.partialMap !=
null)
145 EClass.Sound.Play(
"build_area");
146 this.partialMap.editMode =
false;
147 this.partialMap.procedural =
true;
150 if (Input.GetKey(KeyCode.LeftShift))
152 this.partialMap.procedural =
true;
156 this.partialMap.editMode =
true;
159 this.partialMap.Apply(end,
PartialMap.ApplyMode.Apply);
164 allowRotate = Application.isEditor
166 int x = Mathf.Min(start.x, end.x);
167 int z = Mathf.Min(start.z, end.z);
168 int w = Mathf.Abs(start.x - end.x) + 1;
169 int h = Mathf.Abs(start.z - end.z) + 1;
170 this.partialMap.Save(x, z, w, h);
171 if (!this.overwritePath.IsEmpty())
173 File.Copy(
PartialMap.PathTemp,
this.overwritePath,
true);
175 this.overwritePath =
null;
176 this.partialMap =
null;
177 this.RefreshMenu(
true);
181 this.partialMap.localOffsetX = ((end.x > start.x) ? (start.x - end.x) : 0);
182 this.partialMap.localOffsetZ = ((end.z > start.z) ? (start.z - end.z) : 0);
183 this.RefreshMenu(
false);
184 if (this.mode ==
AM_Copy.Mode.Create)
186 UIScreenshot.Create().Activate(this.partialMap, this.dir,
new Action<PartialMap>(this.OnSave),
false);
194 public virtual void OnSave(
PartialMap _partial)
198 MapPiece.initialized =
false;
199 this.menu.RefreshCategory(
null);
201 this.menu.DestorySprites();
206 public override void OnRenderTile(
Point point, HitResult result,
int dir)
212 if (this.partialMap !=
null)
214 this.partialMap.Apply(point,
PartialMap.ApplyMode.Render);
217 base.OnRenderTile(point, result, dir);
222 public override int CostMoney
226 if (this.partialMap ==
null)
230 return this.partialMap.value;
235 public override void OnUpdateInput()
237 if (Input.GetKeyDown(KeyCode.K))
241 if (Input.GetKeyDown(KeyCode.L))
243 this.ImportDialog(
null);
248 public override void RotateUnderMouse()
250 if (this.partialMap !=
null && this.partialMap.allowRotate)
252 this.partialMap.Rotate();
255 base.RotateUnderMouse();
261 this.partialMap.ClearMarkedCells();
262 this.partialMap =
null;
263 this.RefreshMenu(
true);
267 public override void OnCancel()
269 if (!this.overwritePath.IsEmpty())
271 this.overwritePath =
null;
272 SE.Play(
"actionMode");
273 this.RefreshMenu(
true);
276 if (this.mode ==
AM_Copy.Mode.Place)
285 if (this.partialMap !=
null)
288 SE.Play(
"actionMode");
295 public void Import(
string path)
298 this.RefreshMenu(
false);
302 public void ImportDialog(
string dir =
null)
304 EClass.core.WaitForEndOfFrame(delegate
306 string[] array = StandaloneFileBrowser.OpenFilePanel(
"Import Map Piece", dir ?? CorePath.MapPieceSaveUser,
"mp",
false);
307 if (array.Length != 0)
309 this.Import(array[0]);
315 public void RefreshMenu(
bool show)
319 this.menu.SetVisible(show);
320 BuildMenu.Instance.terrainMenu.SetActive(!show);
321 this.menu.buttonSave.SetActive(this.partialMap !=
null && this.partialMap.path.IsEmpty());
322 this.menu.buttonDelete.SetActive(this.partialMap !=
null && !this.partialMap.path.IsEmpty());
323 this.menu.buttonEdit.SetActive(this.partialMap !=
null && !this.partialMap.path.IsEmpty());
324 this.menu.buttonSave.SetOnClick(delegate
332 this.menu.buttonDelete.SetOnClick(delegate
334 Dialog.YesNo(
"dialog_deleteMapPiece", delegate
338 this.menu.DestorySprites();
341 },
null,
"yes",
"no");
343 this.menu.buttonEdit.SetOnClick(delegate
345 UIScreenshot.Create().Activate(this.partialMap, this.dir,
new Action<PartialMap>(this.OnSave),
true);
352 public override void OnActivate()
354 this.dir = (this.dirUser =
new DirectoryInfo(CorePath.MapPieceSaveUser));
355 if (this.mode ==
AM_Copy.Mode.Copy)
359 this.RefreshMenu(
true);
363 public override void OnDeactivate()
365 if (this.partialMap !=
null)
367 this.partialMap.ClearMarkedCells();
368 this.partialMap =
null;
372 this.menu.Deactivate();
374 if (Application.isEditor)
376 MapPiece.initialized =
false;
381 public string overwritePath;
387 public DirectoryInfo dir;
390 public DirectoryInfo dirUser;