Elin Modding Docs Doc
Loading...
Searching...
No Matches
Map.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using System.Runtime.CompilerServices;
6using System.Runtime.Serialization;
7using Algorithms;
8using FloodSpill;
9using Ionic.Zip;
10using Newtonsoft.Json;
11using UnityEngine;
12
13// Token: 0x0200068C RID: 1676
15{
16 // Token: 0x17000D5F RID: 3423
17 // (get) Token: 0x06002EF6 RID: 12022 RVA: 0x00107261 File Offset: 0x00105461
18 // (set) Token: 0x06002EF7 RID: 12023 RVA: 0x0010726F File Offset: 0x0010546F
19 public bool isBreakerDown
20 {
21 get
22 {
23 return this.bits[0];
24 }
25 set
26 {
27 this.bits[0] = value;
28 }
29 }
30
31 // Token: 0x17000D60 RID: 3424
32 // (get) Token: 0x06002EF8 RID: 12024 RVA: 0x0010727E File Offset: 0x0010547E
33 public PropsStocked Stocked
34 {
35 get
36 {
37 return this.props.stocked;
38 }
39 }
40
41 // Token: 0x17000D61 RID: 3425
42 // (get) Token: 0x06002EF9 RID: 12025 RVA: 0x0010728B File Offset: 0x0010548B
43 public PropsInstalled Installed
44 {
45 get
46 {
47 return this.props.installed;
48 }
49 }
50
51 // Token: 0x17000D62 RID: 3426
52 // (get) Token: 0x06002EFA RID: 12026 RVA: 0x00107298 File Offset: 0x00105498
53 public PropsRoaming Roaming
54 {
55 get
56 {
57 return this.props.roaming;
58 }
59 }
60
61 // Token: 0x17000D63 RID: 3427
62 // (get) Token: 0x06002EFB RID: 12027 RVA: 0x001072A5 File Offset: 0x001054A5
63 public float sizeModifier
64 {
65 get
66 {
67 return 1f / (16384f / (float)this.SizeXZ);
68 }
69 }
70
71 // Token: 0x17000D64 RID: 3428
72 // (get) Token: 0x06002EFC RID: 12028 RVA: 0x001072BA File Offset: 0x001054BA
73 public bool isGenerated
74 {
75 get
76 {
77 return this.Size != 0;
78 }
79 }
80
81 // Token: 0x17000D65 RID: 3429
82 // (get) Token: 0x06002EFD RID: 12029 RVA: 0x001072C5 File Offset: 0x001054C5
83 public bool IsIndoor
84 {
85 get
86 {
87 return this.config.indoor;
88 }
89 }
90
91 // Token: 0x17000D66 RID: 3430
92 // (get) Token: 0x06002EFE RID: 12030 RVA: 0x001072D2 File Offset: 0x001054D2
93 public int SizeXZ
94 {
95 get
96 {
97 return this.Size * this.Size;
98 }
99 }
100
101 // Token: 0x17000D67 RID: 3431
102 // (get) Token: 0x06002EFF RID: 12031 RVA: 0x001072E1 File Offset: 0x001054E1
103 public IEnumerable<Card> Cards
104 {
105 get
106 {
107 return this.things.Concat(this.charas);
108 }
109 }
110
111 // Token: 0x06002F00 RID: 12032 RVA: 0x001072F4 File Offset: 0x001054F4
112 [OnSerializing]
113 private void OnSerializing(StreamingContext context)
114 {
115 this._bits = (int)this.bits.Bits;
116 }
117
118 // Token: 0x06002F01 RID: 12033 RVA: 0x00107307 File Offset: 0x00105507
119 protected virtual void OnSerializing()
120 {
121 }
122
123 // Token: 0x06002F02 RID: 12034 RVA: 0x00107309 File Offset: 0x00105509
124 [OnDeserialized]
125 private void OnDeserialized(StreamingContext context)
126 {
127 this.bits.Bits = (uint)this._bits;
128 }
129
130 // Token: 0x06002F04 RID: 12036 RVA: 0x00107418 File Offset: 0x00105618
131 public void CreateNew(int size, bool setReference = true)
132 {
133 Debug.Log("Map CreateNew:");
134 this.Size = size;
135 this.cells = new Cell[this.Size, this.Size];
136 this.bounds = new MapBounds
137 {
138 x = 0,
139 z = 0,
140 maxX = this.Size - 1,
141 maxZ = this.Size - 1,
142 Size = this.Size
143 };
144 base.SetBounds(0, 0, this.Size - 1, this.Size - 1);
145 this.ForeachXYZ(delegate(int x, int z)
146 {
147 this.cells[x, z] = new Cell
148 {
149 x = (byte)x,
150 z = (byte)z
151 };
152 });
153 if (setReference)
154 {
155 this.SetReference();
156 }
157 }
158
159 // Token: 0x06002F05 RID: 12037 RVA: 0x001074C4 File Offset: 0x001056C4
160 public void SetZone(Zone _zone)
161 {
162 this.zone = _zone;
163 this.zone.bounds = this.bounds;
164 this.bounds.Size = this.Size;
165 this.SetReference();
166 this.props.Init();
167 EClass.scene.profile = SceneProfile.Load(this.config.idSceneProfile.IsEmpty("default"));
168 if (!this.config.idFowProfile.IsEmpty())
169 {
170 this.fowProfile = FowProfile.Load(this.config.idFowProfile);
171 }
172 }
173
174 // Token: 0x06002F06 RID: 12038 RVA: 0x00107558 File Offset: 0x00105758
175 public void SetReference()
176 {
177 CellDetail.map = this;
178 Point.map = this;
179 Wall.map = this;
180 Cell.map = this;
181 Fov.map = this;
182 Cell.Size = this.Size;
183 Cell.cells = this.cells;
184 IPathfinder pathfinder = PathManager.Instance.pathfinder;
185 WeightCell[,] weightMap = this.cells;
186 pathfinder.Init(this, weightMap, this.Size);
187 }
188
189 // Token: 0x06002F07 RID: 12039 RVA: 0x001075B8 File Offset: 0x001057B8
190 public void OnDeactivate()
191 {
192 this.charas.ForeachReverse(delegate(Chara c)
193 {
194 c.ai = new NoGoal();
195 if (c.IsGlobal)
196 {
197 this.zone.RemoveCard(c);
198 c.currentZone = this.zone;
199 }
200 });
201 foreach (Thing thing in this.things)
202 {
203 if (thing.renderer.hasActor)
204 {
205 thing.renderer.KillActor();
206 }
207 }
208 EClass.player.ClearMapHighlights();
209 }
210
211 // Token: 0x06002F08 RID: 12040 RVA: 0x00107640 File Offset: 0x00105840
212 public void Resize(int newSize)
213 {
214 Point p = new Point(0, 0);
215 foreach (Thing thing in EClass._map.things)
216 {
217 if (thing.pos.x >= newSize || thing.pos.z >= newSize)
218 {
219 this.MoveCard(p, thing);
220 }
221 }
222 foreach (Chara chara in EClass._map.charas)
223 {
224 if (chara.pos.x >= newSize || chara.pos.z >= newSize)
225 {
226 this.MoveCard(p, chara);
227 }
228 }
229 this.bounds.Size = newSize;
230 this.Size = newSize;
231 this.maxX = (this.maxZ = this.Size);
232 this.cells = Util.ResizeArray<Cell>(EClass._map.cells, newSize, newSize, (int x, int y) => new Cell
233 {
234 x = (byte)x,
235 z = (byte)y,
236 isSeen = true
237 });
238 this.Reload();
239 }
240
241 // Token: 0x06002F09 RID: 12041 RVA: 0x00107790 File Offset: 0x00105990
242 public void Shift(Vector2Int offset)
243 {
244 TweenUtil.Tween(0.1f, null, delegate()
245 {
246 foreach (Card card in EClass._map.things.Concat(EClass._map.charas))
247 {
248 card.pos.x += offset.x;
249 card.pos.z += offset.y;
250 card.pos.Clamp(false);
251 }
252 Cell[,] array = new Cell[this.Size, this.Size];
253 for (int i = 0; i < this.Size; i++)
254 {
255 int num = i - offset.y;
256 for (int j = 0; j < this.Size; j++)
257 {
258 int num2 = j - offset.x;
259 if (num2 >= 0 && num2 < this.Size && num >= 0 && num < this.Size)
260 {
261 array[j, i] = this.cells[num2, num];
262 }
263 else
264 {
265 array[j, i] = new Cell
266 {
267 x = (byte)j,
268 z = (byte)i
269 };
270 }
271 }
272 }
273 this.cells = array;
274 this.bounds.x += offset.x;
275 this.bounds.z += offset.y;
276 this.bounds.maxX += offset.x;
277 this.bounds.maxZ += offset.y;
278 if (this.bounds.x < 0)
279 {
280 this.bounds.x = 0;
281 }
282 if (this.bounds.z < 0)
283 {
284 this.bounds.z = 0;
285 }
286 if (this.bounds.maxX > this.Size)
287 {
288 this.bounds.maxX = this.Size;
289 }
290 if (this.bounds.maxZ > this.Size)
291 {
292 this.bounds.maxZ = this.Size;
293 }
294 this.Reload();
295 });
296 }
297
298 // Token: 0x06002F0A RID: 12042 RVA: 0x001077CC File Offset: 0x001059CC
299 public void Reload()
300 {
301 this.rooms = new RoomManager();
302 this.SetReference();
303 string id = Game.id;
304 EClass.game.Save(false, null, false);
305 EClass.scene.Init(Scene.Mode.None);
306 Game.Load(id);
307 this.RevealAll(true);
308 TweenUtil.Tween(0.1f, null, delegate()
309 {
310 this.ReloadRoom();
311 });
312 }
313
314 // Token: 0x06002F0B RID: 12043 RVA: 0x0010782C File Offset: 0x00105A2C
315 public void ReloadRoom()
316 {
317 List<Thing> list = new List<Thing>();
318 foreach (Thing thing in this.things)
319 {
320 if (thing.trait.IsDoor)
321 {
322 list.Add(thing);
323 }
324 }
325 foreach (Thing thing2 in list)
326 {
327 Point pos = thing2.pos;
328 EClass._zone.RemoveCard(thing2);
329 EClass._zone.AddCard(thing2, pos);
330 thing2.Install();
331 }
332 this.rooms.RefreshAll();
333 }
334
335 // Token: 0x06002F0C RID: 12044 RVA: 0x001078FC File Offset: 0x00105AFC
336 public void Reset()
337 {
338 for (int i = 0; i < this.Size; i++)
339 {
340 for (int j = 0; j < this.Size; j++)
341 {
342 this.cells[i, j].Reset();
343 }
344 }
345 this.SetReference();
346 }
347
348 // Token: 0x06002F0D RID: 12045 RVA: 0x00107944 File Offset: 0x00105B44
349 public void ResetEditorPos()
350 {
351 EClass._zone.Revive();
352 foreach (Chara chara in this.charas)
353 {
354 if (chara.isPlayerCreation && chara.orgPos != null)
355 {
356 this.MoveCard(chara.orgPos, chara);
357 }
358 }
359 foreach (Thing thing in this.things)
360 {
361 if (thing.trait is TraitDoor)
362 {
363 (thing.trait as TraitDoor).ForceClose();
364 }
365 }
366 }
367
368 // Token: 0x06002F0E RID: 12046 RVA: 0x00107A10 File Offset: 0x00105C10
369 public void Save(string path, ZoneExportData export = null, PartialMap partial = null)
370 {
371 this.version = EClass.core.version;
372 Debug.Log("#io saving map:" + path);
373 IO.CreateDirectory(path);
374 int num = 0;
375 int num2 = 0;
376 int num3 = this.Size;
377 int num4 = this.Size;
378 if (partial != null)
379 {
380 num = partial.offsetX;
381 num2 = partial.offsetZ;
382 num3 = partial.w;
383 num4 = partial.h;
384 }
385 int num5 = num3 * num4;
386 byte[] array = new byte[num5];
387 byte[] array2 = new byte[num5];
388 byte[] array3 = new byte[num5];
389 byte[] array4 = new byte[num5];
390 byte[] array5 = new byte[num5];
391 byte[] array6 = new byte[num5];
392 byte[] array7 = new byte[num5];
393 byte[] array8 = new byte[num5];
394 byte[] array9 = new byte[num5];
395 byte[] array10 = new byte[num5];
396 byte[] array11 = new byte[num5];
397 byte[] array12 = new byte[num5];
398 byte[] array13 = new byte[num5];
399 byte[] array14 = new byte[num5];
400 byte[] array15 = new byte[num5];
401 byte[] array16 = new byte[num5];
402 byte[] array17 = new byte[num5];
403 byte[] array18 = new byte[num5];
404 byte[] array19 = new byte[num5];
405 this.cellEffects.Clear();
406 int num6 = 0;
407 for (int i = num; i < num + num3; i++)
408 {
409 for (int j = num2; j < num2 + num4; j++)
410 {
411 Cell cell = this.cells[i, j];
412 array[num6] = cell.objVal;
413 array3[num6] = cell._blockMat;
414 array2[num6] = cell._block;
415 array5[num6] = cell._floorMat;
416 array4[num6] = cell._floor;
417 array6[num6] = cell.obj;
418 array7[num6] = cell.objMat;
419 array8[num6] = cell.decal;
420 array9[num6] = cell._dirs;
421 array12[num6] = cell.height;
422 array13[num6] = cell._bridge;
423 array14[num6] = cell._bridgeMat;
424 array15[num6] = cell.bridgeHeight;
425 array17[num6] = cell._roofBlockDir;
426 array18[num6] = cell._roofBlock;
427 array19[num6] = cell._roofBlockMat;
428 array16[num6] = cell.bridgePillar;
429 array10[num6] = array10[num6].SetBit(1, cell.isSeen);
430 array10[num6] = array10[num6].SetBit(2, cell.isHarvested);
431 array10[num6] = array10[num6].SetBit(3, cell.impassable);
432 array10[num6] = array10[num6].SetBit(4, cell.isModified);
433 array10[num6] = array10[num6].SetBit(5, cell.isClearSnow);
434 array10[num6] = array10[num6].SetBit(6, cell.isForceFloat);
435 array10[num6] = array10[num6].SetBit(7, cell.isToggleWallPillar);
436 array11[num6] = array11[num6].SetBit(0, cell.isWatered);
437 array11[num6] = array11[num6].SetBit(1, cell.isObjDyed);
438 if (cell.effect != null)
439 {
440 this.cellEffects[j * num4 + i] = cell.effect;
441 }
442 num6++;
443 }
444 }
445 IO.WriteLZ4(path + "objVals", array);
446 IO.WriteLZ4(path + "blocks", array2);
447 IO.WriteLZ4(path + "blockMats", array3);
448 IO.WriteLZ4(path + "floors", array4);
449 IO.WriteLZ4(path + "floorMats", array5);
450 IO.WriteLZ4(path + "objs", array6);
451 IO.WriteLZ4(path + "objMats", array7);
452 IO.WriteLZ4(path + "decal", array8);
453 IO.WriteLZ4(path + "flags", array10);
454 IO.WriteLZ4(path + "flags2", array11);
455 IO.WriteLZ4(path + "dirs", array9);
456 IO.WriteLZ4(path + "heights", array12);
457 IO.WriteLZ4(path + "bridges", array13);
458 IO.WriteLZ4(path + "bridgeMats", array14);
459 IO.WriteLZ4(path + "bridgeHeights", array15);
460 IO.WriteLZ4(path + "bridgePillars", array16);
461 IO.WriteLZ4(path + "roofBlocks", array18);
462 IO.WriteLZ4(path + "roofBlockMats", array19);
463 IO.WriteLZ4(path + "roofBlockDirs", array17);
464 this.things.Sort((Thing a, Thing b) => a.stackOrder - b.stackOrder);
465 if (export == null)
466 {
467 foreach (Chara chara in this.charas)
468 {
469 if (!chara.IsGlobal)
470 {
471 this.serializedCharas.Add(chara);
472 }
473 }
474 GameIO.SaveFile(path + "map", this);
475 }
476 else
477 {
478 export.serializedCards.cards.Clear();
479 if (partial == null)
480 {
481 foreach (Chara chara2 in this.charas)
482 {
483 if (export.usermap)
484 {
485 if (!chara2.trait.IsUnique && !chara2.IsPC)
486 {
487 export.serializedCards.Add(chara2);
488 }
489 }
490 else if (!chara2.IsGlobal && chara2.isPlayerCreation)
491 {
492 export.serializedCards.Add(chara2);
493 }
494 }
495 using (List<Thing>.Enumerator enumerator2 = this.things.GetEnumerator())
496 {
497 while (enumerator2.MoveNext())
498 {
499 Thing thing = enumerator2.Current;
500 if (thing.isPlayerCreation && thing.c_altName != "DebugContainer")
501 {
502 export.serializedCards.Add(thing);
503 }
504 }
505 goto IL_66C;
506 }
507 }
508 foreach (Thing thing2 in this.things)
509 {
510 if ((ActionMode.Copy.IsActive || thing2.trait.CanCopyInBlueprint) && thing2.pos.x >= num && thing2.pos.z >= num2 && thing2.pos.x < num + num3 && thing2.pos.z < num2 + num4)
511 {
512 export.serializedCards.Add(thing2);
513 }
514 }
515 IL_66C:
516 List<Thing> list = this.things;
517 this.things = new List<Thing>();
518 GameIO.SaveFile(path + "map", this);
519 this.things = list;
520 }
521 this.serializedCharas.Clear();
522 }
523
524 // Token: 0x06002F0F RID: 12047 RVA: 0x001080F4 File Offset: 0x001062F4
525 public void Load(string path, bool import = false, PartialMap partial = null)
526 {
527 Map.<>c__DisplayClass67_0 CS$<>8__locals1 = new Map.<>c__DisplayClass67_0();
528 CS$<>8__locals1.path = path;
529 CS$<>8__locals1.<>4__this = this;
530 if (partial == null)
531 {
532 Debug.Log("Map Load:" + CS$<>8__locals1.path);
533 }
534 int num = this.Size;
535 int num2 = this.Size;
536 if (partial != null)
537 {
538 num = partial.w;
539 num2 = partial.h;
540 Debug.Log(num.ToString() + "/" + num2.ToString());
541 }
542 CS$<>8__locals1.size = num * num2;
543 this.cells = new Cell[num, num2];
544 if (this.bounds.maxX == 0)
545 {
546 this.bounds.SetBounds(0, 0, num - 1, num2 - 1);
547 }
548 base.SetBounds(0, 0, num - 1, num2 - 1);
549 byte[] array = CS$<>8__locals1.<Load>g__TryLoad|0("objVals");
550 byte[] array2 = CS$<>8__locals1.<Load>g__TryLoad|0("blockMats");
551 byte[] array3 = CS$<>8__locals1.<Load>g__TryLoad|0("blocks");
552 byte[] array4 = CS$<>8__locals1.<Load>g__TryLoad|0("floorMats");
553 byte[] array5 = CS$<>8__locals1.<Load>g__TryLoad|0("floors");
554 byte[] array6 = CS$<>8__locals1.<Load>g__TryLoad|0("objs");
555 byte[] array7 = CS$<>8__locals1.<Load>g__TryLoad|0("objMats");
556 byte[] array8 = CS$<>8__locals1.<Load>g__TryLoad|0("decal");
557 byte[] array9 = CS$<>8__locals1.<Load>g__TryLoad|0("dirs");
558 byte[] array10 = CS$<>8__locals1.<Load>g__TryLoad|0("flags");
559 byte[] array11 = CS$<>8__locals1.<Load>g__TryLoad|0("flags2");
560 byte[] array12 = CS$<>8__locals1.<Load>g__TryLoad|0("heights");
561 byte[] array13 = CS$<>8__locals1.<Load>g__TryLoad|0("bridges");
562 byte[] array14 = CS$<>8__locals1.<Load>g__TryLoad|0("bridgeMats");
563 byte[] array15 = CS$<>8__locals1.<Load>g__TryLoad|0("bridgeHeights");
564 byte[] array16 = CS$<>8__locals1.<Load>g__TryLoad|0("bridgePillars");
565 byte[] array17 = CS$<>8__locals1.<Load>g__TryLoad|0("roofBlocks");
566 byte[] array18 = CS$<>8__locals1.<Load>g__TryLoad|0("roofBlockMats");
567 byte[] array19 = CS$<>8__locals1.<Load>g__TryLoad|0("roofBlockDirs");
568 if (array16.Length < CS$<>8__locals1.size)
569 {
570 array16 = new byte[CS$<>8__locals1.size];
571 }
572 if (array.Length < CS$<>8__locals1.size)
573 {
574 array = new byte[CS$<>8__locals1.size];
575 }
576 if (array11.Length < CS$<>8__locals1.size)
577 {
578 array11 = new byte[CS$<>8__locals1.size];
579 }
580 CS$<>8__locals1.<Load>g__Validate|1(ref array, "objVals");
581 CS$<>8__locals1.<Load>g__Validate|1(ref array2, "blockMats");
582 CS$<>8__locals1.<Load>g__Validate|1(ref array3, "blocks");
583 CS$<>8__locals1.<Load>g__Validate|1(ref array4, "floorMats");
584 CS$<>8__locals1.<Load>g__Validate|1(ref array5, "floors");
585 CS$<>8__locals1.<Load>g__Validate|1(ref array6, "objs");
586 CS$<>8__locals1.<Load>g__Validate|1(ref array7, "objMats");
587 CS$<>8__locals1.<Load>g__Validate|1(ref array8, "decal");
588 CS$<>8__locals1.<Load>g__Validate|1(ref array9, "dirs");
589 CS$<>8__locals1.<Load>g__Validate|1(ref array10, "flags");
590 CS$<>8__locals1.<Load>g__Validate|1(ref array11, "flags2");
591 CS$<>8__locals1.<Load>g__Validate|1(ref array12, "heights");
592 CS$<>8__locals1.<Load>g__Validate|1(ref array13, "bridges");
593 CS$<>8__locals1.<Load>g__Validate|1(ref array14, "bridgeMats");
594 CS$<>8__locals1.<Load>g__Validate|1(ref array15, "bridgeHeights");
595 CS$<>8__locals1.<Load>g__Validate|1(ref array16, "bridgePillars");
596 CS$<>8__locals1.<Load>g__Validate|1(ref array17, "roofBlocks");
597 CS$<>8__locals1.<Load>g__Validate|1(ref array18, "roofBlockMats");
598 CS$<>8__locals1.<Load>g__Validate|1(ref array19, "roofBlockDirs");
599 int num3 = 0;
600 for (int i = 0; i < num; i++)
601 {
602 for (int j = 0; j < num2; j++)
603 {
604 this.cells[i, j] = new Cell
605 {
606 x = (byte)i,
607 z = (byte)j,
608 objVal = array[num3],
609 _blockMat = array2[num3],
610 _block = array3[num3],
611 _floorMat = array4[num3],
612 _floor = array5[num3],
613 obj = array6[num3],
614 objMat = array7[num3],
615 decal = array8[num3],
616 _dirs = array9[num3],
617 height = array12[num3],
618 _bridge = array13[num3],
619 _bridgeMat = array14[num3],
620 bridgeHeight = array15[num3],
621 bridgePillar = array16[num3],
622 _roofBlock = array17[num3],
623 _roofBlockMat = array18[num3],
624 _roofBlockDir = array19[num3],
625 isSeen = array10[num3].GetBit(1),
626 isHarvested = array10[num3].GetBit(2),
627 impassable = array10[num3].GetBit(3),
628 isModified = array10[num3].GetBit(4),
629 isClearSnow = array10[num3].GetBit(5),
630 isForceFloat = array10[num3].GetBit(6),
631 isToggleWallPillar = array10[num3].GetBit(7),
632 isWatered = array11[num3].GetBit(0),
633 isObjDyed = array11[num3].GetBit(1)
634 };
635 Critter.RebuildCritter(this.cells[i, j]);
636 num3++;
637 }
638 }
639 this.things.ForeachReverse(delegate(Thing t)
640 {
641 if (t.Num <= 0 || t.isDestroyed)
642 {
643 Debug.Log(string.Concat(new string[]
644 {
645 "[bug] Removing bugged thing:",
646 t.Num.ToString(),
647 "/",
648 t.isDestroyed.ToString(),
649 "/",
650 (t != null) ? t.ToString() : null
651 }));
652 CS$<>8__locals1.<>4__this.things.Remove(t);
653 }
654 });
655 foreach (KeyValuePair<int, CellEffect> keyValuePair in this.cellEffects)
656 {
657 int key = keyValuePair.Key;
658 int num4 = key % this.Size;
659 int num5 = key / this.Size;
660 this.cells[num4, num5].effect = keyValuePair.Value;
661 if (keyValuePair.Value.IsFire)
662 {
663 this.effectManager.GetOrCreate(new Point(num4, num5));
664 }
665 }
666 this.cellEffects.Clear();
667 this.ValidateVersion();
668 }
669
670 // Token: 0x06002F10 RID: 12048 RVA: 0x00108668 File Offset: 0x00106868
671 public void ValidateVersion()
672 {
673 this.version = EClass.core.version;
674 }
675
676 // Token: 0x06002F11 RID: 12049 RVA: 0x0010867A File Offset: 0x0010687A
677 public void OnLoad()
678 {
679 this.rooms.OnLoad();
680 this.tasks.OnLoad();
681 }
682
683 // Token: 0x06002F12 RID: 12050 RVA: 0x00108692 File Offset: 0x00106892
684 public void OnImport(ZoneExportData data)
685 {
686 this.tasks = new TaskManager();
687 data.serializedCards.Restore(this, data.orgMap, false, null);
688 }
689
690 // Token: 0x06002F13 RID: 12051 RVA: 0x001086B4 File Offset: 0x001068B4
691 public void ExportMetaData(string _path, string id, PartialMap partial = null)
692 {
693 if (this.custom == null)
694 {
695 this.custom = new CustomData();
696 }
697 MapMetaData mapMetaData = new MapMetaData
698 {
699 name = EClass._zone.Name,
700 version = BaseCore.Instance.version.GetInt(),
701 partial = partial
702 };
703 CustomData customData = this.custom;
704 mapMetaData.id = id;
705 customData.id = id;
706 IO.SaveFile(_path + "meta", mapMetaData, false, null);
707 }
708
709 // Token: 0x06002F14 RID: 12052 RVA: 0x00108730 File Offset: 0x00106930
710 public static MapMetaData GetMetaData(string pathZip)
711 {
712 try
713 {
714 using (ZipFile zipFile = ZipFile.Read(pathZip))
715 {
716 ZipEntry zipEntry = zipFile["meta"];
717 if (zipEntry != null)
718 {
719 Debug.Log(zipEntry);
720 using (MemoryStream memoryStream = new MemoryStream())
721 {
722 zipEntry.Extract(memoryStream);
723 MapMetaData mapMetaData = IO.LoadStreamJson<MapMetaData>(memoryStream, null);
724 Debug.Log(mapMetaData);
725 mapMetaData.path = pathZip;
726 return mapMetaData;
727 }
728 }
729 }
730 }
731 catch (Exception message)
732 {
733 Debug.Log(message);
734 }
735 return null;
736 }
737
738 // Token: 0x06002F15 RID: 12053 RVA: 0x001087C8 File Offset: 0x001069C8
739 public static void UpdateMetaData(string pathZip, PartialMap partial = null)
740 {
741 IO.CreateTempDirectory(null);
742 ZipFile zipFile = ZipFile.Read(pathZip);
743 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
744 zipFile.ExtractAll(IO.TempPath);
745 zipFile.Dispose();
746 EClass._map.ExportMetaData(IO.TempPath + "/", Path.GetFileNameWithoutExtension(pathZip), partial);
747 ZipFile zipFile2;
748 zipFile = (zipFile2 = new ZipFile());
749 try
750 {
751 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
752 zipFile.AddDirectory(IO.TempPath);
753 zipFile.Save(pathZip);
754 zipFile.Dispose();
755 }
756 finally
757 {
758 if (zipFile2 != null)
759 {
760 ((IDisposable)zipFile2).Dispose();
761 }
762 }
763 IO.DeleteTempDirectory(null);
764 }
765
766 // Token: 0x06002F16 RID: 12054 RVA: 0x00108864 File Offset: 0x00106A64
767 public void AddCardOnActivate(Card c)
768 {
769 c.parent = this.zone;
770 this.props.OnCardAddedToZone(c);
771 Chara chara = c.Chara;
772 if (chara != null)
773 {
774 chara.currentZone = EClass._zone;
775 }
776 this._AddCard(c.pos.x, c.pos.z, c, true);
777 }
778
779 // Token: 0x06002F17 RID: 12055 RVA: 0x001088BC File Offset: 0x00106ABC
780 public void OnCardAddedToZone(Card t, int x, int z)
781 {
782 if (t.isChara)
783 {
784 this.charas.Add(t.Chara);
785 }
786 else
787 {
788 this.things.Add(t.Thing);
789 }
790 this.props.OnCardAddedToZone(t);
791 if (t.isChara && new Point(x, z).cell.HasFullBlock)
792 {
793 this.DestroyBlock(x, z);
794 }
795 this._AddCard(x, z, t, true);
796 t.trait.OnAddedToZone();
797 }
798
799 // Token: 0x06002F18 RID: 12056 RVA: 0x0010893C File Offset: 0x00106B3C
800 public void OnCardRemovedFromZone(Card t)
801 {
802 t.trait.OnRemovedFromZone();
803 t.SetPlaceState(PlaceState.none, false);
804 this._RemoveCard(t);
805 t.parent = null;
806 if (t.isChara)
807 {
808 this.charas.Remove(t.Chara);
809 return;
810 }
811 this.things.Remove(t.Thing);
812 }
813
814 // Token: 0x06002F19 RID: 12057 RVA: 0x00108997 File Offset: 0x00106B97
815 public void MoveCard(Point p, Card t)
816 {
817 this._AddCard(p.x, p.z, t, false);
818 }
819
820 // Token: 0x06002F1A RID: 12058 RVA: 0x001089B0 File Offset: 0x00106BB0
821 public void _AddCard(int x, int z, Card t, bool onAddToZone)
822 {
823 if (!onAddToZone)
824 {
825 this._RemoveCard(t);
826 }
827 t.pos.Set(x, z);
828 if (t.IsMultisize)
829 {
830 t.ForeachPoint(delegate(Point p, bool main)
831 {
832 p.cell.AddCard(t);
833 });
834 }
835 else
836 {
837 t.Cell.AddCard(t);
838 }
839 t.CalculateFOV();
840 if (t.isThing && !t.trait.IDActorEx.IsEmpty())
841 {
842 EClass.scene.AddActorEx(t, null);
843 }
844 }
845
846 // Token: 0x06002F1B RID: 12059 RVA: 0x00108A6C File Offset: 0x00106C6C
847 public void _RemoveCard(Card t)
848 {
849 if (t.IsMultisize)
850 {
851 t.ForeachPoint(delegate(Point p, bool main)
852 {
853 p.cell.RemoveCard(t);
854 });
855 }
856 else
857 {
858 t.Cell.RemoveCard(t);
859 }
860 t.ClearFOV();
861 }
862
863 // Token: 0x06002F1C RID: 12060 RVA: 0x00108ACD File Offset: 0x00106CCD
864 public Cell GetCell(int index)
865 {
866 return this.cells[index % this.Size, index % this.SizeXZ / this.Size];
867 }
868
869 // Token: 0x06002F1D RID: 12061 RVA: 0x00108AF4 File Offset: 0x00106CF4
870 public void SetSeen(int x, int z, bool seen = true, bool refresh = true)
871 {
872 if (this.cells[x, z].isSeen == seen)
873 {
874 return;
875 }
876 this.cells[x, z].isSeen = seen;
877 if (refresh)
878 {
879 WidgetMinimap.UpdateMap(x, z);
880 }
881 EClass._map.RefreshNeighborTiles(x, z);
882 }
883
884 // Token: 0x06002F1E RID: 12062 RVA: 0x00108B44 File Offset: 0x00106D44
885 public void RevealAll(bool reveal = true)
886 {
887 for (int i = 0; i < this.Size; i++)
888 {
889 for (int j = 0; j < this.Size; j++)
890 {
891 EClass._map.SetSeen(i, j, reveal, false);
892 }
893 }
894 this.revealed = !this.revealed;
895 WidgetMinimap.UpdateMap();
896 }
897
898 // Token: 0x06002F1F RID: 12063 RVA: 0x00108B98 File Offset: 0x00106D98
899 public void Reveal(Point center, int power = 100)
900 {
901 this.ForeachSphere(center.x, center.z, (float)(10 + power / 5), delegate(Point p)
902 {
903 if (EClass.rnd(power) >= Mathf.Min(p.Distance(center) * 10, power - 10))
904 {
905 EClass._map.SetSeen(p.x, p.z, true, true);
906 }
907 });
908 }
909
910 // Token: 0x06002F20 RID: 12064 RVA: 0x00108BF0 File Offset: 0x00106DF0
911 public void RefreshFOV(int x, int z, int radius = 6, bool recalculate = false)
912 {
913 this.ForeachSphere(x, z, (float)radius, delegate(Point p)
914 {
915 List<Card> list = p.ListCards(false);
916 if (recalculate)
917 {
918 using (List<Card>.Enumerator enumerator = list.GetEnumerator())
919 {
920 while (enumerator.MoveNext())
921 {
922 Card card = enumerator.Current;
923 card.RecalculateFOV();
924 }
925 return;
926 }
927 }
928 foreach (Card card2 in list)
929 {
930 card2.CalculateFOV();
931 }
932 });
933 }
934
935 // Token: 0x06002F21 RID: 12065 RVA: 0x00108C24 File Offset: 0x00106E24
936 public void RefreshFOVAll()
937 {
938 foreach (Card card in EClass._map.things.Concat(EClass._map.charas))
939 {
940 card.RecalculateFOV();
941 }
942 }
943
944 // Token: 0x06002F22 RID: 12066 RVA: 0x00108C84 File Offset: 0x00106E84
945 public void SetFloor(int x, int z, int idMat = 0, int idFloor = 0)
946 {
947 this.SetFloor(x, z, idMat, idFloor, 0);
948 }
949
950 // Token: 0x06002F23 RID: 12067 RVA: 0x00108C92 File Offset: 0x00106E92
951 public void SetFloor(int x, int z, int idMat, int idFloor, int dir)
952 {
953 Cell cell = this.cells[x, z];
954 cell._floorMat = (byte)idMat;
955 cell._floor = (byte)idFloor;
956 cell.floorDir = dir;
957 Critter.RebuildCritter(cell);
958 this.RefreshNeighborTiles(x, z);
959 }
960
961 // Token: 0x06002F24 RID: 12068 RVA: 0x00108CC8 File Offset: 0x00106EC8
962 public void SetBridge(int x, int z, int height = 0, int idMat = 0, int idBridge = 0, int dir = 0)
963 {
964 Cell cell = this.cells[x, z];
965 cell.bridgeHeight = (byte)height;
966 cell._bridgeMat = (byte)idMat;
967 cell._bridge = (byte)idBridge;
968 cell.bridgePillar = 0;
969 cell.floorDir = dir;
970 if (cell.room != null)
971 {
972 cell.room.SetDirty();
973 }
974 this.RefreshNeighborTiles(x, z);
975 }
976
977 // Token: 0x06002F25 RID: 12069 RVA: 0x00108D27 File Offset: 0x00106F27
978 public void SetRoofBlock(int x, int z, int idMat, int idBlock, int dir, int height)
979 {
980 Cell cell = this.cells[x, z];
981 cell._roofBlockMat = (byte)idMat;
982 cell._roofBlock = (byte)idBlock;
983 cell._roofBlockDir = (byte)(dir + height * 4);
984 this.RefreshSingleTile(x, z);
985 }
986
987 // Token: 0x06002F26 RID: 12070 RVA: 0x00108D5C File Offset: 0x00106F5C
988 public void SetBlock(int x, int z, int idMat = 0, int idBlock = 0)
989 {
990 this.SetBlock(x, z, idMat, idBlock, 0);
991 }
992
993 // Token: 0x06002F27 RID: 12071 RVA: 0x00108D6C File Offset: 0x00106F6C
994 public void SetBlock(int x, int z, int idMat, int idBlock, int dir)
995 {
996 Cell cell = this.cells[x, z];
997 bool hasFloodBlock = cell.HasFloodBlock;
998 cell._blockMat = (byte)idMat;
999 cell._block = (byte)idBlock;
1000 cell.blockDir = dir;
1001 if (cell.effect == null || !cell.effect.IsFire)
1002 {
1003 cell.effect = null;
1004 }
1005 cell.isToggleWallPillar = false;
1006 if (cell.room != null)
1007 {
1008 cell.room.SetDirty();
1009 }
1010 if (hasFloodBlock || cell.HasFloodBlock)
1011 {
1012 this.OnSetBlockOrDoor(x, z);
1013 }
1014 this.RefreshNeighborTiles(x, z);
1015 }
1016
1017 // Token: 0x06002F28 RID: 12072 RVA: 0x00108DF8 File Offset: 0x00106FF8
1018 public void OnSetBlockOrDoor(int x, int z)
1019 {
1020 new Point(x, z);
1021 this.TryRemoveRoom(x, z);
1022 if (x > 0)
1023 {
1024 this.TryRemoveRoom(x - 1, z);
1025 }
1026 if (x < this.Size - 1)
1027 {
1028 this.TryRemoveRoom(x + 1, z);
1029 }
1030 if (z > 0)
1031 {
1032 this.TryRemoveRoom(x, z - 1);
1033 }
1034 if (z < this.Size - 1)
1035 {
1036 this.TryRemoveRoom(x, z + 1);
1037 }
1038 if (x > 0 && z < this.Size - 1)
1039 {
1040 this.TryRemoveRoom(x - 1, z + 1);
1041 }
1042 this.roomHash.Clear();
1043 this.TryAddRoom(x, z);
1044 if (x > 0)
1045 {
1046 this.TryAddRoom(x - 1, z);
1047 }
1048 if (x < this.Size - 1)
1049 {
1050 this.TryAddRoom(x + 1, z);
1051 }
1052 if (z > 0)
1053 {
1054 this.TryAddRoom(x, z - 1);
1055 }
1056 if (z < this.Size - 1)
1057 {
1058 this.TryAddRoom(x, z + 1);
1059 }
1060 if (x > 0 && z < this.Size - 1)
1061 {
1062 this.TryAddRoom(x - 1, z + 1);
1063 }
1064 }
1065
1066 // Token: 0x06002F29 RID: 12073 RVA: 0x00108EEC File Offset: 0x001070EC
1067 public void TryRemoveRoom(int x, int z)
1068 {
1069 if (this.cells[x, z].HasFloodBlock)
1070 {
1071 return;
1072 }
1073 Room room = this.cells[x, z].room;
1074 if (room != null)
1075 {
1076 this.rooms.RemoveRoom(room);
1077 }
1078 }
1079
1080 // Token: 0x06002F2A RID: 12074 RVA: 0x00108F30 File Offset: 0x00107130
1081 public void TryAddRoom(int x, int z)
1082 {
1083 if (EClass._zone.DisableRooms)
1084 {
1085 return;
1086 }
1087 if (this.roomHash.Contains(x + z * this.Size) || this.cells[x, z].HasFloodBlock)
1088 {
1089 return;
1090 }
1091 FloodSpiller floodSpiller = this.flood;
1092 IFloodCell[,] array = this.cells;
1093 FloodSpiller.Result result = floodSpiller.SpillFlood(array, x, z);
1094 if (!result.IsValid)
1095 {
1096 return;
1097 }
1098 bool flag = false;
1099 foreach (IFloodCell floodCell in result.visited)
1100 {
1101 if (floodCell.hasDoor)
1102 {
1103 flag = true;
1104 break;
1105 }
1106 Cell cell = floodCell as Cell;
1107 if (cell.sourceBlock.tileType.IsFloodDoor || cell.Front.hasDoor || cell.Right.hasDoor || cell.FrontRight.hasDoor || cell.Back.hasDoor || cell.Left.hasDoor || cell.BackLeft.hasDoor)
1108 {
1109 flag = true;
1110 break;
1111 }
1112 }
1113 if (!flag && this.IsIndoor)
1114 {
1115 foreach (IFloodCell floodCell2 in result.visited)
1116 {
1117 Cell cell2 = floodCell2 as Cell;
1118 if (cell2.detail != null && cell2.detail.things.Count != 0)
1119 {
1120 foreach (Thing thing in cell2.detail.things)
1121 {
1122 if (thing.trait is TraitRoomPlate || thing.trait is TraitHouseBoard)
1123 {
1124 flag = true;
1125 break;
1126 }
1127 }
1128 if (flag)
1129 {
1130 break;
1131 }
1132 }
1133 }
1134 }
1135 if (!flag)
1136 {
1137 return;
1138 }
1139 Room room = this.rooms.AddRoom(new Room());
1140 foreach (IFloodCell floodCell3 in result.visited)
1141 {
1142 Cell cell3 = floodCell3 as Cell;
1143 byte x2 = cell3.x;
1144 byte z2 = cell3.z;
1145 room.AddPoint(new Point((int)x2, (int)z2));
1146 this.roomHash.Add((int)x2 + (int)z2 * this.Size);
1147 if (z2 > 0 && cell3.Front.HasFloodBlock && cell3.Front.room == null)
1148 {
1149 room.AddPoint(new Point((int)x2, (int)(z2 - 1)));
1150 this.roomHash.Add((int)x2 + (int)(z2 - 1) * this.Size);
1151 }
1152 if ((int)x2 < this.Size - 1 && cell3.Right.HasFloodBlock && cell3.Right.room == null)
1153 {
1154 room.AddPoint(new Point((int)(x2 + 1), (int)z2));
1155 this.roomHash.Add((int)(x2 + 1) + (int)z2 * this.Size);
1156 }
1157 if (z2 > 0 && (int)x2 < this.Size - 1 && cell3.FrontRight.HasFloodBlock && cell3.FrontRight.room == null)
1158 {
1159 room.AddPoint(new Point((int)(x2 + 1), (int)(z2 - 1)));
1160 this.roomHash.Add((int)(x2 + 1) + (int)(z2 - 1) * this.Size);
1161 }
1162 }
1163 }
1164
1165 // Token: 0x06002F2B RID: 12075 RVA: 0x00109300 File Offset: 0x00107500
1166 public void SetBlockDir(int x, int z, int dir)
1167 {
1168 Cell cell = this.cells[x, z];
1169 cell._block = (byte)cell.sourceBlock.id;
1170 cell.blockDir = dir;
1171 }
1172
1173 // Token: 0x06002F2C RID: 12076 RVA: 0x00109328 File Offset: 0x00107528
1174 public void ModFire(int x, int z, int amount)
1175 {
1176 Cell cell = this.cells[x, z];
1177 if (cell.IsTopWaterAndNoSnow)
1178 {
1179 return;
1180 }
1181 if (cell.effect == null && amount > 0)
1182 {
1183 SE.Play("fire");
1184 }
1185 CellEffect effect = cell.effect;
1186 int num = amount + ((effect != null) ? effect.FireAmount : 0);
1187 if (num > 20)
1188 {
1189 num = 20;
1190 }
1191 if (num <= 0)
1192 {
1193 cell.effect = null;
1194 return;
1195 }
1196 cell.effect = new CellEffect
1197 {
1198 id = 3,
1199 amount = num
1200 };
1201 this.effectManager.GetOrCreate(new Point(x, z));
1202 }
1203
1204 // Token: 0x06002F2D RID: 12077 RVA: 0x001093B8 File Offset: 0x001075B8
1205 public void TryShatter(Point pos, int ele, int power)
1206 {
1207 Element element = Element.Create(ele, 0);
1208 List<Card> list = new List<Card>();
1209 Map.<>c__DisplayClass99_0 CS$<>8__locals1;
1210 CS$<>8__locals1.fire = (ele == 910);
1211 bool fire = CS$<>8__locals1.fire;
1212 List<Card> list2 = pos.ListCards(false);
1213 if (CS$<>8__locals1.fire && (pos.cell.IsSnowTile || pos.cell.IsTopWater))
1214 {
1215 return;
1216 }
1217 foreach (Card card in list2)
1218 {
1219 if (card.ResistLvFrom(ele) < 3 && !(card.trait is TraitBlanket) && (EClass.rnd(3) != 0 || Map.<TryShatter>g__CanCook|99_0(card, ref CS$<>8__locals1)))
1220 {
1221 if (card.isThing && card.things.Count == 0)
1222 {
1223 list.Add(card);
1224 }
1225 else
1226 {
1227 Thing thing = (ele == 910) ? card.things.Find<TraitBlanketFireproof>() : card.things.Find<TraitBlanketColdproof>();
1228 if (thing != null)
1229 {
1230 thing.ModCharge(-1, false);
1231 if (pos.IsSync)
1232 {
1233 Msg.Say((pos.HasChara ? "blanketInv_" : "blanketGround_") + element.source.alias, thing, pos.FirstChara, null, null);
1234 }
1235 if (thing.c_charges <= 0)
1236 {
1237 thing.Die(element, null, AttackSource.None);
1238 }
1239 }
1240 else
1241 {
1242 foreach (Thing thing2 in card.things.List((Thing a) => a.things.Count == 0, false))
1243 {
1244 Card parentCard = thing2.parentCard;
1245 if (parentCard == null || (!(parentCard.trait is TraitChestMerchant) && !parentCard.HasEditorTag(EditorTag.PreciousContainer)))
1246 {
1247 list.Add(thing2);
1248 }
1249 }
1250 }
1251 }
1252 }
1253 }
1254 list.Shuffle<Card>();
1255 int num = 0;
1256 foreach (Card card2 in list)
1257 {
1258 if (card2.trait.CanBeDestroyed && !card2.category.IsChildOf("currency") && !(card2.trait is TraitDoor) && !(card2.trait is TraitFigure) && !(card2.trait is TraitTrainingDummy) && card2.rarity < Rarity.Legendary)
1259 {
1260 Card rootCard = card2.GetRootCard();
1261 if (!card2.IsEquipmentOrRanged || (EClass.rnd(4) == 0 && ((!card2.IsRangedWeapon && !card2.Thing.isEquipped) || !rootCard.IsPCFaction || EClass.rnd(4) == 0)))
1262 {
1263 if (EClass._zone.IsPCFaction && EClass.Branch.lv >= 3 && (!rootCard.isChara || rootCard.Chara.IsPCFaction))
1264 {
1265 if (pos.IsSync)
1266 {
1267 Msg.Say("damage_protectCore", card2, null, null, null);
1268 }
1269 }
1270 else
1271 {
1272 if (ele != 910)
1273 {
1274 if (ele == 911)
1275 {
1276 if (!card2.category.IsChildOf("drink") && EClass.rnd(5) == 0)
1277 {
1278 continue;
1279 }
1280 }
1281 }
1282 else
1283 {
1284 if (card2.isFireproof)
1285 {
1286 continue;
1287 }
1288 if (!card2.category.IsChildOf("book") && EClass.rnd(2) == 0)
1289 {
1290 continue;
1291 }
1292 }
1293 if (EClass.rnd(num * num) == 0)
1294 {
1295 bool flag = Map.<TryShatter>g__CanCook|99_0(card2, ref CS$<>8__locals1);
1296 string text = "";
1297 if (flag)
1298 {
1299 List<SourceThing.Row> list3 = new List<SourceThing.Row>();
1300 foreach (RecipeSource recipeSource in RecipeManager.list)
1301 {
1302 SourceThing.Row row = recipeSource.row as SourceThing.Row;
1303 if (row != null && !row.isOrigin && !row.components.IsEmpty() && row.components.Length < 3 && row.Category.IsChildOf("meal"))
1304 {
1305 if (!row.factory.IsEmpty())
1306 {
1307 string a2 = row.factory[0];
1308 if (a2 == "chopper" || a2 == "mixer" || a2 == "camppot" || a2 == "cauldron")
1309 {
1310 continue;
1311 }
1312 }
1313 if (row.components[0] == card2.id || row.components[0] == card2.sourceCard._origin)
1314 {
1315 list3.Add(row);
1316 }
1317 }
1318 }
1319 if (list3.Count > 0)
1320 {
1321 text = list3.RandomItem<SourceThing.Row>().id;
1322 }
1323 }
1324 if (flag && !text.IsEmpty())
1325 {
1326 card2.GetRoot();
1327 Thing thing3 = card2.Split(1);
1328 List<Thing> list4 = new List<Thing>();
1329 list4.Add(thing3);
1330 Thing thing4 = ThingGen.Create(text, -1, -1);
1331 CraftUtil.MakeDish(thing4, list4, 999);
1332 thing4.elements.ModBase(2, EClass.curve(power / 10, 50, 10, 75));
1333 if (pos.IsSync)
1334 {
1335 Msg.Say((rootCard == card2) ? "cook_groundItem" : "cook_invItem", thing3, rootCard, thing4.Name, null);
1336 }
1337 if (rootCard == card2)
1338 {
1339 EClass._zone.AddCard(thing4, card2.pos);
1340 }
1341 else if (rootCard.isChara)
1342 {
1343 rootCard.Chara.Pick(thing4, false, true);
1344 }
1345 else
1346 {
1347 rootCard.AddThing(thing4, true, -1, -1);
1348 }
1349 thing3.Destroy();
1350 }
1351 else
1352 {
1353 int num2 = EClass.rnd(card2.Num) / 2 + 1;
1354 if (card2.Num > num2)
1355 {
1356 Thing thing5 = card2.Split(num2);
1357 if (pos.IsSync)
1358 {
1359 Msg.Say((rootCard == card2) ? "damage_groundItem" : "damage_invItem", thing5, rootCard, null, null);
1360 }
1361 thing5.Destroy();
1362 }
1363 else
1364 {
1365 card2.Die(element, null, AttackSource.None);
1366 }
1367 }
1368 num++;
1369 }
1370 }
1371 }
1372 }
1373 }
1374 this._ValidateInstalled(pos.x, pos.z);
1375 }
1376
1377 // Token: 0x06002F2E RID: 12078 RVA: 0x00109A68 File Offset: 0x00107C68
1378 public void Burn(int x, int z, bool instant = false)
1379 {
1380 Cell cell = this.cells[x, z];
1381 Point sharedPoint = cell.GetSharedPoint();
1382 if ((instant || EClass.rnd(10) == 0) && cell.HasObj)
1383 {
1384 if (cell.sourceObj.tileType is TileTypeTree)
1385 {
1386 this.SetObj(x, z, cell.matObj_fixed.id, 59, 0, EClass.rnd(4));
1387 }
1388 else
1389 {
1390 this.SetObj(x, z, 0, 1, 0);
1391 if (EClass.rnd(2) == 0)
1392 {
1393 EClass._zone.AddCard(ThingGen.Create((EClass.rnd(2) == 0) ? "ash" : "ash2", -1, -1), sharedPoint);
1394 }
1395 }
1396 }
1397 if ((instant || EClass.rnd(5) == 0) && cell._block != 0 && cell._block != 96)
1398 {
1399 if (EClass.rnd(10) == 0 || !cell.sourceBlock.tileType.IsWall)
1400 {
1401 cell._block = 0;
1402 }
1403 else
1404 {
1405 cell._block = 96;
1406 }
1407 if (cell.room != null)
1408 {
1409 cell.room.SetDirty();
1410 }
1411 this.RefreshNeighborTiles(x, z);
1412 }
1413 if (instant || EClass.rnd(10) == 0)
1414 {
1415 if (EClass.rnd(4) != 0)
1416 {
1417 cell._floor = 49;
1418 }
1419 if (cell._bridge != 0 && EClass.rnd(5) != 0)
1420 {
1421 cell._bridge = 49;
1422 }
1423 }
1424 foreach (Card card in sharedPoint.ListCards(false))
1425 {
1426 if (card.isThing)
1427 {
1428 if (instant)
1429 {
1430 card.Destroy();
1431 EClass._zone.AddCard(ThingGen.Create((EClass.rnd(2) == 0) ? "ash" : "ash2", -1, -1), sharedPoint);
1432 }
1433 else
1434 {
1435 card.DamageHP(30, 910, 100, AttackSource.None, null, true);
1436 }
1437 }
1438 }
1439 if (instant)
1440 {
1441 cell.effect = null;
1442 }
1443 }
1444
1445 // Token: 0x06002F2F RID: 12079 RVA: 0x00109C38 File Offset: 0x00107E38
1446 public void SetLiquid(int x, int z, CellEffect effect = null)
1447 {
1448 Cell cell = this.cells[x, z];
1449 if (cell.IsTopWaterAndNoSnow && effect != null)
1450 {
1451 return;
1452 }
1453 cell.effect = effect;
1454 }
1455
1456 // Token: 0x06002F30 RID: 12080 RVA: 0x00109C68 File Offset: 0x00107E68
1457 public void SetLiquid(int x, int z, int id, int value = 1)
1458 {
1459 Cell cell = this.cells[x, z];
1460 if (cell.IsTopWaterAndNoSnow && value != 0)
1461 {
1462 return;
1463 }
1464 if (value > 3)
1465 {
1466 value = 3;
1467 }
1468 if (value <= 0)
1469 {
1470 cell.effect = null;
1471 return;
1472 }
1473 cell.effect = new CellEffect
1474 {
1475 id = id,
1476 amount = value
1477 };
1478 }
1479
1480 // Token: 0x06002F31 RID: 12081 RVA: 0x00109CBF File Offset: 0x00107EBF
1481 public void SetEffect(int x, int z, CellEffect effect = null)
1482 {
1483 this.cells[x, z].effect = effect;
1484 }
1485
1486 // Token: 0x06002F32 RID: 12082 RVA: 0x00109CD4 File Offset: 0x00107ED4
1487 public void ModLiquid(int x, int z, int amount)
1488 {
1489 Cell cell = this.cells[x, z];
1490 if (cell.IsTopWaterAndNoSnow || cell.effect == null)
1491 {
1492 return;
1493 }
1494 cell.effect.amount += amount;
1495 if (cell.effect.amount <= 0)
1496 {
1497 cell.effect = null;
1498 }
1499 }
1500
1501 // Token: 0x06002F33 RID: 12083 RVA: 0x00109D28 File Offset: 0x00107F28
1502 public void ClearRainAndDecal()
1503 {
1504 this.ForeachCell(delegate(Cell c)
1505 {
1506 c.effect = null;
1507 c.decal = 0;
1508 });
1509 }
1510
1511 // Token: 0x06002F34 RID: 12084 RVA: 0x00109D4F File Offset: 0x00107F4F
1512 public void SetObj(int x, int z, int id = 0, int value = 1, int dir = 0)
1513 {
1514 this.SetObj(x, z, (int)((byte)EClass.sources.objs.rows[id].DefaultMaterial.id), id, value, dir);
1515 }
1516
1517 // Token: 0x06002F35 RID: 12085 RVA: 0x00109D80 File Offset: 0x00107F80
1518 public void SetObj(int x, int z, int idMat, int idObj, int value, int dir)
1519 {
1520 Cell cell = this.cells[x, z];
1521 cell.obj = (byte)idObj;
1522 cell.objVal = (byte)value;
1523 cell.objMat = (byte)idMat;
1524 cell.objDir = dir;
1525 cell.isHarvested = false;
1526 cell.isObjDyed = false;
1527 SourceObj.Row sourceObj = cell.sourceObj;
1528 if (!sourceObj.matCategory.IsEmpty())
1529 {
1530 int num = EClass._zone.DangerLv;
1531 if (sourceObj.tag.Contains("spot"))
1532 {
1533 num += EClass.pc.Evalue(1656) * 5;
1534 }
1535 cell.objMat = (byte)MATERIAL.GetRandomMaterialFromCategory(num, sourceObj.matCategory.Split(',', StringSplitOptions.None), cell.matObj).id;
1536 }
1537 if (this.backerObjs.ContainsKey(cell.index))
1538 {
1539 this.backerObjs.Remove(cell.index);
1540 }
1541 if (this.plants.ContainsKey(cell.index))
1542 {
1543 this.plants.Remove(cell.index);
1544 }
1545 Critter.RebuildCritter(cell);
1546 this.RefreshNeighborTiles(x, z);
1547 }
1548
1549 // Token: 0x06002F36 RID: 12086 RVA: 0x00109E90 File Offset: 0x00108090
1550 public void AddBackerTree()
1551 {
1552 SourceBacker.Row item = EClass.sources.backers.listTree.NextItem(ref BackerContent.indexTree);
1553 int num = 1;
1554 EClass._map.bounds.ForeachCell(delegate(Cell c)
1555 {
1556 int num;
1557 if (num <= 0 || c.growth == null || !c.growth.IsTree || !c.growth.IsMature || (EClass.player.doneBackers.Contains(item.id) && !EClass.core.config.test.ignoreBackerDestoryFlag))
1558 {
1559 return;
1560 }
1561 if (c.sourceObj.alias == item.tree || item.tree == "random")
1562 {
1563 this.backerObjs[c.index] = item.id;
1564 Debug.Log(string.Concat(new string[]
1565 {
1566 c.index.ToString(),
1567 "/",
1568 c.x.ToString(),
1569 "/",
1570 c.z.ToString(),
1571 "/",
1572 item.id.ToString(),
1573 "/",
1574 item.Name,
1575 "/",
1576 item.tree
1577 }));
1578 num = num;
1579 num--;
1580 item = EClass.sources.backers.listTree.NextItem(ref BackerContent.indexTree);
1581 }
1582 });
1583 }
1584
1585 // Token: 0x06002F37 RID: 12087 RVA: 0x00109EEB File Offset: 0x001080EB
1586 public SourceBacker.Row GetBackerObj(Point p)
1587 {
1588 if (!this.backerObjs.ContainsKey(p.index))
1589 {
1590 return null;
1591 }
1592 return EClass.sources.backers.map.TryGetValue(this.backerObjs[p.index], null);
1593 }
1594
1595 // Token: 0x06002F38 RID: 12088 RVA: 0x00109F28 File Offset: 0x00108128
1596 public void ApplyBackerObj(Point p, int id = -1)
1597 {
1598 if (!p.HasObj)
1599 {
1600 return;
1601 }
1602 bool flag = p.sourceObj.id == 82;
1603 SourceBacker.Row row = (id != -1) ? EClass.sources.backers.map.TryGetValue(id, null) : (flag ? EClass.sources.backers.listRemain.NextItem(ref BackerContent.indexRemain) : EClass.sources.backers.listTree.NextItem(ref BackerContent.indexTree));
1604 if (row != null)
1605 {
1606 if (!EClass.player.doneBackers.Contains(row.id) || EClass.core.config.test.ignoreBackerDestoryFlag)
1607 {
1608 this.backerObjs[p.index] = row.id;
1609 if (flag)
1610 {
1611 p.cell.objDir = row.skin;
1612 return;
1613 }
1614 }
1615 else
1616 {
1617 this.backerObjs.Remove(p.index);
1618 }
1619 }
1620 }
1621
1622 // Token: 0x06002F39 RID: 12089 RVA: 0x0010A010 File Offset: 0x00108210
1623 public void DropBlockComponent(Point point, TileRow r, SourceMaterial.Row mat, bool recoverBlock, bool isPlatform = false, Chara c = null)
1624 {
1625 if (r.components.Length == 0)
1626 {
1627 return;
1628 }
1629 RecipeManager.BuildList();
1630 Thing thing;
1631 if (recoverBlock)
1632 {
1633 if (r is SourceFloor.Row)
1634 {
1635 thing = ThingGen.CreateFloor(r.id, mat.id, isPlatform);
1636 }
1637 else
1638 {
1639 thing = ThingGen.CreateBlock(r.id, mat.id);
1640 }
1641 }
1642 else
1643 {
1644 RecipeSource recipeSource = RecipeManager.Get(r.RecipeID + (isPlatform ? "-b" : ""));
1645 if (recipeSource == null)
1646 {
1647 return;
1648 }
1649 string idingredient = recipeSource.GetIDIngredient();
1650 if (idingredient == null)
1651 {
1652 return;
1653 }
1654 thing = ThingGen.Create(idingredient, -1, -1);
1655 thing.ChangeMaterial(mat.alias);
1656 }
1657 if (EClass.scene.actionMode.IsBuildMode && EClass.debug.godBuild)
1658 {
1659 this.PutAway(thing);
1660 return;
1661 }
1662 this.TrySmoothPick(point, thing, c);
1663 }
1664
1665 // Token: 0x06002F3A RID: 12090 RVA: 0x0010A0DC File Offset: 0x001082DC
1666 public void MineBlock(Point point, bool recoverBlock = false, Chara c = null)
1667 {
1668 bool flag = ActionMode.Mine.IsRoofEditMode(null) && point.cell._roofBlock > 0;
1669 if (!point.IsValid || (!flag && !point.cell.HasBlock))
1670 {
1671 return;
1672 }
1673 SourceMaterial.Row row = flag ? point.matRoofBlock : point.matBlock;
1674 byte b = flag ? point.cell._roofBlock : point.cell._block;
1675 SourceBlock.Row row2 = EClass.sources.blocks.rows[(int)b];
1676 Effect.Get("smoke").Play(point, 0f, null, null);
1677 Effect.Get("mine").Play(point, 0f, null, null).SetParticleColor(row.GetColor()).Emit(10 + EClass.rnd(10));
1678 point.PlaySound(row.GetSoundDead(row2), true, 1f, true);
1679 row.AddBlood(point, 8);
1680 bool flag2 = c == null || c.IsAgent || c.IsPCFactionOrMinion;
1681 if (flag)
1682 {
1683 point.cell._roofBlock = 0;
1684 this.RefreshSingleTile(point.x, point.z);
1685 }
1686 else
1687 {
1688 if (point.cell.HasFullBlock)
1689 {
1690 this.RemoveLonelyRamps(point.cell);
1691 }
1692 point.SetBlock(0, 0);
1693 if (flag2 && point.sourceObj.tileType.IsBlockMount)
1694 {
1695 this.MineObj(point, null, c);
1696 }
1697 }
1698 if (flag2)
1699 {
1700 this.DropBlockComponent(point, row2, row, recoverBlock, false, c);
1701 }
1702 this.RefreshShadow(point.x, point.z);
1703 this.RefreshShadow(point.x, point.z - 1);
1704 this.ValidateInstalled(point);
1705 this.RefreshFOV(point.x, point.z, 6, false);
1706 if (flag2 && !point.cell.isModified && !flag)
1707 {
1708 if (b == 17 || EClass.rnd(100) == 0)
1709 {
1710 this.zone.AddCard(ThingGen.Create("money2", -1, -1), point);
1711 }
1712 if (EClass._zone.DangerLv >= 10 && EClass.rnd(200) == 0)
1713 {
1714 this.zone.AddCard(ThingGen.Create("crystal_earth", -1, -1), point);
1715 }
1716 if (EClass._zone.DangerLv >= 25 && EClass.rnd(200) == 0)
1717 {
1718 this.zone.AddCard(ThingGen.Create("crystal_sun", -1, -1), point);
1719 }
1720 if (EClass._zone.DangerLv >= 40 && EClass.rnd(200) == 0)
1721 {
1722 this.zone.AddCard(ThingGen.Create("crystal_mana", -1, -1), point);
1723 }
1724 point.cell.isModified = true;
1725 }
1726 }
1727
1728 // Token: 0x06002F3B RID: 12091 RVA: 0x0010A380 File Offset: 0x00108580
1729 public void MineRamp(Point point, int ramp, bool recoverBlock = false)
1730 {
1731 if (!point.IsValid || !point.cell.HasFullBlock)
1732 {
1733 return;
1734 }
1735 SourceMaterial.Row matBlock = point.matBlock;
1736 byte block = point.cell._block;
1737 Effect.Get("smoke").Play(point, 0f, null, null);
1738 Effect.Get("mine").Play(point, 0f, null, null).SetParticleColor(point.matBlock.GetColor()).Emit(10 + EClass.rnd(10));
1739 this.MineObj(point, null, null);
1740 int rampDir = EClass._map.GetRampDir(point.x, point.z, EClass.sources.blocks.rows[ramp].tileType);
1741 this.RemoveLonelyRamps(point.cell);
1742 this.SetBlock(point.x, point.z, (int)point.cell._blockMat, ramp, rampDir);
1743 this.DropBlockComponent(point, EClass.sources.blocks.rows[(int)block], matBlock, recoverBlock, false, null);
1744 }
1745
1746 // Token: 0x06002F3C RID: 12092 RVA: 0x0010A48C File Offset: 0x0010868C
1747 public void MineFloor(Point point, Chara c = null, bool recoverBlock = false, bool removePlatform = true)
1748 {
1749 if (!point.IsValid || (!point.HasFloor && !point.HasBridge))
1750 {
1751 return;
1752 }
1753 SourceMaterial.Row row = point.cell.HasBridge ? point.matBridge : point.matFloor;
1754 SourceFloor.Row c2 = point.cell.HasBridge ? point.sourceBridge : point.sourceFloor;
1755 Effect.Get("mine").Play(point, 0f, null, null).SetParticleColor(row.GetColor()).Emit(10 + EClass.rnd(10));
1756 point.PlaySound(row.GetSoundDead(c2), true, 1f, true);
1757 this.MineObj(point, null, c);
1758 if (point.cell.HasBridge && removePlatform)
1759 {
1760 this.DropBlockComponent(EClass.pc.pos, point.sourceBridge, point.matBridge, recoverBlock, true, c);
1761 EClass._map.SetBridge(point.x, point.z, 0, 0, 0, 0);
1762 if (point.IsSky)
1763 {
1764 EClass.pc.Kick(point, true);
1765 }
1766 return;
1767 }
1768 if (EClass._zone.IsSkyLevel)
1769 {
1770 this.DropBlockComponent(EClass.pc.pos, point.sourceFloor, row, recoverBlock, false, c);
1771 this.SetFloor(point.x, point.z, 0, 90);
1772 if (point.IsSky)
1773 {
1774 EClass.pc.Kick(point, true);
1775 }
1776 return;
1777 }
1778 if (this.zone.IsRegion || point.cell._floor == 40)
1779 {
1780 Thing thing = ThingGen.CreateRawMaterial(row);
1781 thing.ChangeMaterial(row.alias);
1782 this.TrySmoothPick(point, thing, c);
1783 }
1784 else
1785 {
1786 this.DropBlockComponent(point, point.sourceFloor, row, recoverBlock, false, c);
1787 }
1788 if (EClass._zone.IsRegion || point.sourceFloor.components[0].Contains("chunk@soil"))
1789 {
1790 return;
1791 }
1792 point.SetFloor(EClass.sources.floors.rows[1].DefaultMaterial.id, 40);
1793 }
1794
1795 // Token: 0x06002F3D RID: 12093 RVA: 0x0010A681 File Offset: 0x00108881
1796 public void RefreshShadow(int x, int z)
1797 {
1798 }
1799
1800 // Token: 0x06002F3E RID: 12094 RVA: 0x0010A683 File Offset: 0x00108883
1801 public void TrySmoothPick(Cell cell, Thing t, Chara c)
1802 {
1803 this.TrySmoothPick(cell.GetPoint(), t, c);
1804 }
1805
1806 // Token: 0x06002F3F RID: 12095 RVA: 0x0010A694 File Offset: 0x00108894
1807 public void TrySmoothPick(Point p, Thing t, Chara c)
1808 {
1809 if (c != null && c.IsAgent)
1810 {
1811 EClass.pc.PickOrDrop(p, t, true);
1812 return;
1813 }
1814 if (c != null && (c.pos.Equals(p) || EClass.core.config.game.smoothPick || EClass._zone.IsRegion))
1815 {
1816 c.PickOrDrop(p, t, true);
1817 return;
1818 }
1819 EClass._zone.AddCard(t, p);
1820 }
1821
1822 // Token: 0x06002F40 RID: 12096 RVA: 0x0010A704 File Offset: 0x00108904
1823 public void DestroyObj(Point point)
1824 {
1825 Cell cell = point.cell;
1826 RenderRow sourceObj = cell.sourceObj;
1827 SourceMaterial.Row matObj = cell.matObj;
1828 if (sourceObj.tileType.IsBlockPass)
1829 {
1830 Effect.Get("smoke").Play(point, 0f, null, null);
1831 }
1832 Effect.Get("mine").Play(point, 0f, null, null).SetParticleColor(cell.matObj.GetColor()).Emit(10 + EClass.rnd(10));
1833 point.PlaySound(matObj.GetSoundDead(null), true, 1f, true);
1834 matObj.AddBlood(point, 3);
1835 }
1836
1837 // Token: 0x06002F41 RID: 12097 RVA: 0x0010A7A0 File Offset: 0x001089A0
1838 public void MineObj(Point point, Task task = null, Chara c = null)
1839 {
1840 Map.<>c__DisplayClass119_0 CS$<>8__locals1;
1841 CS$<>8__locals1.<>4__this = this;
1842 CS$<>8__locals1.point = point;
1843 CS$<>8__locals1.c = c;
1844 if (!CS$<>8__locals1.point.IsValid || !CS$<>8__locals1.point.HasObj)
1845 {
1846 return;
1847 }
1848 Cell cell = CS$<>8__locals1.point.cell;
1849 SourceObj.Row sourceObj = cell.sourceObj;
1850 bool flag = false;
1851 if (CS$<>8__locals1.c == null && task != null)
1852 {
1853 CS$<>8__locals1.c = task.owner;
1854 }
1855 bool flag2 = CS$<>8__locals1.c == null || CS$<>8__locals1.c.IsAgent || CS$<>8__locals1.c.IsPCFactionOrMinion;
1856 this.DestroyObj(CS$<>8__locals1.point);
1857 if (flag2)
1858 {
1859 SourceMaterial.Row matObj_fixed = cell.matObj_fixed;
1860 TaskHarvest taskHarvest = task as TaskHarvest;
1861 if (taskHarvest != null && taskHarvest.IsReapSeed)
1862 {
1863 int num = 1 + EClass.rnd(2) + ((EClass.rnd(3) == 0) ? 1 : 0);
1864 if (EClass._zone.IsPCFaction)
1865 {
1866 int soilCost = EClass._zone.GetSoilCost();
1867 int maxSoil = EClass.Branch.MaxSoil;
1868 if (soilCost > maxSoil)
1869 {
1870 num -= EClass.rnd(2 + (soilCost - maxSoil) / 10);
1871 }
1872 }
1873 if (num <= 0)
1874 {
1875 Msg.Say("seedSpoiled", cell.GetObjName(), null, null, null);
1876 }
1877 else
1878 {
1879 Thing t = TraitSeed.MakeSeed(sourceObj, this.TryGetPlant(cell)).SetNum(num);
1880 EClass.pc.PickOrDrop(CS$<>8__locals1.point, t, true);
1881 }
1882 if (cell.growth.IsTree)
1883 {
1884 cell.isHarvested = true;
1885 return;
1886 }
1887 }
1888 else if (sourceObj.HasGrowth)
1889 {
1890 cell.growth.PopMineObj(CS$<>8__locals1.c);
1891 }
1892 else
1893 {
1894 if (cell.HasBlock && (sourceObj.id == 18 || sourceObj.id == 19))
1895 {
1896 this.MineBlock(CS$<>8__locals1.point, false, CS$<>8__locals1.c);
1897 }
1898 string alias = sourceObj.alias;
1899 uint num2 = <PrivateImplementationDetails>.ComputeStringHash(alias);
1900 if (num2 <= 529228496U)
1901 {
1902 if (num2 != 414349311U)
1903 {
1904 if (num2 != 489301296U)
1905 {
1906 if (num2 == 529228496U)
1907 {
1908 if (!(alias == "wreck_junk"))
1909 {
1910 }
1911 }
1912 }
1913 else if (!(alias == "wreck_precious"))
1914 {
1915 }
1916 }
1917 else if (alias == "nest_bird")
1918 {
1919 if (EClass.rnd(5) <= 1)
1920 {
1921 this.<MineObj>g__Pop|119_0(ThingGen.Create((EClass.rnd(10) == 0) ? "egg_fertilized" : "_egg", -1, -1).TryMakeRandomItem(-1), ref CS$<>8__locals1);
1922 }
1923 }
1924 }
1925 else if (num2 <= 1575653919U)
1926 {
1927 if (num2 != 1117262783U)
1928 {
1929 if (num2 == 1575653919U)
1930 {
1931 if (!(alias == "wreck_scrap"))
1932 {
1933 }
1934 }
1935 }
1936 else if (!(alias == "wreck_stone"))
1937 {
1938 }
1939 }
1940 else if (num2 != 3603235706U)
1941 {
1942 if (num2 == 3937420123U)
1943 {
1944 if (!(alias == "wreck_wood"))
1945 {
1946 }
1947 }
1948 }
1949 else if (!(alias == "wreck_cloth"))
1950 {
1951 }
1952 int num3 = EClass.rnd(EClass.rnd(sourceObj.components.Length) + 1);
1953 string[] array = sourceObj.components[num3].Split('/', StringSplitOptions.None);
1954 Thing thing = ThingGen.Create(array[0], matObj_fixed.alias);
1955 if (array.Length > 1)
1956 {
1957 thing.SetNum(EClass.rnd(array[1].ToInt()) + 1);
1958 }
1959 this.<MineObj>g__Pop|119_0(thing, ref CS$<>8__locals1);
1960 }
1961 }
1962 this.SetObj(CS$<>8__locals1.point.x, CS$<>8__locals1.point.z, 0, 1, 0);
1963 cell.gatherCount = 0;
1964 if (flag)
1965 {
1966 this.RefreshFOV(CS$<>8__locals1.point.x, CS$<>8__locals1.point.z, 6, false);
1967 }
1968 }
1969
1970 // Token: 0x06002F42 RID: 12098 RVA: 0x0010AB2D File Offset: 0x00108D2D
1971 public void MineObjSound(Point point)
1972 {
1973 point.PlaySound(point.cell.matObj.GetSoundDead(point.cell.sourceObj), true, 1f, true);
1974 }
1975
1976 // Token: 0x06002F43 RID: 12099 RVA: 0x0010AB58 File Offset: 0x00108D58
1977 public PlantData TryGetPlant(Point p)
1978 {
1979 return this.plants.TryGetValue(p.index, null);
1980 }
1981
1982 // Token: 0x06002F44 RID: 12100 RVA: 0x0010AB6C File Offset: 0x00108D6C
1983 public PlantData TryGetPlant(Cell c)
1984 {
1985 return this.plants.TryGetValue(c.index, null);
1986 }
1987
1988 // Token: 0x06002F45 RID: 12101 RVA: 0x0010AB80 File Offset: 0x00108D80
1989 public PlantData AddPlant(Point pos, Thing seed)
1990 {
1991 PlantData plantData = new PlantData
1992 {
1993 seed = seed
1994 };
1995 this.plants[pos.index] = plantData;
1996 return plantData;
1997 }
1998
1999 // Token: 0x06002F46 RID: 12102 RVA: 0x0010ABAD File Offset: 0x00108DAD
2000 public void RemovePlant(Point pos)
2001 {
2002 this.plants.Remove(pos.index);
2003 }
2004
2005 // Token: 0x06002F47 RID: 12103 RVA: 0x0010ABC4 File Offset: 0x00108DC4
2006 public void ValidateInstalled(Point p)
2007 {
2008 this._ValidateInstalled(p.x, p.z);
2009 this._ValidateInstalled(p.x + 1, p.z);
2010 this._ValidateInstalled(p.x - 1, p.z);
2011 this._ValidateInstalled(p.x, p.z + 1);
2012 this._ValidateInstalled(p.x, p.z - 1);
2013 }
2014
2015 // Token: 0x06002F48 RID: 12104 RVA: 0x0010AC34 File Offset: 0x00108E34
2016 public void _ValidateInstalled(int x, int y)
2017 {
2018 Point point = Point.shared.Set(x, y);
2019 if (!point.IsValid)
2020 {
2021 return;
2022 }
2023 List<Card> list = point.ListCards(false);
2024 CellDetail detail = point.cell.detail;
2025 if (detail == null)
2026 {
2027 return;
2028 }
2029 foreach (Card card in list)
2030 {
2031 if (card.isThing && card.trait.CanBeDestroyed && card.IsInstalled)
2032 {
2033 HitResult hitResult = card.TileType._HitTest(point, card.Thing, false);
2034 if (card.Thing.stackOrder != detail.things.IndexOf(card.Thing) || (hitResult != HitResult.Valid && hitResult != HitResult.Warning))
2035 {
2036 if (EClass._zone.IsPCFaction)
2037 {
2038 card.SetPlaceState(PlaceState.roaming, false);
2039 }
2040 else
2041 {
2042 card.Die(null, null, AttackSource.None);
2043 }
2044 }
2045 }
2046 }
2047 }
2048
2049 // Token: 0x06002F49 RID: 12105 RVA: 0x0010AD34 File Offset: 0x00108F34
2050 public void RemoveLonelyRamps(Cell cell)
2051 {
2052 for (int i = 0; i < 4; i++)
2053 {
2054 Cell dependedRamp = this.GetDependedRamp(cell);
2055 if (dependedRamp == null)
2056 {
2057 break;
2058 }
2059 this.MineBlock(dependedRamp.GetPoint(), false, null);
2060 }
2061 }
2062
2063 // Token: 0x06002F4A RID: 12106 RVA: 0x0010AD66 File Offset: 0x00108F66
2064 public void DestroyBlock(int x, int z)
2065 {
2066 this.SetBlock(x, z, 0, 0);
2067 }
2068
2069 // Token: 0x06002F4B RID: 12107 RVA: 0x0010AD74 File Offset: 0x00108F74
2070 public void AddDecal(int x, int z, int id, int amount = 1, bool refresh = true)
2071 {
2072 if (x < 0 || z < 0 || x >= this.Size || z >= this.Size)
2073 {
2074 return;
2075 }
2076 Cell cell = this.cells[x, z];
2077 if (!cell.sourceFloor.tileType.AllowBlood)
2078 {
2079 return;
2080 }
2081 if ((int)(cell.decal / 8) != id && (int)(cell.decal % 8) > amount)
2082 {
2083 return;
2084 }
2085 if ((int)(cell.decal / 8) != id && cell.decal % 8 == 0)
2086 {
2087 amount--;
2088 }
2089 int num = Mathf.Clamp((int)(((int)(cell.decal / 8) == id) ? (cell.decal % 8) : 0) + amount, 0, 7);
2090 cell.decal = (byte)(id * 8 + num);
2091 if (refresh)
2092 {
2093 this.RefreshNeighborTiles(x, z);
2094 }
2095 }
2096
2097 // Token: 0x06002F4C RID: 12108 RVA: 0x0010AE29 File Offset: 0x00109029
2098 public void SetDecal(int x, int z, int id = 0, int amount = 1, bool refresh = true)
2099 {
2100 this.cells[x, z].decal = (byte)(id * 8 + ((id == 0) ? 0 : amount));
2101 if (refresh)
2102 {
2103 this.RefreshNeighborTiles(x, z);
2104 }
2105 }
2106
2107 // Token: 0x06002F4D RID: 12109 RVA: 0x0010AE58 File Offset: 0x00109058
2108 public void SetFoormark(Point pos, int id, int angle, int offset = 0)
2109 {
2110 Cell cell = pos.cell;
2111 int tile = this.AngleToIndex(angle) + offset;
2112 Footmark footmark = new Footmark
2113 {
2114 tile = tile,
2115 remaining = 10
2116 };
2117 footmark.pos.Set(pos);
2118 this.footmarks.Add(footmark);
2119 cell.GetOrCreateDetail().footmark = footmark;
2120 }
2121
2122 // Token: 0x06002F4E RID: 12110 RVA: 0x0010AEB0 File Offset: 0x001090B0
2123 public int AngleToIndex(int a)
2124 {
2125 if (EClass._zone.IsRegion)
2126 {
2127 if (a == 135)
2128 {
2129 return 7;
2130 }
2131 if (a == 180)
2132 {
2133 return 0;
2134 }
2135 if (a == 225)
2136 {
2137 return 1;
2138 }
2139 if (a == -90)
2140 {
2141 return 2;
2142 }
2143 if (a == -45)
2144 {
2145 return 3;
2146 }
2147 if (a == 0)
2148 {
2149 return 4;
2150 }
2151 if (a == 45)
2152 {
2153 return 5;
2154 }
2155 return 6;
2156 }
2157 else
2158 {
2159 if (a == 135)
2160 {
2161 return 0;
2162 }
2163 if (a == 180)
2164 {
2165 return 1;
2166 }
2167 if (a == 225)
2168 {
2169 return 2;
2170 }
2171 if (a == -90)
2172 {
2173 return 3;
2174 }
2175 if (a == -45)
2176 {
2177 return 4;
2178 }
2179 if (a == 0)
2180 {
2181 return 5;
2182 }
2183 if (a == 45)
2184 {
2185 return 6;
2186 }
2187 return 7;
2188 }
2189 }
2190
2191 // Token: 0x06002F4F RID: 12111 RVA: 0x0010AF3C File Offset: 0x0010913C
2192 public void RefreshSingleTile(int x, int z)
2193 {
2194 this.cells[x, z].Refresh();
2195 }
2196
2197 // Token: 0x06002F50 RID: 12112 RVA: 0x0010AF50 File Offset: 0x00109150
2198 public void RefreshAllTiles()
2199 {
2200 for (int i = 0; i < this.Size; i++)
2201 {
2202 for (int j = 0; j < this.Size; j++)
2203 {
2204 this.cells[i, j].Refresh();
2205 }
2206 }
2207 }
2208
2209 // Token: 0x06002F51 RID: 12113 RVA: 0x0010AF94 File Offset: 0x00109194
2210 public void RefreshNeighborTiles(int x, int z)
2211 {
2212 this.cells[x, z].Refresh();
2213 for (int i = x - 2; i < x + 3; i++)
2214 {
2215 if (i >= 0 && i < this.Size)
2216 {
2217 for (int j = z - 2; j < z + 3; j++)
2218 {
2219 if (j >= 0 && j < this.Size && (x != i || z != j))
2220 {
2221 this.cells[i, j].Refresh();
2222 }
2223 }
2224 }
2225 }
2226 }
2227
2228 // Token: 0x06002F52 RID: 12114 RVA: 0x0010B008 File Offset: 0x00109208
2229 public void QuickRefreshTile(int x, int z)
2230 {
2231 Cell cell = this.cells[x, z];
2232 Cell cell2 = (x > 0) ? this.cells[x - 1, z] : Cell.Void;
2233 Cell cell3 = (x + 1 < this.Size) ? this.cells[x + 1, z] : Cell.Void;
2234 Cell cell4 = (z > 0) ? this.cells[x, z - 1] : Cell.Void;
2235 Cell cell5 = (z + 1 < this.Size) ? this.cells[x, z + 1] : Cell.Void;
2236 Cell cell6 = (x > 0 && z > 0) ? this.cells[x - 1, z - 1] : Cell.Void;
2237 Cell cell7 = (x + 1 < this.Size && z > 0) ? this.cells[x + 1, z - 1] : Cell.Void;
2238 Cell cell8 = (x > 0 && z + 1 < this.Size) ? this.cells[x - 1, z + 1] : Cell.Void;
2239 Cell cell9 = (x + 1 < this.Size && z + 1 < this.Size) ? this.cells[x + 1, z + 1] : Cell.Void;
2240 cell.isSurrounded4d = (cell2.HasFullBlock && cell3.HasFullBlock && cell4.HasFullBlock && cell5.HasFullBlock);
2241 cell.isSurrounded = (cell.isSurrounded4d && cell6.HasFullBlock && cell7.HasFullBlock && cell8.HasFullBlock && cell9.HasFullBlock);
2242 }
2243
2244 // Token: 0x06002F53 RID: 12115 RVA: 0x0010B19C File Offset: 0x0010939C
2245 public int GetRampDir(int x, int z, TileType blockType = null)
2246 {
2247 Cell cell = this.cells[x, z];
2248 if (cell.HasFullBlock)
2249 {
2250 if (blockType == null)
2251 {
2252 blockType = cell.sourceBlock.tileType;
2253 }
2254 Cell right = cell.Right;
2255 Cell front = cell.Front;
2256 Cell left = cell.Left;
2257 Cell back = cell.Back;
2258 if (!right.HasBlock && !right.IsVoid && left.HasFullBlock && front.CanBuildRamp(1) && back.CanBuildRamp(1))
2259 {
2260 return 1;
2261 }
2262 if (!front.HasBlock && !front.IsVoid && back.HasFullBlock && left.CanBuildRamp(0) && right.CanBuildRamp(0))
2263 {
2264 return 0;
2265 }
2266 if (!left.HasBlock && !left.IsVoid && right.HasFullBlock && front.CanBuildRamp(3) && back.CanBuildRamp(3))
2267 {
2268 return 3;
2269 }
2270 if (!back.HasBlock && !back.IsVoid && front.HasFullBlock && left.CanBuildRamp(2) && right.CanBuildRamp(2))
2271 {
2272 return 2;
2273 }
2274 if (!blockType.IsRamp)
2275 {
2276 return 0;
2277 }
2278 }
2279 return -1;
2280 }
2281
2282 // Token: 0x06002F54 RID: 12116 RVA: 0x0010B2B0 File Offset: 0x001094B0
2283 public Cell GetDependedRamp(Cell cell)
2284 {
2285 Cell right = cell.Right;
2286 if (right.HasRamp && !right.HasStairs && right.blockDir == 1)
2287 {
2288 return right;
2289 }
2290 Cell front = cell.Front;
2291 if (front.HasRamp && !front.HasStairs && front.blockDir == 0)
2292 {
2293 return front;
2294 }
2295 Cell left = cell.Left;
2296 if (left.HasRamp && !left.HasStairs && left.blockDir == 3)
2297 {
2298 return left;
2299 }
2300 Cell back = cell.Back;
2301 if (back.HasRamp && !back.HasStairs && back.blockDir == 2)
2302 {
2303 return back;
2304 }
2305 return null;
2306 }
2307
2308 // Token: 0x06002F55 RID: 12117 RVA: 0x0010B348 File Offset: 0x00109548
2309 public Point GetRandomPoint(Point center, int radius, int tries = 100, bool mustBeWalkable = true, bool requireLos = true)
2310 {
2311 Point point = new Point();
2312 for (int i = 0; i < tries; i++)
2313 {
2314 point.x = center.x + EClass.rnd(radius * 2 + 1) - radius;
2315 point.z = center.z + EClass.rnd(radius * 2 + 1) - radius;
2316 point.Clamp(false);
2317 if ((!mustBeWalkable || !point.cell.blocked) && (!requireLos || Los.IsVisible(center, point, null)))
2318 {
2319 return point;
2320 }
2321 }
2322 Debug.Log("GetRandomPoint failed center:" + ((center != null) ? center.ToString() : null) + " rad:" + radius.ToString());
2323 point.IsValid = false;
2324 return point;
2325 }
2326
2327 // Token: 0x06002F56 RID: 12118 RVA: 0x0010B3F4 File Offset: 0x001095F4
2328 public new Point GetRandomEdge(int r = 3)
2329 {
2330 for (int i = 0; i < 10000; i++)
2331 {
2332 int x;
2333 int z;
2334 if (EClass.rnd(2) == 0)
2335 {
2336 x = ((EClass.rnd(2) == 0) ? EClass.rnd(r) : (this.Size - 1 - EClass.rnd(r)));
2337 z = EClass.rnd(this.Size);
2338 }
2339 else
2340 {
2341 z = ((EClass.rnd(2) == 0) ? EClass.rnd(r) : (this.Size - 1 - EClass.rnd(r)));
2342 x = EClass.rnd(this.Size);
2343 }
2344 Point surface = base.GetSurface(x, z, false);
2345 if (surface.IsValid)
2346 {
2347 return surface;
2348 }
2349 }
2350 return base.GetSurface(this.Size / 2, this.Size / 2, false);
2351 }
2352
2353 // Token: 0x06002F57 RID: 12119 RVA: 0x0010B4A8 File Offset: 0x001096A8
2354 public Point GetNearbyResourcePoint(Point center)
2355 {
2356 Point point = new Point();
2357 int num = (EClass.rnd(2) == 0) ? 1 : -1;
2358 int num2 = (EClass.rnd(2) == 0) ? 1 : -1;
2359 for (int i = 0; i < 3; i++)
2360 {
2361 point.x = center.x - num + i * num;
2362 for (int j = 0; j < 3; j++)
2363 {
2364 point.z = center.z - num2 + j * num2;
2365 if (point.IsValid && point.area == null && point.cell.CanHarvest())
2366 {
2367 return point;
2368 }
2369 }
2370 }
2371 return Point.Invalid;
2372 }
2373
2374 // Token: 0x06002F58 RID: 12120 RVA: 0x0010B53C File Offset: 0x0010973C
2375 public List<Point> ListPointsInCircle(Point center, float radius, bool mustBeWalkable = true, bool los = true)
2376 {
2377 List<Point> list = new List<Point>();
2378 this.ForeachSphere(center.x, center.z, radius, delegate(Point p)
2379 {
2380 if ((!mustBeWalkable || !p.cell.blocked) && (!los || Los.IsVisible(center, p, null)))
2381 {
2382 list.Add(p.Copy());
2383 }
2384 });
2385 return list;
2386 }
2387
2388 // Token: 0x06002F59 RID: 12121 RVA: 0x0010B5A0 File Offset: 0x001097A0
2389 public List<Chara> ListCharasInCircle(Point center, float radius, bool los = true)
2390 {
2391 List<Chara> list = new List<Chara>();
2392 foreach (Point point in this.ListPointsInCircle(center, radius, false, los))
2393 {
2394 CellDetail detail = point.detail;
2395 if (detail != null && detail.charas.Count > 0)
2396 {
2397 foreach (Chara item in point.detail.charas)
2398 {
2399 list.Add(item);
2400 }
2401 }
2402 }
2403 return list;
2404 }
2405
2406 // Token: 0x06002F5A RID: 12122 RVA: 0x0010B65C File Offset: 0x0010985C
2407 public List<Point> ListPointsInArc(Point center, Point to, int radius, float angle)
2408 {
2409 Point to2 = new Point((to.x > center.x) ? 1 : ((to.x < center.x) ? -1 : 0), (to.z > center.z) ? 1 : ((to.z < center.z) ? -1 : 0));
2410 Point point = new Point(0, 0);
2411 List<Point> list = new List<Point>();
2412 float diff = point.GetAngle2(to2);
2413 this.ForeachSphere(center.x, center.z, (float)radius, delegate(Point p)
2414 {
2415 float angle2 = center.GetAngle2(p);
2416 if ((Mathf.Abs(diff - angle2) < angle || Mathf.Abs(diff - angle2 + 360f) < angle || Mathf.Abs(360f - diff + angle2) < angle) && Los.IsVisible(center, p, null) && !p.IsBlocked)
2417 {
2418 list.Add(p.Copy());
2419 }
2420 });
2421 return list;
2422 }
2423
2424 // Token: 0x06002F5B RID: 12123 RVA: 0x0010B72E File Offset: 0x0010992E
2425 public List<Point> ListPointsInLine(Point center, Point to, int radius)
2426 {
2427 return Los.ListVisible(center, to, radius, null);
2428 }
2429
2430 // Token: 0x06002F5C RID: 12124 RVA: 0x0010B73C File Offset: 0x0010993C
2431 public void SetBounds(int size)
2432 {
2433 if (size > this.Size / 2 + 1)
2434 {
2435 size = this.Size / 2 - 1;
2436 }
2437 this.bounds.SetBounds(this.Size / 2 - size, this.Size / 2 - size, this.Size / 2 + size, this.Size / 2 + size);
2438 }
2439
2440 // Token: 0x06002F5D RID: 12125 RVA: 0x0010B795 File Offset: 0x00109995
2441 public void SetBounds(MapBounds b)
2442 {
2443 this.bounds.SetBounds(b.x, b.z, b.maxX, b.maxZ);
2444 this.bounds.Size = b.Size;
2445 }
2446
2447 // Token: 0x06002F5E RID: 12126 RVA: 0x0010B7CC File Offset: 0x001099CC
2448 public new void ForeachCell(Action<Cell> action)
2449 {
2450 for (int i = 0; i < this.Size; i++)
2451 {
2452 for (int j = 0; j < this.Size; j++)
2453 {
2454 action(this.cells[i, j]);
2455 }
2456 }
2457 }
2458
2459 // Token: 0x06002F5F RID: 12127 RVA: 0x0010B810 File Offset: 0x00109A10
2460 public new void ForeachPoint(Action<Point> action)
2461 {
2462 Point point = new Point();
2463 for (int i = 0; i < this.Size; i++)
2464 {
2465 for (int j = 0; j < this.Size; j++)
2466 {
2467 action(point.Set(i, j));
2468 }
2469 }
2470 }
2471
2472 // Token: 0x06002F60 RID: 12128 RVA: 0x0010B854 File Offset: 0x00109A54
2473 public new void ForeachXYZ(Action<int, int> action)
2474 {
2475 for (int i = 0; i < this.Size; i++)
2476 {
2477 for (int j = 0; j < this.Size; j++)
2478 {
2479 action(i, j);
2480 }
2481 }
2482 }
2483
2484 // Token: 0x06002F61 RID: 12129 RVA: 0x0010B88C File Offset: 0x00109A8C
2485 public void ForeachSphere(int _x, int _z, float r, Action<Point> action)
2486 {
2487 Point point = new Point();
2488 int num = (int)Mathf.Ceil(r);
2489 for (int i = _x - num; i < _x + num + 1; i++)
2490 {
2491 if (i >= 0 && i < this.Size)
2492 {
2493 for (int j = _z - num; j < _z + num + 1; j++)
2494 {
2495 if (j >= 0 && j < this.Size && (float)((i - _x) * (i - _x) + (j - _z) * (j - _z)) < r * r)
2496 {
2497 point.Set(i, j);
2498 action(point);
2499 }
2500 }
2501 }
2502 }
2503 }
2504
2505 // Token: 0x06002F62 RID: 12130 RVA: 0x0010B90C File Offset: 0x00109B0C
2506 public void ForeachNeighbor(Point center, Action<Point> action)
2507 {
2508 int x = center.x;
2509 int z = center.z;
2510 Point point = new Point();
2511 for (int i = x - 1; i < x + 2; i++)
2512 {
2513 if (i >= 0 && i < this.Size)
2514 {
2515 for (int j = z - 1; j < z + 2; j++)
2516 {
2517 if (j >= 0 && j < this.Size)
2518 {
2519 point.Set(i, j);
2520 action(point);
2521 }
2522 }
2523 }
2524 }
2525 }
2526
2527 // Token: 0x06002F63 RID: 12131 RVA: 0x0010B980 File Offset: 0x00109B80
2528 public void Quake()
2529 {
2530 Point point = new Point();
2531 for (int i = 0; i < this.Size; i++)
2532 {
2533 for (int j = 0; j < this.Size; j++)
2534 {
2535 point.x = i;
2536 point.z = j;
2537 point.Copy().Animate(AnimeID.Quake, true);
2538 j += EClass.rnd(2);
2539 }
2540 i += EClass.rnd(2);
2541 }
2542 }
2543
2544 // Token: 0x06002F64 RID: 12132 RVA: 0x0010B9E4 File Offset: 0x00109BE4
2545 public int CountChara(Faction faction)
2546 {
2547 int num = 0;
2548 using (List<Chara>.Enumerator enumerator = this.charas.GetEnumerator())
2549 {
2550 while (enumerator.MoveNext())
2551 {
2552 if (enumerator.Current.faction == faction)
2553 {
2554 num++;
2555 }
2556 }
2557 }
2558 return num;
2559 }
2560
2561 // Token: 0x06002F65 RID: 12133 RVA: 0x0010BA40 File Offset: 0x00109C40
2562 public int CountGuest()
2563 {
2564 int num = 0;
2565 using (List<Chara>.Enumerator enumerator = this.charas.GetEnumerator())
2566 {
2567 while (enumerator.MoveNext())
2568 {
2569 if (enumerator.Current.IsGuest())
2570 {
2571 num++;
2572 }
2573 }
2574 }
2575 return num;
2576 }
2577
2578 // Token: 0x06002F66 RID: 12134 RVA: 0x0010BA9C File Offset: 0x00109C9C
2579 public int CountHostile()
2580 {
2581 int num = 0;
2582 foreach (Chara chara in this.charas)
2583 {
2584 if (!chara.IsPCFaction && chara.IsHostile())
2585 {
2586 num++;
2587 }
2588 }
2589 return num;
2590 }
2591
2592 // Token: 0x06002F67 RID: 12135 RVA: 0x0010BB00 File Offset: 0x00109D00
2593 public int CountWildAnimal()
2594 {
2595 int num = 0;
2596 foreach (Chara chara in this.charas)
2597 {
2598 if (!chara.IsPCFaction && chara.race.IsAnimal)
2599 {
2600 num++;
2601 }
2602 }
2603 return num;
2604 }
2605
2606 // Token: 0x06002F68 RID: 12136 RVA: 0x0010BB68 File Offset: 0x00109D68
2607 public int CountNonHostile()
2608 {
2609 int num = 0;
2610 foreach (Chara chara in this.charas)
2611 {
2612 if (!chara.IsPCFaction && !chara.IsHostile())
2613 {
2614 num++;
2615 }
2616 }
2617 return num;
2618 }
2619
2620 // Token: 0x06002F69 RID: 12137 RVA: 0x0010BBCC File Offset: 0x00109DCC
2621 public List<Chara> ListChara(Faction faction)
2622 {
2623 List<Chara> list = new List<Chara>();
2624 foreach (Chara chara in this.charas)
2625 {
2626 if (chara.faction == faction)
2627 {
2628 list.Add(chara);
2629 }
2630 }
2631 return list;
2632 }
2633
2634 // Token: 0x06002F6A RID: 12138 RVA: 0x0010BC30 File Offset: 0x00109E30
2635 public List<Thing> ListThing<T>() where T : Trait
2636 {
2637 List<Thing> list = new List<Thing>();
2638 foreach (Thing thing in this.things)
2639 {
2640 if (thing.IsInstalled && thing.trait is T)
2641 {
2642 list.Add(thing);
2643 }
2644 }
2645 return list;
2646 }
2647
2648 // Token: 0x06002F6B RID: 12139 RVA: 0x0010BCA0 File Offset: 0x00109EA0
2649 public bool PutAway(Card c)
2650 {
2651 if (c.IsPC || (c.trait.CanOnlyCarry && !EClass.debug.ignoreBuildRule))
2652 {
2653 return false;
2654 }
2655 if (c.isChara)
2656 {
2657 if (!EClass.debug.ignoreBuildRule)
2658 {
2659 return false;
2660 }
2661 c.Destroy();
2662 return true;
2663 }
2664 else
2665 {
2666 Thing thing = c.Thing;
2667 if (thing.parent != null)
2668 {
2669 thing.parent.RemoveCard(thing);
2670 }
2671 thing.isMasked = false;
2672 thing.isRoofItem = false;
2673 if (EClass._zone.IsPCFaction && EClass._map.props.installed.traits.GetRandomThing<TraitSpotStockpile>() != null)
2674 {
2675 EClass._zone.TryAddThingInSpot<TraitSpotStockpile>(thing, true, true);
2676 return true;
2677 }
2678 if (EClass.debug.enable)
2679 {
2680 EClass.debug.GetOrCreateDebugContainer().AddThing(thing, true, -1, -1);
2681 return true;
2682 }
2683 EClass.pc.Pick(thing, false, true);
2684 return true;
2685 }
2686 }
2687
2688 // Token: 0x06002F6C RID: 12140 RVA: 0x0010BD80 File Offset: 0x00109F80
2689 public Chara FindChara(string id)
2690 {
2691 foreach (Chara chara in this.charas)
2692 {
2693 if (chara.id == id)
2694 {
2695 return chara;
2696 }
2697 }
2698 return null;
2699 }
2700
2701 // Token: 0x06002F6D RID: 12141 RVA: 0x0010BDE4 File Offset: 0x00109FE4
2702 public Chara FindChara(int uid)
2703 {
2704 foreach (Chara chara in this.charas)
2705 {
2706 if (chara.uid == uid)
2707 {
2708 return chara;
2709 }
2710 }
2711 return null;
2712 }
2713
2714 // Token: 0x06002F6E RID: 12142 RVA: 0x0010BE40 File Offset: 0x0010A040
2715 public Thing FindThing(Func<Thing, bool> func)
2716 {
2717 foreach (Thing thing in this.things)
2718 {
2719 if (func(thing))
2720 {
2721 return thing;
2722 }
2723 }
2724 return null;
2725 }
2726
2727 // Token: 0x06002F6F RID: 12143 RVA: 0x0010BE9C File Offset: 0x0010A09C
2728 public Thing FindThing(int uid)
2729 {
2730 foreach (Thing thing in this.things)
2731 {
2732 if (thing.uid == uid)
2733 {
2734 return thing;
2735 }
2736 }
2737 return null;
2738 }
2739
2740 // Token: 0x06002F70 RID: 12144 RVA: 0x0010BEF8 File Offset: 0x0010A0F8
2741 public T FindThing<T>() where T : Trait
2742 {
2743 foreach (Thing thing in this.things)
2744 {
2745 if (thing.trait is T)
2746 {
2747 return thing.trait as T;
2748 }
2749 }
2750 return default(T);
2751 }
2752
2753 // Token: 0x06002F71 RID: 12145 RVA: 0x0010BF70 File Offset: 0x0010A170
2754 public Thing FindThing(Type type, Chara c = null)
2755 {
2756 this._things.Clear();
2757 foreach (Thing thing in EClass._map.props.installed.things)
2758 {
2759 if (type.IsAssignableFrom(thing.trait.GetType()) && thing.pos.IsPublicSpace())
2760 {
2761 this._things.Add(thing);
2762 }
2763 }
2764 if (this._things.Count <= 0)
2765 {
2766 return null;
2767 }
2768 return this._things.RandomItem<Thing>();
2769 }
2770
2771 // Token: 0x06002F72 RID: 12146 RVA: 0x0010C01C File Offset: 0x0010A21C
2772 public Thing FindThing(Type type, BaseArea area1, BaseArea area2 = null)
2773 {
2774 Map.<>c__DisplayClass169_0 CS$<>8__locals1;
2775 CS$<>8__locals1.<>4__this = this;
2776 CS$<>8__locals1.type = type;
2777 if (area1 == null && area2 == null)
2778 {
2779 return null;
2780 }
2781 Thing thing = this.<FindThing>g__Find|169_0(area1, ref CS$<>8__locals1);
2782 if (thing == null && area2 != null)
2783 {
2784 thing = this.<FindThing>g__Find|169_0(area2, ref CS$<>8__locals1);
2785 }
2786 return thing;
2787 }
2788
2789 // Token: 0x06002F73 RID: 12147 RVA: 0x0010C05C File Offset: 0x0010A25C
2790 public Thing FindThing(string workTag, BaseArea area1 = null, BaseArea area2 = null)
2791 {
2792 if (area1 == null && area2 == null)
2793 {
2794 return null;
2795 }
2796 Thing thing = null;
2797 PropSet orCreate = EClass._map.Installed.workMap.GetOrCreate(workTag, null);
2798 if (area1 != null)
2799 {
2800 IEnumerable<Card> enumerable = from a in orCreate.Values
2801 where a.pos.HasRoomOrArea(area1)
2802 select a;
2803 if (enumerable.Count<Card>() > 0)
2804 {
2805 thing = (enumerable.RandomItem<Card>() as Thing);
2806 }
2807 }
2808 if (thing == null && area2 != null)
2809 {
2810 IEnumerable<Card> enumerable2 = from a in orCreate.Values
2811 where a.pos.HasRoomOrArea(area2)
2812 select a;
2813 if (enumerable2.Count<Card>() > 0)
2814 {
2815 thing = (enumerable2.RandomItem<Card>() as Thing);
2816 }
2817 }
2818 return thing;
2819 }
2820
2821 // Token: 0x06002F74 RID: 12148 RVA: 0x0010C11C File Offset: 0x0010A31C
2822 public Thing FindThing(string workTag, Chara c)
2823 {
2824 Thing result = null;
2825 IEnumerable<Card> enumerable = from a in EClass._map.Installed.workMap.GetOrCreate(workTag, null).Values
2826 where a.pos.IsPublicSpace()
2827 select a;
2828 if (enumerable.Count<Card>() > 0)
2829 {
2830 result = (enumerable.RandomItem<Card>() as Thing);
2831 }
2832 return result;
2833 }
2834
2835 // Token: 0x06002F75 RID: 12149 RVA: 0x0010C184 File Offset: 0x0010A384
2836 public BaseArea FindPublicArea()
2837 {
2838 return (from a in this.rooms.listArea.Concat(this.rooms.listRoom)
2839 where a.type.IsPublicArea
2840 select a).RandomItem<BaseArea>();
2841 }
2842
2843 // Token: 0x06002F76 RID: 12150 RVA: 0x0010C1D8 File Offset: 0x0010A3D8
2844 public void RefreshSunMap()
2845 {
2846 if (Map.isDirtySunMap)
2847 {
2848 Map.sunMap.Clear();
2849 foreach (Trait trait in EClass._map.props.installed.traits.suns.Values)
2850 {
2851 foreach (Point point in trait.ListPoints(null, false))
2852 {
2853 Map.sunMap.Add(point.index);
2854 }
2855 }
2856 Map.isDirtySunMap = false;
2857 }
2858 }
2859
2860 // Token: 0x06002F7B RID: 12155 RVA: 0x0010C309 File Offset: 0x0010A509
2861 [CompilerGenerated]
2862 internal static bool <TryShatter>g__CanCook|99_0(Card c, ref Map.<>c__DisplayClass99_0 A_1)
2863 {
2864 return A_1.fire && c.IsFood && c.category.IsChildOf("foodstuff");
2865 }
2866
2867 // Token: 0x06002F7C RID: 12156 RVA: 0x0010C32D File Offset: 0x0010A52D
2868 [CompilerGenerated]
2869 private void <MineObj>g__Pop|119_0(Thing t, ref Map.<>c__DisplayClass119_0 A_2)
2870 {
2871 if (EClass.scene.actionMode.IsBuildMode && EClass.debug.godBuild)
2872 {
2873 EClass._map.PutAway(t);
2874 return;
2875 }
2876 this.TrySmoothPick(A_2.point, t, A_2.c);
2877 }
2878
2879 // Token: 0x06002F7D RID: 12157 RVA: 0x0010C36C File Offset: 0x0010A56C
2880 [CompilerGenerated]
2881 private Thing <FindThing>g__Find|169_0(BaseArea area, ref Map.<>c__DisplayClass169_0 A_2)
2882 {
2883 this._things.Clear();
2884 foreach (Thing thing in EClass._map.props.installed.things)
2885 {
2886 if (A_2.type.IsAssignableFrom(thing.trait.GetType()) && thing.pos.HasRoomOrArea(area))
2887 {
2888 this._things.Add(thing);
2889 }
2890 }
2891 if (this._things.Count <= 0)
2892 {
2893 return null;
2894 }
2895 return this._things.RandomItem<Thing>();
2896 }
2897
2898 // Token: 0x04001A94 RID: 6804
2899 public static HashSet<int> sunMap = new HashSet<int>();
2900
2901 // Token: 0x04001A95 RID: 6805
2902 public static bool isDirtySunMap;
2903
2904 // Token: 0x04001A96 RID: 6806
2905 [JsonProperty]
2906 public int seed;
2907
2908 // Token: 0x04001A97 RID: 6807
2909 [JsonProperty]
2910 public int _bits;
2911
2912 // Token: 0x04001A98 RID: 6808
2913 [JsonProperty]
2914 public global::Version version;
2915
2916 // Token: 0x04001A99 RID: 6809
2917 [JsonProperty]
2918 public RoomManager rooms = new RoomManager();
2919
2920 // Token: 0x04001A9A RID: 6810
2921 [JsonProperty]
2922 public TaskManager tasks = new TaskManager();
2923
2924 // Token: 0x04001A9B RID: 6811
2925 [JsonProperty]
2926 public MapConfig config = new MapConfig();
2927
2928 // Token: 0x04001A9C RID: 6812
2929 [JsonProperty]
2930 public CustomData custom;
2931
2932 // Token: 0x04001A9D RID: 6813
2933 [JsonProperty]
2934 public List<Chara> serializedCharas = new List<Chara>();
2935
2936 // Token: 0x04001A9E RID: 6814
2937 [JsonProperty]
2938 public List<Chara> deadCharas = new List<Chara>();
2939
2940 // Token: 0x04001A9F RID: 6815
2941 [JsonProperty]
2942 public List<Thing> things = new List<Thing>();
2943
2944 // Token: 0x04001AA0 RID: 6816
2945 [JsonProperty]
2946 public MapBounds bounds = new MapBounds();
2947
2948 // Token: 0x04001AA1 RID: 6817
2949 [JsonProperty]
2950 public List<int> _plDay = new List<int>();
2951
2952 // Token: 0x04001AA2 RID: 6818
2953 [JsonProperty]
2954 public List<int> _plNight = new List<int>();
2955
2956 // Token: 0x04001AA3 RID: 6819
2957 [JsonProperty]
2958 public Dictionary<int, int> gatherCounts = new Dictionary<int, int>();
2959
2960 // Token: 0x04001AA4 RID: 6820
2961 [JsonProperty]
2962 public Dictionary<int, CellEffect> cellEffects = new Dictionary<int, CellEffect>();
2963
2964 // Token: 0x04001AA5 RID: 6821
2965 [JsonProperty]
2966 public Dictionary<int, int> backerObjs = new Dictionary<int, int>();
2967
2968 // Token: 0x04001AA6 RID: 6822
2969 [JsonProperty]
2970 public Dictionary<int, PlantData> plants = new Dictionary<int, PlantData>();
2971
2972 // Token: 0x04001AA7 RID: 6823
2973 public BitArray32 bits;
2974
2975 // Token: 0x04001AA8 RID: 6824
2976 public Playlist plDay;
2977
2978 // Token: 0x04001AA9 RID: 6825
2979 public Playlist plNight;
2980
2981 // Token: 0x04001AAA RID: 6826
2982 public List<Chara> charas = new List<Chara>();
2983
2984 // Token: 0x04001AAB RID: 6827
2985 public List<TransAnime> pointAnimes = new List<TransAnime>();
2986
2987 // Token: 0x04001AAC RID: 6828
2988 public Cell[,] cells;
2989
2990 // Token: 0x04001AAD RID: 6829
2991 public Zone zone;
2992
2993 // Token: 0x04001AAE RID: 6830
2994 public CellEffectManager effectManager = new CellEffectManager();
2995
2996 // Token: 0x04001AAF RID: 6831
2997 public PropsManager props = new PropsManager();
2998
2999 // Token: 0x04001AB0 RID: 6832
3000 public FloodSpiller flood = new FloodSpiller();
3001
3002 // Token: 0x04001AB1 RID: 6833
3003 public BiomeProfile[,] biomes;
3004
3005 // Token: 0x04001AB2 RID: 6834
3006 public POIMap poiMap;
3007
3008 // Token: 0x04001AB3 RID: 6835
3009 public List<Footmark> footmarks = new List<Footmark>();
3010
3011 // Token: 0x04001AB4 RID: 6836
3012 public FowProfile fowProfile;
3013
3014 // Token: 0x04001AB5 RID: 6837
3015 public bool revealed;
3016
3017 // Token: 0x04001AB6 RID: 6838
3018 private HashSet<int> roomHash = new HashSet<int>();
3019
3020 // Token: 0x04001AB7 RID: 6839
3021 private List<Thing> _things = new List<Thing>();
3022}
Definition Card.cs:13
Definition Cell.cs:10
Definition Chara.cs:12
Definition Game.cs:10
Definition Los.cs:6
Definition Map.cs:15
Definition Msg.cs:7
Definition Point.cs:11
Definition Room.cs:6
Definition Scene.cs:10
Definition Task.cs:6
Definition Thing.cs:10
Definition Trait.cs:9
Definition Zone.cs:14