Elin Modding Docs Doc
Loading...
Searching...
No Matches
AM_Copy.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4using SFB;
5using UnityEngine;
6
7// Token: 0x02000145 RID: 325
9{
10 // Token: 0x17000228 RID: 552
11 // (get) Token: 0x0600091A RID: 2330 RVA: 0x000394DD File Offset: 0x000376DD
12 public override BaseTileSelector.SelectType selectType
13 {
14 get
15 {
16 if (this.partialMap != null)
17 {
18 return BaseTileSelector.SelectType.Single;
19 }
20 return BaseTileSelector.SelectType.Multiple;
21 }
22 }
23
24 // Token: 0x17000229 RID: 553
25 // (get) Token: 0x0600091B RID: 2331 RVA: 0x000394EA File Offset: 0x000376EA
26 public override bool IsBuildMode
27 {
28 get
29 {
30 return true;
31 }
32 }
33
34 // Token: 0x1700022A RID: 554
35 // (get) Token: 0x0600091C RID: 2332 RVA: 0x000394ED File Offset: 0x000376ED
36 public override BuildMenu.Mode buildMenuMode
37 {
38 get
39 {
40 return BuildMenu.Mode.PartialMap;
41 }
42 }
43
44 // Token: 0x1700022B RID: 555
45 // (get) Token: 0x0600091D RID: 2333 RVA: 0x000394F0 File Offset: 0x000376F0
46 public override bool UseSubMenu
47 {
48 get
49 {
50 return true;
51 }
52 }
53
54 // Token: 0x1700022C RID: 556
55 // (get) Token: 0x0600091E RID: 2334 RVA: 0x000394F3 File Offset: 0x000376F3
56 public override bool SubMenuAsGroup
57 {
58 get
59 {
60 return false;
61 }
62 }
63
64 // Token: 0x1700022D RID: 557
65 // (get) Token: 0x0600091F RID: 2335 RVA: 0x000394F6 File Offset: 0x000376F6
66 public virtual AM_Copy.Mode mode
67 {
68 get
69 {
70 return AM_Copy.Mode.Copy;
71 }
72 }
73
74 // Token: 0x1700022E RID: 558
75 // (get) Token: 0x06000920 RID: 2336 RVA: 0x000394F9 File Offset: 0x000376F9
76 public PartialMapMenu menu
77 {
78 get
79 {
80 return PartialMapMenu.Instance;
81 }
82 }
83
84 // Token: 0x06000921 RID: 2337 RVA: 0x00039500 File Offset: 0x00037700
85 public override string OnSetSubMenuButton(int a, UIButton b)
86 {
87 if (a != 0)
88 {
89 return null;
90 }
91 b.SetCheck(PartialMap.relative);
92 return "copyRelative";
93 }
94
95 // Token: 0x06000922 RID: 2338 RVA: 0x00039517 File Offset: 0x00037717
96 public override void OnClickSubMenu(int a)
97 {
98 PartialMap.relative = !PartialMap.relative;
99 }
100
101 // Token: 0x06000923 RID: 2339 RVA: 0x00039528 File Offset: 0x00037728
102 public override HitResult HitTest(Point point, Point start)
103 {
104 if (!base.Summary.CanExecute())
105 {
106 return HitResult.Invalid;
107 }
108 if (this.partialMap == null)
109 {
110 using (List<Thing>.Enumerator enumerator = point.cell.Things.GetEnumerator())
111 {
112 while (enumerator.MoveNext())
113 {
114 if (!enumerator.Current.trait.CanCopyInBlueprint)
115 {
116 return HitResult.Warning;
117 }
118 }
119 }
120 return HitResult.Valid;
121 }
122 return HitResult.Valid;
123 }
124
125 // Token: 0x06000924 RID: 2340 RVA: 0x000395A4 File Offset: 0x000377A4
126 public override void OnSelectStart(Point point)
127 {
128 this.RefreshMenu(false);
129 }
130
131 // Token: 0x06000925 RID: 2341 RVA: 0x000395AD File Offset: 0x000377AD
132 public override void OnSelectEnd(bool cancel)
133 {
134 if (cancel)
135 {
136 this.RefreshMenu(true);
137 }
138 }
139
140 // Token: 0x06000926 RID: 2342 RVA: 0x000395BC File Offset: 0x000377BC
141 public override void OnAfterProcessTiles(Point start, Point end)
142 {
143 if (this.partialMap != null)
144 {
145 EClass.Sound.Play("build_area");
146 this.partialMap.editMode = false;
147 this.partialMap.procedural = true;
148 if (MapPiece.IsEditor)
149 {
150 if (Input.GetKey(KeyCode.LeftShift))
151 {
152 this.partialMap.procedural = true;
153 }
154 else
155 {
156 this.partialMap.editMode = true;
157 }
158 }
159 this.partialMap.Apply(end, PartialMap.ApplyMode.Apply);
160 return;
161 }
162 this.partialMap = new PartialMap
163 {
164 allowRotate = Application.isEditor
165 };
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())
172 {
173 File.Copy(PartialMap.PathTemp, this.overwritePath, true);
174 SE.Play("camera");
175 this.overwritePath = null;
176 this.partialMap = null;
177 this.RefreshMenu(true);
178 return;
179 }
180 this.partialMap = PartialMap.Load(null);
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)
185 {
186 UIScreenshot.Create().Activate(this.partialMap, this.dir, new Action<PartialMap>(this.OnSave), false);
187 this.Clear();
188 return;
189 }
190 SE.Click();
191 }
192
193 // Token: 0x06000927 RID: 2343 RVA: 0x00039783 File Offset: 0x00037983
194 public virtual void OnSave(PartialMap _partial)
195 {
196 if (MapPiece.IsEditor)
197 {
198 MapPiece.initialized = false;
199 this.menu.RefreshCategory(null);
200 }
201 this.menu.DestorySprites();
202 this.menu.Refresh();
203 }
204
205 // Token: 0x06000928 RID: 2344 RVA: 0x000397B4 File Offset: 0x000379B4
206 public override void OnRenderTile(Point point, HitResult result, int dir)
207 {
208 if (UIScreenshot.Instance)
209 {
210 return;
211 }
212 if (this.partialMap != null)
213 {
214 this.partialMap.Apply(point, PartialMap.ApplyMode.Render);
215 return;
216 }
217 base.OnRenderTile(point, result, dir);
218 }
219
220 // Token: 0x1700022F RID: 559
221 // (get) Token: 0x06000929 RID: 2345 RVA: 0x000397E2 File Offset: 0x000379E2
222 public override int CostMoney
223 {
224 get
225 {
226 if (this.partialMap == null)
227 {
228 return 0;
229 }
230 return this.partialMap.value;
231 }
232 }
233
234 // Token: 0x0600092A RID: 2346 RVA: 0x000397F9 File Offset: 0x000379F9
235 public override void OnUpdateInput()
236 {
237 if (Input.GetKeyDown(KeyCode.K))
238 {
239 PartialMap.ExportDialog(null);
240 }
241 if (Input.GetKeyDown(KeyCode.L))
242 {
243 this.ImportDialog(null);
244 }
245 }
246
247 // Token: 0x0600092B RID: 2347 RVA: 0x0003981A File Offset: 0x00037A1A
248 public override void RotateUnderMouse()
249 {
250 if (this.partialMap != null && this.partialMap.allowRotate)
251 {
252 this.partialMap.Rotate();
253 return;
254 }
255 base.RotateUnderMouse();
256 }
257
258 // Token: 0x0600092C RID: 2348 RVA: 0x00039843 File Offset: 0x00037A43
259 public void Clear()
260 {
261 this.partialMap.ClearMarkedCells();
262 this.partialMap = null;
263 this.RefreshMenu(true);
264 }
265
266 // Token: 0x0600092D RID: 2349 RVA: 0x00039860 File Offset: 0x00037A60
267 public override void OnCancel()
268 {
269 if (!this.overwritePath.IsEmpty())
270 {
271 this.overwritePath = null;
272 SE.Play("actionMode");
273 this.RefreshMenu(true);
274 return;
275 }
276 if (this.mode == AM_Copy.Mode.Place)
277 {
278 base.Deactivate();
279 return;
280 }
281 if (UIScreenshot.Instance)
282 {
283 return;
284 }
285 if (this.partialMap != null)
286 {
287 this.Clear();
288 SE.Play("actionMode");
289 return;
290 }
291 base.Deactivate();
292 }
293
294 // Token: 0x0600092E RID: 2350 RVA: 0x000398CF File Offset: 0x00037ACF
295 public void Import(string path)
296 {
297 this.partialMap = PartialMap.Load(path);
298 this.RefreshMenu(false);
299 }
300
301 // Token: 0x0600092F RID: 2351 RVA: 0x000398E4 File Offset: 0x00037AE4
302 public void ImportDialog(string dir = null)
303 {
304 EClass.core.WaitForEndOfFrame(delegate
305 {
306 string[] array = StandaloneFileBrowser.OpenFilePanel("Import Map Piece", dir ?? CorePath.MapPieceSaveUser, "mp", false);
307 if (array.Length != 0)
308 {
309 this.Import(array[0]);
310 }
311 });
312 }
313
314 // Token: 0x06000930 RID: 2352 RVA: 0x0003991C File Offset: 0x00037B1C
315 public void RefreshMenu(bool show)
316 {
317 if (this.menu)
318 {
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
325 {
326 UIScreenshot.Create().Activate(this.partialMap, this.dir, delegate(PartialMap a)
327 {
328 this.OnSave(a);
329 this.Clear();
330 }, false);
331 });
332 this.menu.buttonDelete.SetOnClick(delegate
333 {
334 Dialog.YesNo("dialog_deleteMapPiece", delegate
335 {
336 SE.Trash();
337 PartialMap.Delete(this.partialMap.path);
338 this.menu.DestorySprites();
339 this.menu.Refresh();
340 this.Clear();
341 }, null, "yes", "no");
342 });
343 this.menu.buttonEdit.SetOnClick(delegate
344 {
345 UIScreenshot.Create().Activate(this.partialMap, this.dir, new Action<PartialMap>(this.OnSave), true);
346 this.Clear();
347 });
348 }
349 }
350
351 // Token: 0x06000931 RID: 2353 RVA: 0x00039A34 File Offset: 0x00037C34
352 public override void OnActivate()
353 {
354 this.dir = (this.dirUser = new DirectoryInfo(CorePath.MapPieceSaveUser));
355 if (this.mode == AM_Copy.Mode.Copy)
356 {
357 PartialMapMenu.Activate();
358 }
359 this.RefreshMenu(true);
360 }
361
362 // Token: 0x06000932 RID: 2354 RVA: 0x00039A70 File Offset: 0x00037C70
363 public override void OnDeactivate()
364 {
365 if (this.partialMap != null)
366 {
367 this.partialMap.ClearMarkedCells();
368 this.partialMap = null;
369 }
370 if (this.menu)
371 {
372 this.menu.Deactivate();
373 }
374 if (Application.isEditor)
375 {
376 MapPiece.initialized = false;
377 }
378 }
379
380 // Token: 0x040008E2 RID: 2274
381 public string overwritePath;
382
383 // Token: 0x040008E3 RID: 2275
384 public PartialMap partialMap;
385
386 // Token: 0x040008E4 RID: 2276
387 public DirectoryInfo dir;
388
389 // Token: 0x040008E5 RID: 2277
390 public DirectoryInfo dirUser;
391
392 // Token: 0x02000866 RID: 2150
393 public enum Mode
394 {
395 // Token: 0x040023F4 RID: 9204
396 Copy,
397 // Token: 0x040023F5 RID: 9205
398 Place,
399 // Token: 0x040023F6 RID: 9206
400 Create
401 }
402}
Definition Point.cs:11