Elin Decompiled Documentation EA 23.188 Stable Patch 2
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
Map.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using System.Runtime.Serialization;
6using Algorithms;
7using FloodSpill;
8using Ionic.Zip;
9using Newtonsoft.Json;
10using UnityEngine;
11
13{
14 public static HashSet<int> sunMap = new HashSet<int>();
15
16 public static bool isDirtySunMap;
17
18 [JsonProperty]
19 public int seed;
20
21 [JsonProperty]
22 public int _bits;
23
24 [JsonProperty]
26
27 [JsonProperty]
29
30 [JsonProperty]
32
33 [JsonProperty]
35
36 [JsonProperty]
37 public MapConfig config = new MapConfig();
38
39 [JsonProperty]
41
42 [JsonProperty]
43 public List<Chara> serializedCharas = new List<Chara>();
44
45 [JsonProperty]
46 public List<Chara> deadCharas = new List<Chara>();
47
48 [JsonProperty]
49 public List<Thing> things = new List<Thing>();
50
51 [JsonProperty]
52 public MapBounds bounds = new MapBounds();
53
54 [JsonProperty]
55 public List<int> _plDay = new List<int>();
56
57 [JsonProperty]
58 public List<int> _plNight = new List<int>();
59
60 [JsonProperty]
61 public Dictionary<int, int> gatherCounts = new Dictionary<int, int>();
62
63 [JsonProperty]
64 public Dictionary<int, CellEffect> cellEffects = new Dictionary<int, CellEffect>();
65
66 [JsonProperty]
67 public Dictionary<int, int> backerObjs = new Dictionary<int, int>();
68
69 [JsonProperty]
70 public Dictionary<int, PlantData> plants = new Dictionary<int, PlantData>();
71
72 [JsonProperty]
74
76
77 public Playlist plDay;
78
79 public Playlist plNight;
80
81 public List<Chara> charas = new List<Chara>();
82
83 public List<TransAnime> pointAnimes = new List<TransAnime>();
84
85 public Cell[,] cells;
86
87 public Zone zone;
88
90
92
93 public FloodSpiller flood = new FloodSpiller();
94
96
97 public POIMap poiMap;
98
99 public List<Footmark> footmarks = new List<Footmark>();
100
102
103 public bool revealed;
104
105 private HashSet<int> roomHash = new HashSet<int>();
106
107 private List<Thing> _things = new List<Thing>();
108
109 public bool isBreakerDown
110 {
111 get
112 {
113 return bits[0];
114 }
115 set
116 {
117 bits[0] = value;
118 }
119 }
120
122
124
126
127 public float sizeModifier => 1f / (16384f / (float)SizeXZ);
128
129 public bool isGenerated => Size != 0;
130
131 public bool IsIndoor => config.indoor;
132
133 public int SizeXZ => Size * Size;
134
135 public IEnumerable<Card> Cards => ((IEnumerable<Card>)things).Concat((IEnumerable<Card>)charas);
136
138 private void OnSerializing(StreamingContext context)
139 {
140 _bits = (int)bits.Bits;
141 }
142
143 protected virtual void OnSerializing()
144 {
145 }
146
148 private void OnDeserialized(StreamingContext context)
149 {
150 bits.Bits = (uint)_bits;
151 }
152
153 public void CreateNew(int size, bool setReference = true)
154 {
155 Debug.Log("Map CreateNew:");
156 Size = size;
157 cells = new Cell[Size, Size];
158 bounds = new MapBounds
159 {
160 x = 0,
161 z = 0,
162 maxX = Size - 1,
163 maxZ = Size - 1,
164 Size = Size
165 };
166 SetBounds(0, 0, Size - 1, Size - 1);
167 ForeachXYZ(delegate(int x, int z)
168 {
169 cells[x, z] = new Cell
170 {
171 x = (byte)x,
172 z = (byte)z
173 };
174 });
175 if (setReference)
176 {
177 SetReference();
178 }
179 }
180
181 public void SetZone(Zone _zone)
182 {
183 zone = _zone;
184 zone.bounds = bounds;
185 bounds.Size = Size;
186 SetReference();
187 props.Init();
188 EClass.scene.profile = SceneProfile.Load(config.idSceneProfile.IsEmpty("default"));
189 if (!config.idFowProfile.IsEmpty())
190 {
192 }
193 }
194
195 public void SetReference()
196 {
197 Fov.map = (Cell.map = (Wall.map = (Point.map = (CellDetail.map = this))));
198 Cell.Size = Size;
199 Cell.cells = cells;
201 WeightCell[,] weightMap = cells;
202 pathfinder.Init(this, weightMap, Size);
203 }
204
205 public void OnDeactivate()
206 {
207 charas.ForeachReverse(delegate(Chara c)
208 {
209 c.ai = new NoGoal();
210 if (c.IsGlobal)
211 {
212 zone.RemoveCard(c);
213 c.currentZone = zone;
214 }
215 });
216 foreach (Thing thing in things)
217 {
218 if (thing.renderer.hasActor)
219 {
220 thing.renderer.KillActor();
221 }
222 }
224 }
225
226 public void Resize(int newSize)
227 {
228 Point p = new Point(0, 0);
229 foreach (Thing thing in EClass._map.things)
230 {
231 if (thing.pos.x >= newSize || thing.pos.z >= newSize)
232 {
233 MoveCard(p, thing);
234 }
235 }
236 foreach (Chara chara in EClass._map.charas)
237 {
238 if (chara.pos.x >= newSize || chara.pos.z >= newSize)
239 {
240 MoveCard(p, chara);
241 }
242 }
243 Size = (bounds.Size = newSize);
244 maxX = (maxZ = Size);
245 cells = Util.ResizeArray(EClass._map.cells, newSize, newSize, (int x, int y) => new Cell
246 {
247 x = (byte)x,
248 z = (byte)y,
249 isSeen = true
250 });
251 Reload();
252 }
253
254 public void Shift(Vector2Int offset)
255 {
256 TweenUtil.Tween(0.1f, null, delegate
257 {
258 foreach (Card item in ((IEnumerable<Card>)EClass._map.things).Concat((IEnumerable<Card>)EClass._map.charas))
259 {
260 item.pos.x += offset.x;
261 item.pos.z += offset.y;
262 item.pos.Clamp();
263 }
264 Cell[,] array = new Cell[Size, Size];
265 for (int i = 0; i < Size; i++)
266 {
267 int num = i - offset.y;
268 for (int j = 0; j < Size; j++)
269 {
270 int num2 = j - offset.x;
271 if (num2 >= 0 && num2 < Size && num >= 0 && num < Size)
272 {
273 array[j, i] = cells[num2, num];
274 }
275 else
276 {
277 array[j, i] = new Cell
278 {
279 x = (byte)j,
280 z = (byte)i
281 };
282 }
283 }
284 }
285 cells = array;
286 bounds.x += offset.x;
287 bounds.z += offset.y;
288 bounds.maxX += offset.x;
289 bounds.maxZ += offset.y;
290 if (bounds.x < 0)
291 {
292 bounds.x = 0;
293 }
294 if (bounds.z < 0)
295 {
296 bounds.z = 0;
297 }
298 if (bounds.maxX > Size)
299 {
300 bounds.maxX = Size;
301 }
302 if (bounds.maxZ > Size)
303 {
304 bounds.maxZ = Size;
305 }
306 Reload();
307 });
308 }
309
310 public void Reload()
311 {
312 rooms = new RoomManager();
313 SetReference();
314 string id = Game.id;
315 EClass.game.Save();
316 EClass.scene.Init(Scene.Mode.None);
317 Game.Load(id, cloud: false);
318 RevealAll();
319 TweenUtil.Tween(0.1f, null, delegate
320 {
321 ReloadRoom();
322 });
323 }
324
325 public void ReloadRoom()
326 {
327 List<Thing> list = new List<Thing>();
328 foreach (Thing thing in things)
329 {
330 if (thing.trait.IsDoor)
331 {
332 list.Add(thing);
333 }
334 }
335 foreach (Thing item in list)
336 {
337 Point pos = item.pos;
339 EClass._zone.AddCard(item, pos);
340 item.Install();
341 }
343 }
344
345 public void Reset()
346 {
347 for (int i = 0; i < Size; i++)
348 {
349 for (int j = 0; j < Size; j++)
350 {
351 cells[i, j].Reset();
352 }
353 }
354 SetReference();
355 }
356
357 public void ResetEditorPos()
358 {
360 foreach (Chara chara in charas)
361 {
362 if (chara.isPlayerCreation && chara.orgPos != null)
363 {
364 MoveCard(chara.orgPos, chara);
365 }
366 }
367 foreach (Thing thing in things)
368 {
369 if (thing.trait is TraitDoor)
370 {
371 (thing.trait as TraitDoor).ForceClose();
372 }
373 }
374 }
375
376 public void Save(string path, ZoneExportData export = null, PartialMap partial = null)
377 {
379 Debug.Log("#io saving map:" + path);
380 IO.CreateDirectory(path);
381 int num = 0;
382 int num2 = 0;
383 int num3 = Size;
384 int num4 = Size;
385 if (partial != null)
386 {
387 num = partial.offsetX;
388 num2 = partial.offsetZ;
389 num3 = partial.w;
390 num4 = partial.h;
391 }
392 int num5 = num3 * num4;
393 byte[] array = new byte[num5];
394 byte[] array2 = new byte[num5];
395 byte[] array3 = new byte[num5];
396 byte[] array4 = new byte[num5];
397 byte[] array5 = new byte[num5];
398 byte[] array6 = new byte[num5];
399 byte[] array7 = new byte[num5];
400 byte[] array8 = new byte[num5];
401 byte[] array9 = new byte[num5];
402 byte[] array10 = new byte[num5];
403 byte[] array11 = new byte[num5];
404 byte[] array12 = new byte[num5];
405 byte[] array13 = new byte[num5];
406 byte[] array14 = new byte[num5];
407 byte[] array15 = new byte[num5];
408 byte[] array16 = new byte[num5];
409 byte[] array17 = new byte[num5];
410 byte[] array18 = new byte[num5];
411 byte[] array19 = new byte[num5];
412 cellEffects.Clear();
413 int num6 = 0;
414 for (int i = num; i < num + num3; i++)
415 {
416 for (int j = num2; j < num2 + num4; j++)
417 {
418 Cell cell = cells[i, j];
419 array[num6] = cell.objVal;
420 array3[num6] = cell._blockMat;
421 array2[num6] = cell._block;
422 array5[num6] = cell._floorMat;
423 array4[num6] = cell._floor;
424 array6[num6] = cell.obj;
425 array7[num6] = cell.objMat;
426 array8[num6] = cell.decal;
427 array9[num6] = cell._dirs;
428 array12[num6] = cell.height;
429 array13[num6] = cell._bridge;
430 array14[num6] = cell._bridgeMat;
431 array15[num6] = cell.bridgeHeight;
432 array17[num6] = cell._roofBlockDir;
433 array18[num6] = cell._roofBlock;
434 array19[num6] = cell._roofBlockMat;
435 array16[num6] = cell.bridgePillar;
436 array10[num6] = array10[num6].SetBit(1, cell.isSeen);
437 array10[num6] = array10[num6].SetBit(2, cell.isHarvested);
438 array10[num6] = array10[num6].SetBit(3, cell.impassable);
439 array10[num6] = array10[num6].SetBit(4, cell.isModified);
440 array10[num6] = array10[num6].SetBit(5, cell.isClearSnow);
441 array10[num6] = array10[num6].SetBit(6, cell.isForceFloat);
442 array10[num6] = array10[num6].SetBit(7, cell.isToggleWallPillar);
443 array11[num6] = array11[num6].SetBit(0, cell.isWatered);
444 array11[num6] = array11[num6].SetBit(1, cell.isObjDyed);
445 array11[num6] = array11[num6].SetBit(2, cell.crossWall);
446 if (cell.effect != null)
447 {
448 cellEffects[j * num4 + i] = cell.effect;
449 }
450 num6++;
451 }
452 }
453 compression = ((!EClass.core.config.test.compressSave) ? IO.Compression.None : IO.Compression.LZ4);
454 Write(path + "objVals", array);
455 Write(path + "blocks", array2);
456 Write(path + "blockMats", array3);
457 Write(path + "floors", array4);
458 Write(path + "floorMats", array5);
459 Write(path + "objs", array6);
460 Write(path + "objMats", array7);
461 Write(path + "decal", array8);
462 Write(path + "flags", array10);
463 Write(path + "flags2", array11);
464 Write(path + "dirs", array9);
465 Write(path + "heights", array12);
466 Write(path + "bridges", array13);
467 Write(path + "bridgeMats", array14);
468 Write(path + "bridgeHeights", array15);
469 Write(path + "bridgePillars", array16);
470 Write(path + "roofBlocks", array18);
471 Write(path + "roofBlockMats", array19);
472 Write(path + "roofBlockDirs", array17);
473 things.Sort((Thing a, Thing b) => a.stackOrder - b.stackOrder);
474 if (export == null)
475 {
476 foreach (Chara chara in charas)
477 {
478 if (!chara.IsGlobal)
479 {
480 serializedCharas.Add(chara);
481 }
482 }
483 GameIO.SaveFile(path + "map", this);
484 }
485 else
486 {
487 export.serializedCards.cards.Clear();
488 if (partial == null)
489 {
490 MapExportSetting mapExportSetting = exportSetting ?? new MapExportSetting();
491 foreach (Chara chara2 in charas)
492 {
493 if (export.usermap)
494 {
495 if ((!mapExportSetting.clearLocalCharas || chara2.IsPCFactionOrMinion) && !chara2.trait.IsUnique && !chara2.IsPC)
496 {
497 export.serializedCards.Add(chara2);
498 }
499 }
500 else if (!chara2.IsGlobal && chara2.isPlayerCreation)
501 {
502 export.serializedCards.Add(chara2);
503 }
504 }
505 foreach (Thing thing in things)
506 {
507 if (thing.isPlayerCreation && thing.c_altName != "DebugContainer")
508 {
509 export.serializedCards.Add(thing);
510 }
511 }
512 }
513 else
514 {
515 foreach (Thing thing2 in things)
516 {
517 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)
518 {
519 export.serializedCards.Add(thing2);
520 }
521 }
522 }
523 List<Thing> list = things;
524 things = new List<Thing>();
525 GameIO.SaveFile(path + "map", this);
526 things = list;
527 }
528 serializedCharas.Clear();
529 void Write(string _path, byte[] bytes)
530 {
531 IO.WriteLZ4(_path, bytes, compression);
532 }
533 }
534
535 public byte[] TryLoadFile(string path, string s, int size)
536 {
537 byte[] array = IO.ReadLZ4(path + s, size, compression);
538 if (array == null)
539 {
540 Debug.Log("Couldn't load:" + s);
541 return new byte[size];
542 }
543 return array;
544 }
545
546 public void Load(string path, bool import = false, PartialMap partial = null)
547 {
548 if (partial == null)
549 {
550 Debug.Log("Map Load:" + compression.ToString() + ": " + path);
551 }
552 int num = Size;
553 int num2 = Size;
554 if (partial != null)
555 {
556 num = partial.w;
557 num2 = partial.h;
558 Debug.Log(compression.ToString() + ": " + num + "/" + num2);
559 }
560 int size = num * num2;
561 cells = new Cell[num, num2];
562 if (bounds.maxX == 0)
563 {
564 bounds.SetBounds(0, 0, num - 1, num2 - 1);
565 }
566 SetBounds(0, 0, num - 1, num2 - 1);
567 byte[] bytes2 = TryLoad("objVals");
568 byte[] bytes3 = TryLoad("blockMats");
569 byte[] bytes4 = TryLoad("blocks");
570 byte[] bytes5 = TryLoad("floorMats");
571 byte[] bytes6 = TryLoad("floors");
572 byte[] bytes7 = TryLoad("objs");
573 byte[] bytes8 = TryLoad("objMats");
574 byte[] bytes9 = TryLoad("decal");
575 byte[] bytes10 = TryLoad("dirs");
576 byte[] bytes11 = TryLoad("flags");
577 byte[] bytes12 = TryLoad("flags2");
578 byte[] bytes13 = TryLoad("heights");
579 byte[] bytes14 = TryLoad("bridges");
580 byte[] bytes15 = TryLoad("bridgeMats");
581 byte[] bytes16 = TryLoad("bridgeHeights");
582 byte[] bytes17 = TryLoad("bridgePillars");
583 byte[] bytes18 = TryLoad("roofBlocks");
584 byte[] bytes19 = TryLoad("roofBlockMats");
585 byte[] bytes20 = TryLoad("roofBlockDirs");
586 if (bytes17.Length < size)
587 {
588 bytes17 = new byte[size];
589 }
590 if (bytes2.Length < size)
591 {
592 bytes2 = new byte[size];
593 }
594 if (bytes12.Length < size)
595 {
596 bytes12 = new byte[size];
597 }
598 Validate(ref bytes2, "objVals");
599 Validate(ref bytes3, "blockMats");
600 Validate(ref bytes4, "blocks");
601 Validate(ref bytes5, "floorMats");
602 Validate(ref bytes6, "floors");
603 Validate(ref bytes7, "objs");
604 Validate(ref bytes8, "objMats");
605 Validate(ref bytes9, "decal");
606 Validate(ref bytes10, "dirs");
607 Validate(ref bytes11, "flags");
608 Validate(ref bytes12, "flags2");
609 Validate(ref bytes13, "heights");
610 Validate(ref bytes14, "bridges");
611 Validate(ref bytes15, "bridgeMats");
612 Validate(ref bytes16, "bridgeHeights");
613 Validate(ref bytes17, "bridgePillars");
614 Validate(ref bytes18, "roofBlocks");
615 Validate(ref bytes19, "roofBlockMats");
616 Validate(ref bytes20, "roofBlockDirs");
617 int count = EClass.sources.floors.rows.Count;
618 int count2 = EClass.sources.materials.rows.Count;
619 int num3 = 0;
620 for (int i = 0; i < num; i++)
621 {
622 for (int j = 0; j < num2; j++)
623 {
624 Cell cell = (cells[i, j] = new Cell
625 {
626 x = (byte)i,
627 z = (byte)j,
628 objVal = bytes2[num3],
629 _blockMat = bytes3[num3],
630 _block = bytes4[num3],
631 _floorMat = bytes5[num3],
632 _floor = bytes6[num3],
633 obj = bytes7[num3],
634 objMat = bytes8[num3],
635 decal = bytes9[num3],
636 _dirs = bytes10[num3],
637 height = bytes13[num3],
638 _bridge = bytes14[num3],
639 _bridgeMat = bytes15[num3],
640 bridgeHeight = bytes16[num3],
641 bridgePillar = bytes17[num3],
642 _roofBlock = bytes18[num3],
643 _roofBlockMat = bytes19[num3],
644 _roofBlockDir = bytes20[num3],
645 isSeen = bytes11[num3].GetBit(1),
646 isHarvested = bytes11[num3].GetBit(2),
647 impassable = bytes11[num3].GetBit(3),
648 isModified = bytes11[num3].GetBit(4),
649 isClearSnow = bytes11[num3].GetBit(5),
650 isForceFloat = bytes11[num3].GetBit(6),
651 isToggleWallPillar = bytes11[num3].GetBit(7),
652 isWatered = bytes12[num3].GetBit(0),
653 isObjDyed = bytes12[num3].GetBit(1),
654 crossWall = bytes12[num3].GetBit(2)
655 });
656 if (cell._bridge >= count)
657 {
658 cell._bridge = 0;
659 }
660 if (cell._bridgeMat >= count2)
661 {
662 cell._bridgeMat = 1;
663 }
665 num3++;
666 }
667 }
668 things.ForeachReverse(delegate(Thing t)
669 {
670 if (t.Num <= 0 || t.isDestroyed)
671 {
672 Debug.Log("[bug] Removing bugged thing:" + t.Num + "/" + t.isDestroyed + "/" + t);
673 things.Remove(t);
674 }
675 });
676 foreach (KeyValuePair<int, CellEffect> cellEffect in cellEffects)
677 {
678 int key = cellEffect.Key;
679 int num4 = key % Size;
680 int num5 = key / Size;
681 cells[num4, num5].effect = cellEffect.Value;
682 if (cellEffect.Value.IsFire)
683 {
684 effectManager.GetOrCreate(new Point(num4, num5));
685 }
686 }
687 cellEffects.Clear();
689 byte[] TryLoad(string s)
690 {
691 return TryLoadFile(path, s, size);
692 }
693 void Validate(ref byte[] bytes, string id)
694 {
695 if (bytes.Length < size)
696 {
697 Debug.LogError("expection: size invalid:" + id + " " + bytes.Length + "/" + size);
698 bytes = new byte[size];
699 }
700 }
701 }
702
703 public void ValidateVersion()
704 {
706 }
707
708 public void OnLoad()
709 {
710 rooms.OnLoad();
711 tasks.OnLoad();
712 }
713
714 public void OnImport(ZoneExportData data)
715 {
716 tasks = new TaskManager();
717 data.serializedCards.Restore(this, data.orgMap, addToZone: false);
718 }
719
720 public void ExportMetaData(string _path, string id, PartialMap partial = null)
721 {
722 if (custom == null)
723 {
724 custom = new CustomData();
725 }
726 MapMetaData mapMetaData = new MapMetaData
727 {
728 name = EClass._zone.Name,
730 tag = (EClass._map.exportSetting?.tag ?? ""),
731 partial = partial,
732 underwater = EClass._zone.IsUnderwater
733 };
734 custom.id = (mapMetaData.id = id);
735 IO.SaveFile(_path + "meta", mapMetaData);
736 }
737
738 public static MapMetaData GetMetaData(string pathZip)
739 {
740 try
741 {
742 using ZipFile zipFile = ZipFile.Read(pathZip);
743 ZipEntry zipEntry = zipFile["meta"];
744 if (zipEntry != null)
745 {
746 using (MemoryStream stream = new MemoryStream())
747 {
748 zipEntry.Extract(stream);
749 MapMetaData mapMetaData = IO.LoadStreamJson<MapMetaData>(stream);
750 mapMetaData.path = pathZip;
751 return mapMetaData;
752 }
753 }
754 }
755 catch (Exception message)
756 {
757 if (Application.isEditor)
758 {
759 Debug.Log(message);
760 }
761 }
762 return null;
763 }
764
765 public static void UpdateMetaData(string pathZip, PartialMap partial = null)
766 {
767 IO.CreateTempDirectory();
768 ZipFile zipFile = ZipFile.Read(pathZip);
769 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
770 zipFile.ExtractAll(IO.TempPath);
771 zipFile.Dispose();
772 EClass._map.ExportMetaData(IO.TempPath + "/", Path.GetFileNameWithoutExtension(pathZip), partial);
773 using (zipFile = new ZipFile())
774 {
775 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
776 zipFile.AddDirectory(IO.TempPath);
777 zipFile.Save(pathZip);
778 zipFile.Dispose();
779 }
780 IO.DeleteTempDirectory();
781 }
782
783 public void AddCardOnActivate(Card c)
784 {
785 c.parent = zone;
787 Chara chara = c.Chara;
788 if (chara != null)
789 {
790 chara.currentZone = EClass._zone;
791 }
792 if (c.isChara)
793 {
794 if (!c.pos.IsInBounds)
795 {
797 }
798 }
799 else if (!c.pos.IsValid)
800 {
802 }
803 _AddCard(c.pos.x, c.pos.z, c, onAddToZone: true);
804 }
805
806 public void OnCardAddedToZone(Card t, int x, int z)
807 {
808 if (t.isChara)
809 {
810 charas.Add(t.Chara);
811 }
812 else
813 {
814 things.Add(t.Thing);
815 }
817 if (t.isChara && new Point(x, z).cell.HasFullBlock)
818 {
819 DestroyBlock(x, z);
820 }
821 _AddCard(x, z, t, onAddToZone: true);
823 }
824
826 {
829 _RemoveCard(t);
830 t.parent = null;
831 if (t.isChara)
832 {
833 charas.Remove(t.Chara);
834 }
835 else
836 {
837 things.Remove(t.Thing);
838 }
839 }
840
841 public void MoveCard(Point p, Card t)
842 {
843 _AddCard(p.x, p.z, t, onAddToZone: false);
844 }
845
846 public void _AddCard(int x, int z, Card t, bool onAddToZone)
847 {
848 if (!onAddToZone)
849 {
850 _RemoveCard(t);
851 }
852 t.pos.Set(x, z);
853 if (t.IsMultisize)
854 {
855 t.ForeachPoint(delegate(Point p, bool main)
856 {
857 p.cell.AddCard(t);
858 });
859 }
860 else
861 {
862 t.Cell.AddCard(t);
863 }
864 t.CalculateFOV();
865 if (t.isThing && !t.trait.IDActorEx.IsEmpty())
866 {
868 }
869 }
870
871 public void _RemoveCard(Card t)
872 {
873 if (t.IsMultisize)
874 {
875 t.ForeachPoint(delegate(Point p, bool main)
876 {
877 p.cell.RemoveCard(t);
878 });
879 }
880 else
881 {
882 t.Cell.RemoveCard(t);
883 }
884 t.ClearFOV();
885 }
886
887 public Cell GetCell(int index)
888 {
889 return cells[index % Size, index % SizeXZ / Size];
890 }
891
892 public void SetSeen(int x, int z, bool seen = true, bool refresh = true)
893 {
894 if (cells[x, z].isSeen != seen)
895 {
896 cells[x, z].isSeen = seen;
897 if (refresh)
898 {
900 }
902 }
903 }
904
905 public void RevealAll(bool reveal = true)
906 {
907 for (int i = 0; i < Size; i++)
908 {
909 for (int j = 0; j < Size; j++)
910 {
911 EClass._map.SetSeen(i, j, reveal, refresh: false);
912 }
913 }
916 }
917
918 public void Reveal(Point center, int power = 100)
919 {
920 ForeachSphere(center.x, center.z, 10 + power / 5, delegate(Point p)
921 {
922 if (EClass.rnd(power) >= Mathf.Min(p.Distance(center) * 10, power - 10))
923 {
924 EClass._map.SetSeen(p.x, p.z);
925 }
926 });
927 }
928
929 public void RefreshFOV(int x, int z, int radius = 6, bool recalculate = false)
930 {
931 ForeachSphere(x, z, radius, delegate(Point p)
932 {
933 List<Card> list = p.ListCards();
934 if (recalculate)
935 {
936 foreach (Card item in list)
937 {
938 item.RecalculateFOV();
939 }
940 return;
941 }
942 foreach (Card item2 in list)
943 {
944 item2.CalculateFOV();
945 }
946 });
947 }
948
949 public void RefreshFOVAll()
950 {
951 foreach (Card item in ((IEnumerable<Card>)EClass._map.things).Concat((IEnumerable<Card>)EClass._map.charas))
952 {
953 item.RecalculateFOV();
954 }
955 }
956
957 public void SetFloor(int x, int z, int idMat = 0, int idFloor = 0)
958 {
959 SetFloor(x, z, idMat, idFloor, 0);
960 }
961
962 public void SetFloor(int x, int z, int idMat, int idFloor, int dir)
963 {
964 Cell cell = cells[x, z];
965 cell._floorMat = (byte)idMat;
966 cell._floor = (byte)idFloor;
967 cell.floorDir = dir;
970 }
971
972 public void SetBridge(int x, int z, int height = 0, int idMat = 0, int idBridge = 0, int dir = 0)
973 {
974 Cell cell = cells[x, z];
975 cell.bridgeHeight = (byte)height;
976 cell._bridgeMat = (byte)idMat;
977 cell._bridge = (byte)idBridge;
978 cell.bridgePillar = 0;
979 cell.floorDir = dir;
980 if (cell.room != null)
981 {
982 cell.room.SetDirty();
983 }
985 }
986
987 public void SetRoofBlock(int x, int z, int idMat, int idBlock, int dir, int height)
988 {
989 Cell cell = cells[x, z];
990 cell._roofBlockMat = (byte)idMat;
991 cell._roofBlock = (byte)idBlock;
992 cell._roofBlockDir = (byte)(dir + height * 4);
994 }
995
996 public void SetBlock(int x, int z, int idMat = 0, int idBlock = 0)
997 {
998 SetBlock(x, z, idMat, idBlock, 0);
999 }
1000
1001 public void SetBlock(int x, int z, int idMat, int idBlock, int dir)
1002 {
1003 Cell cell = cells[x, z];
1004 bool hasFloodBlock = cell.HasFloodBlock;
1005 cell._blockMat = (byte)idMat;
1006 cell._block = (byte)idBlock;
1007 cell.blockDir = dir;
1008 if (cell.effect == null || !cell.effect.IsFire)
1009 {
1010 cell.effect = null;
1011 }
1012 cell.isToggleWallPillar = false;
1013 if (cell.room != null)
1014 {
1015 cell.room.SetDirty();
1016 }
1017 if (hasFloodBlock || cell.HasFloodBlock)
1018 {
1020 }
1022 }
1023
1024 public void OnSetBlockOrDoor(int x, int z)
1025 {
1026 new Point(x, z);
1027 TryRemoveRoom(x, z);
1028 if (x > 0)
1029 {
1030 TryRemoveRoom(x - 1, z);
1031 }
1032 if (x < Size - 1)
1033 {
1034 TryRemoveRoom(x + 1, z);
1035 }
1036 if (z > 0)
1037 {
1038 TryRemoveRoom(x, z - 1);
1039 }
1040 if (z < Size - 1)
1041 {
1042 TryRemoveRoom(x, z + 1);
1043 }
1044 if (x > 0 && z < Size - 1)
1045 {
1046 TryRemoveRoom(x - 1, z + 1);
1047 }
1048 roomHash.Clear();
1049 TryAddRoom(x, z);
1050 if (x > 0)
1051 {
1052 TryAddRoom(x - 1, z);
1053 }
1054 if (x < Size - 1)
1055 {
1056 TryAddRoom(x + 1, z);
1057 }
1058 if (z > 0)
1059 {
1060 TryAddRoom(x, z - 1);
1061 }
1062 if (z < Size - 1)
1063 {
1064 TryAddRoom(x, z + 1);
1065 }
1066 if (x > 0 && z < Size - 1)
1067 {
1068 TryAddRoom(x - 1, z + 1);
1069 }
1070 }
1071
1072 public void TryRemoveRoom(int x, int z)
1073 {
1074 if (!cells[x, z].HasFloodBlock)
1075 {
1076 Room room = cells[x, z].room;
1077 if (room != null)
1078 {
1079 rooms.RemoveRoom(room);
1080 }
1081 }
1082 }
1083
1084 public void TryAddRoom(int x, int z)
1085 {
1086 if (EClass._zone.DisableRooms || roomHash.Contains(x + z * Size) || cells[x, z].HasFloodBlock)
1087 {
1088 return;
1089 }
1090 FloodSpiller floodSpiller = flood;
1091 IFloodCell[,] array = cells;
1092 FloodSpiller.Result result = floodSpiller.SpillFlood(array, x, z);
1093 if (!result.IsValid)
1094 {
1095 return;
1096 }
1097 bool flag = false;
1098 foreach (IFloodCell item in result.visited)
1099 {
1100 if (item.hasDoor)
1101 {
1102 flag = true;
1103 break;
1104 }
1105 Cell cell = item as Cell;
1106 if (cell.sourceBlock.tileType.IsFloodDoor || cell.Front.hasDoor || cell.Right.hasDoor || cell.FrontRight.hasDoor || cell.Back.hasDoor || cell.Left.hasDoor || cell.BackLeft.hasDoor)
1107 {
1108 flag = true;
1109 break;
1110 }
1111 }
1112 if (!flag && IsIndoor)
1113 {
1114 foreach (IFloodCell item2 in result.visited)
1115 {
1116 Cell cell2 = item2 as Cell;
1117 if (cell2.detail == null || cell2.detail.things.Count == 0)
1118 {
1119 continue;
1120 }
1121 foreach (Thing thing in cell2.detail.things)
1122 {
1123 if (thing.trait is TraitRoomPlate || thing.trait is TraitHouseBoard)
1124 {
1125 flag = true;
1126 break;
1127 }
1128 }
1129 if (flag)
1130 {
1131 break;
1132 }
1133 }
1134 }
1135 if (!flag)
1136 {
1137 return;
1138 }
1139 Room room = rooms.AddRoom(new Room());
1140 foreach (IFloodCell item3 in result.visited)
1141 {
1142 Cell cell3 = item3 as Cell;
1143 byte b = cell3.x;
1144 byte b2 = cell3.z;
1145 room.AddPoint(new Point(b, b2));
1146 roomHash.Add(b + b2 * Size);
1147 if (b2 > 0 && cell3.Front.HasFloodBlock && cell3.Front.room == null)
1148 {
1149 room.AddPoint(new Point(b, b2 - 1));
1150 roomHash.Add(b + (b2 - 1) * Size);
1151 }
1152 if (b < Size - 1 && cell3.Right.HasFloodBlock && cell3.Right.room == null)
1153 {
1154 room.AddPoint(new Point(b + 1, b2));
1155 roomHash.Add(b + 1 + b2 * Size);
1156 }
1157 if (b2 > 0 && b < Size - 1 && cell3.FrontRight.HasFloodBlock && cell3.FrontRight.room == null)
1158 {
1159 room.AddPoint(new Point(b + 1, b2 - 1));
1160 roomHash.Add(b + 1 + (b2 - 1) * Size);
1161 }
1162 }
1163 }
1164
1165 public void SetBlockDir(int x, int z, int dir)
1166 {
1167 Cell cell = cells[x, z];
1168 cell._block = (byte)cell.sourceBlock.id;
1169 cell.blockDir = dir;
1170 }
1171
1172 public void ModFire(int x, int z, int amount)
1173 {
1174 Cell cell = cells[x, z];
1175 if (amount <= 0 || (!cell.IsTopWaterAndNoSnow && !cell.IsSnowTile && !EClass._zone.IsUnderwater))
1176 {
1177 if (cell.effect == null && amount > 0)
1178 {
1179 SE.Play("fire");
1180 }
1181 int num = amount + (cell.effect?.FireAmount ?? 0);
1182 if (num > 20)
1183 {
1184 num = 20;
1185 }
1186 if (num <= 0)
1187 {
1188 cell.effect = null;
1189 return;
1190 }
1191 cell.effect = new CellEffect
1192 {
1193 id = 3,
1194 amount = num
1195 };
1197 }
1198 }
1199
1200 public void TryShatter(Point pos, int ele, int power)
1201 {
1202 Element element = Element.Create(ele);
1203 List<Card> list = new List<Card>();
1204 bool fire = ele == 910;
1205 bool cold = ele == 911;
1206 _ = fire;
1207 List<Card> list2 = pos.ListCards();
1208 if (fire && (pos.cell.IsSnowTile || pos.cell.IsTopWater))
1209 {
1210 return;
1211 }
1212 foreach (Card item in list2)
1213 {
1214 if (item.ResistLvFrom(ele) >= 3 || item.trait is TraitBlanket || (EClass.rnd(3) == 0 && !CanCook(item)) || (item.IsPCFaction && EClass.rnd(3) == 0) || (fire && item.HasCondition<ConWet>()) || (cold && item.HasCondition<ConBurning>()))
1215 {
1216 continue;
1217 }
1219 {
1220 Card rootCard = item.GetRootCard();
1221 if (!rootCard.isChara || rootCard.Chara.IsPCFaction)
1222 {
1223 if (pos.IsSync)
1224 {
1225 Msg.Say("damage_protectCore", item);
1226 }
1227 continue;
1228 }
1229 }
1230 if (item.isThing && item.things.Count == 0)
1231 {
1232 list.Add(item);
1233 }
1234 else
1235 {
1236 if (ele == 911 && item.HasElement(1236))
1237 {
1238 continue;
1239 }
1240 Thing thing = ((ele == 910) ? item.things.FindBest<TraitBlanketFireproof>((Thing t) => -t.c_charges) : item.things.FindBest<TraitBlanketColdproof>((Thing t) => -t.c_charges));
1241 if (thing != null)
1242 {
1243 thing.ModCharge(-1);
1244 Card rootCard2 = item.GetRootCard();
1245 if (pos.IsSync)
1246 {
1247 Msg.Say((item.isChara ? "blanketInv_" : "blanketGround_") + element.source.alias, thing, item);
1248 }
1249 if (thing.c_charges <= 0)
1250 {
1251 thing.Die(element);
1252 if (rootCard2.IsPCParty)
1253 {
1255 }
1256 }
1257 continue;
1258 }
1259 foreach (Thing item2 in item.things.List((Thing a) => a.things.Count == 0))
1260 {
1261 Card parentCard = item2.parentCard;
1262 if (parentCard == null || (!(parentCard.trait is TraitChestMerchant) && !parentCard.HasEditorTag(EditorTag.PreciousContainer)))
1263 {
1264 list.Add(item2);
1265 }
1266 }
1267 }
1268 }
1269 list.Shuffle();
1270 int num = 0;
1271 foreach (Card item3 in list)
1272 {
1273 if (!item3.trait.CanBeDestroyed || item3.category.IsChildOf("currency") || item3.trait is TraitDoor || item3.trait is TraitFigure || item3.trait is TraitTrainingDummy || item3.rarity >= Rarity.Legendary)
1274 {
1275 continue;
1276 }
1277 Card rootCard3 = item3.GetRootCard();
1278 if (item3.IsEquipmentOrRangedOrAmmo && (EClass.rnd(4) != 0 || ((item3.IsRangedWeapon || item3.Thing.isEquipped) && rootCard3.IsPCFaction && EClass.rnd(4) != 0)))
1279 {
1280 continue;
1281 }
1282 switch (ele)
1283 {
1284 case 910:
1285 if (item3.isFireproof || (!item3.category.IsChildOf("book") && EClass.rnd(2) == 0))
1286 {
1287 continue;
1288 }
1289 break;
1290 case 911:
1291 if (!item3.category.IsChildOf("drink") && EClass.rnd(5) == 0)
1292 {
1293 continue;
1294 }
1295 break;
1296 }
1297 if (EClass.rnd(num * num) != 0)
1298 {
1299 continue;
1300 }
1301 bool flag = CanCook(item3);
1302 string text = "";
1303 if (flag)
1304 {
1305 if (fire)
1306 {
1307 List<SourceThing.Row> list3 = new List<SourceThing.Row>();
1308 foreach (RecipeSource item4 in RecipeManager.list)
1309 {
1310 if (!(item4.row is SourceThing.Row { isOrigin: false } row) || row.components.IsEmpty() || (row.components.Length >= 3 && !row.components[2].StartsWith('+')) || !row.Category.IsChildOf("meal"))
1311 {
1312 continue;
1313 }
1314 if (!row.factory.IsEmpty())
1315 {
1316 switch (row.factory[0])
1317 {
1318 case "chopper":
1319 case "mixer":
1320 case "camppot":
1321 case "cauldron":
1322 continue;
1323 }
1324 }
1325 if (row.components[0].Split('|').Contains(item3.id) || row.components[0].Split('|').Contains(item3.sourceCard._origin))
1326 {
1327 list3.Add(row);
1328 }
1329 }
1330 if (list3.Count > 0)
1331 {
1332 text = list3.RandomItem().id;
1333 }
1334 }
1335 else
1336 {
1337 text = "711";
1338 }
1339 }
1340 if (flag && !text.IsEmpty())
1341 {
1342 item3.GetRoot();
1343 Thing thing2 = item3.Split(1);
1344 List<Thing> list4 = new List<Thing>();
1345 list4.Add(thing2);
1346 Thing thing3 = ThingGen.Create(text);
1347 CraftUtil.MakeDish(thing3, list4, 999);
1348 thing3.elements.ModBase(2, EClass.curve(power / 10, 50, 10));
1349 if (pos.IsSync)
1350 {
1351 Msg.Say(((rootCard3 == item3) ? "cook_groundItem" : "cook_invItem") + (fire ? "" : "_cold"), thing2, rootCard3, thing3.Name);
1352 }
1353 if (rootCard3 == item3)
1354 {
1355 EClass._zone.AddCard(thing3, item3.pos);
1356 }
1357 else if (rootCard3.isChara)
1358 {
1359 rootCard3.Chara.Pick(thing3, msg: false);
1360 }
1361 else
1362 {
1363 rootCard3.AddThing(thing3);
1364 }
1365 thing2.Destroy();
1366 }
1367 else
1368 {
1369 int num2 = EClass.rnd(item3.Num) / 2 + 1;
1370 if (item3.Num > num2)
1371 {
1372 Thing thing4 = item3.Split(num2);
1373 if (pos.IsSync)
1374 {
1375 Msg.Say((rootCard3 == item3) ? "damage_groundItem" : "damage_invItem", thing4, rootCard3);
1376 }
1377 thing4.Destroy();
1378 if (rootCard3.IsPCFaction)
1379 {
1380 WidgetPopText.Say("popDestroy".lang(thing4.Name, rootCard3.Name));
1381 }
1382 }
1383 else
1384 {
1385 item3.Die(element);
1386 if (rootCard3.IsPCFaction)
1387 {
1388 WidgetPopText.Say("popDestroy".lang(item3.Name, rootCard3.Name));
1389 }
1390 }
1391 }
1392 if (rootCard3.IsPCParty)
1393 {
1395 }
1396 num++;
1397 }
1398 _ValidateInstalled(pos.x, pos.z);
1399 bool CanCook(Card c)
1400 {
1401 if ((fire || cold) && c.IsFood)
1402 {
1403 return c.category.IsChildOf("foodstuff");
1404 }
1405 return false;
1406 }
1407 }
1408
1409 public void Burn(int x, int z, bool instant = false)
1410 {
1411 Cell cell = cells[x, z];
1412 Point sharedPoint = cell.GetSharedPoint();
1413 if ((instant || EClass.rnd(10) == 0) && cell.HasObj)
1414 {
1415 if (cell.sourceObj.tileType is TileTypeTree)
1416 {
1417 SetObj(x, z, cell.matObj_fixed.id, 59, 0, EClass.rnd(4));
1418 }
1419 else
1420 {
1421 SetObj(x, z);
1422 if (EClass.rnd(2) == 0)
1423 {
1424 EClass._zone.AddCard(ThingGen.Create((EClass.rnd(2) == 0) ? "ash" : "ash2"), sharedPoint);
1425 }
1426 }
1427 }
1428 if ((instant || EClass.rnd(5) == 0) && cell._block != 0 && cell._block != 96)
1429 {
1430 if (EClass.rnd(10) == 0 || !cell.sourceBlock.tileType.IsWall)
1431 {
1432 cell._block = 0;
1433 }
1434 else
1435 {
1436 cell._block = 96;
1437 }
1438 SetObj(x, z);
1439 if (cell.room != null)
1440 {
1441 cell.room.SetDirty();
1442 }
1444 }
1445 if (instant || EClass.rnd(10) == 0)
1446 {
1447 if (EClass.rnd(4) != 0)
1448 {
1449 cell._floor = 49;
1450 }
1451 if (cell._bridge != 0 && EClass.rnd(5) != 0)
1452 {
1453 cell._bridge = 49;
1454 }
1455 }
1456 foreach (Card item in sharedPoint.ListCards())
1457 {
1458 if (item.trait.CanBeDestroyed && !item.trait.IsDoor && !item.isFireproof && !item.category.IsChildOf("currency") && item.rarity < Rarity.Legendary && !(item.trait is TraitFigure) && item.isThing)
1459 {
1460 if (instant)
1461 {
1462 item.Destroy();
1463 EClass._zone.AddCard(ThingGen.Create((EClass.rnd(2) == 0) ? "ash" : "ash2"), sharedPoint);
1464 }
1465 else
1466 {
1467 item.DamageHP(30, 910);
1468 }
1469 }
1470 }
1471 if (instant)
1472 {
1473 cell.effect = null;
1474 }
1475 }
1476
1477 public void SetLiquid(int x, int z, CellEffect effect = null)
1478 {
1479 Cell cell = cells[x, z];
1480 if (!cell.IsTopWaterAndNoSnow || effect == null)
1481 {
1482 cell.effect = effect;
1483 }
1484 }
1485
1486 public void SetLiquid(int x, int z, int id, int value = 1)
1487 {
1488 Cell cell = cells[x, z];
1489 if (!cell.IsTopWaterAndNoSnow || value == 0)
1490 {
1491 if (value > 3)
1492 {
1493 value = 3;
1494 }
1495 if (value <= 0)
1496 {
1497 cell.effect = null;
1498 return;
1499 }
1500 cell.effect = new CellEffect
1501 {
1502 id = id,
1503 amount = value
1504 };
1505 }
1506 }
1507
1508 public void SetEffect(int x, int z, CellEffect effect = null)
1509 {
1510 cells[x, z].effect = effect;
1511 }
1512
1513 public void ModLiquid(int x, int z, int amount)
1514 {
1515 Cell cell = cells[x, z];
1516 if (!cell.IsTopWaterAndNoSnow && cell.effect != null)
1517 {
1518 cell.effect.amount += amount;
1519 if (cell.effect.amount <= 0)
1520 {
1521 cell.effect = null;
1522 }
1523 }
1524 }
1525
1526 public void ClearRainAndDecal()
1527 {
1528 ForeachCell(delegate(Cell c)
1529 {
1530 c.effect = null;
1531 c.decal = 0;
1532 });
1533 }
1534
1535 public void SetObj(int x, int z, int id = 0, int value = 1, int dir = 0)
1536 {
1537 SetObj(x, z, (byte)EClass.sources.objs.rows[id].DefaultMaterial.id, id, value, dir);
1538 }
1539
1540 public void SetObj(int x, int z, int idMat, int idObj, int value, int dir, bool ignoreRandomMat = false)
1541 {
1542 Cell cell = cells[x, z];
1543 if (cell.sourceObj.id == 118 || idObj == 118)
1544 {
1545 EClass._zone.dirtyElectricity = true;
1546 }
1547 cell.obj = (byte)idObj;
1548 cell.objVal = (byte)value;
1549 cell.objMat = (byte)idMat;
1550 cell.objDir = dir;
1551 cell.isHarvested = false;
1552 cell.isObjDyed = false;
1553 SourceObj.Row sourceObj = cell.sourceObj;
1554 if (!ignoreRandomMat && !sourceObj.matCategory.IsEmpty())
1555 {
1556 int num = EClass._zone.DangerLv;
1557 if (sourceObj.tag.Contains("spot"))
1558 {
1559 num += EClass.pc.Evalue(1656) * 5;
1560 }
1561 cell.objMat = (byte)MATERIAL.GetRandomMaterialFromCategory(num, sourceObj.matCategory.Split(','), cell.matObj).id;
1562 }
1563 if (backerObjs.ContainsKey(cell.index))
1564 {
1565 backerObjs.Remove(cell.index);
1566 }
1567 if (plants.ContainsKey(cell.index))
1568 {
1569 plants.Remove(cell.index);
1570 }
1571 cell.growth?.OnSetObj();
1572 Critter.RebuildCritter(cell);
1574 }
1575
1576 public void AddBackerTree(bool draw)
1577 {
1579 int num = ((!draw) ? 1 : 2);
1580 EClass._map.bounds.ForeachCell(delegate(Cell c)
1581 {
1582 if (num > 0 && c.growth != null && c.growth.IsTree && c.growth.IsMature && (!EClass.player.doneBackers.Contains(item.id) || EClass.core.config.test.ignoreBackerDestoryFlag) && (c.sourceObj.alias == item.tree || item.tree == "random"))
1583 {
1584 backerObjs[c.index] = item.id;
1585 Debug.Log(c.index + "/" + c.x + "/" + c.z + "/" + item.id + "/" + item.Name + "/" + item.tree);
1586 num--;
1588 }
1589 });
1590 }
1591
1593 {
1594 if (!backerObjs.ContainsKey(p.index))
1595 {
1596 return null;
1597 }
1598 return EClass.sources.backers.map.TryGetValue(backerObjs[p.index]);
1599 }
1600
1601 public void ApplyBackerObj(Point p, int id = -1)
1602 {
1603 if (!p.HasObj)
1604 {
1605 return;
1606 }
1607 bool flag = p.sourceObj.id == 82;
1608 SourceBacker.Row row = ((id != -1) ? EClass.sources.backers.map.TryGetValue(id) : (flag ? EClass.sources.backers.listRemain.NextItem(ref BackerContent.indexRemain) : EClass.sources.backers.listTree.NextItem(ref BackerContent.indexTree)));
1609 if (row == null)
1610 {
1611 return;
1612 }
1614 {
1615 backerObjs[p.index] = row.id;
1616 if (flag)
1617 {
1618 p.cell.objDir = row.skin;
1619 }
1620 }
1621 else
1622 {
1623 backerObjs.Remove(p.index);
1624 }
1625 }
1626
1627 public void DropBlockComponent(Point point, TileRow r, SourceMaterial.Row mat, bool recoverBlock, bool isPlatform = false, Chara c = null)
1628 {
1630 {
1631 return;
1632 }
1633 Thing thing = null;
1634 if (r.components.Length == 0)
1635 {
1636 return;
1637 }
1639 if (recoverBlock)
1640 {
1641 thing = ((!(r is SourceFloor.Row)) ? ThingGen.CreateBlock(r.id, mat.id) : ThingGen.CreateFloor(r.id, mat.id, isPlatform));
1642 }
1643 else
1644 {
1645 RecipeSource recipeSource = RecipeManager.Get(r.RecipeID + (isPlatform ? "-b" : ""));
1646 if (recipeSource == null)
1647 {
1648 return;
1649 }
1650 string iDIngredient = recipeSource.GetIDIngredient();
1651 if (iDIngredient == null)
1652 {
1653 return;
1654 }
1655 thing = ThingGen.Create(iDIngredient);
1656 thing.ChangeMaterial(mat.alias);
1657 }
1659 {
1660 PutAway(thing);
1661 }
1662 else
1663 {
1664 TrySmoothPick(point, thing, c);
1665 }
1666 }
1667
1668 public void MineBlock(Point point, bool recoverBlock = false, Chara c = null, bool mineObj = true)
1669 {
1670 bool flag = ActionMode.Mine.IsRoofEditMode() && point.cell._roofBlock != 0;
1671 if (!point.IsValid || (!flag && !point.cell.HasBlock))
1672 {
1673 return;
1674 }
1675 SourceMaterial.Row row = (flag ? point.matRoofBlock : point.matBlock);
1676 byte b = (flag ? point.cell._roofBlock : point.cell._block);
1677 SourceBlock.Row row2 = EClass.sources.blocks.rows[b];
1678 Effect.Get("smoke").Play(point);
1679 Effect.Get("mine").Play(point).SetParticleColor(row.GetColor())
1680 .Emit(10 + EClass.rnd(10));
1681 point.PlaySound(row.GetSoundDead(row2));
1682 row.AddBlood(point, 8);
1683 bool flag2 = c == null || c.IsAgent || c.IsPCFactionOrMinion;
1685 {
1686 flag2 = false;
1687 }
1688 if (flag)
1689 {
1690 point.cell._roofBlock = 0;
1691 RefreshSingleTile(point.x, point.z);
1692 }
1693 else
1694 {
1695 if (point.cell.HasFullBlock)
1696 {
1697 RemoveLonelyRamps(point.cell);
1698 }
1699 point.SetBlock();
1700 if (flag2 && point.sourceObj.tileType.IsBlockMount && mineObj)
1701 {
1702 MineObj(point, null, c);
1703 }
1704 }
1705 if (flag2)
1706 {
1707 DropBlockComponent(point, row2, row, recoverBlock, isPlatform: false, c);
1708 }
1709 RefreshShadow(point.x, point.z);
1710 RefreshShadow(point.x, point.z - 1);
1711 ValidateInstalled(point);
1712 RefreshFOV(point.x, point.z);
1713 if (flag2 && !point.cell.isModified && !flag)
1714 {
1715 if (b == 17 || EClass.rnd(100) == 0)
1716 {
1717 zone.AddCard(ThingGen.Create("money2"), point);
1718 }
1719 if (EClass._zone.DangerLv >= 10 && EClass.rnd(200) == 0)
1720 {
1721 zone.AddCard(ThingGen.Create("crystal_earth"), point);
1722 }
1723 if (EClass._zone.DangerLv >= 25 && EClass.rnd(200) == 0)
1724 {
1725 zone.AddCard(ThingGen.Create("crystal_sun"), point);
1726 }
1727 if (EClass._zone.DangerLv >= 40 && EClass.rnd(200) == 0)
1728 {
1729 zone.AddCard(ThingGen.Create("crystal_mana"), point);
1730 }
1731 point.cell.isModified = true;
1732 }
1733 }
1734
1735 public void MineRamp(Point point, int ramp, bool recoverBlock = false)
1736 {
1737 if (point.IsValid && point.cell.HasFullBlock)
1738 {
1739 SourceMaterial.Row matBlock = point.matBlock;
1740 byte block = point.cell._block;
1741 Effect.Get("smoke").Play(point);
1742 Effect.Get("mine").Play(point).SetParticleColor(point.matBlock.GetColor())
1743 .Emit(10 + EClass.rnd(10));
1744 MineObj(point);
1745 int rampDir = EClass._map.GetRampDir(point.x, point.z, EClass.sources.blocks.rows[ramp].tileType);
1746 RemoveLonelyRamps(point.cell);
1747 SetBlock(point.x, point.z, point.cell._blockMat, ramp, rampDir);
1748 DropBlockComponent(point, EClass.sources.blocks.rows[block], matBlock, recoverBlock);
1749 }
1750 }
1751
1752 public void MineFloor(Point point, Chara c = null, bool recoverBlock = false, bool removePlatform = true)
1753 {
1754 if (!point.IsValid || (!point.HasFloor && !point.HasBridge))
1755 {
1756 return;
1757 }
1758 SourceMaterial.Row row = (point.cell.HasBridge ? point.matBridge : point.matFloor);
1759 SourceFloor.Row c2 = (point.cell.HasBridge ? point.sourceBridge : point.sourceFloor);
1760 Effect.Get("mine").Play(point).SetParticleColor(row.GetColor())
1761 .Emit(10 + EClass.rnd(10));
1762 point.PlaySound(row.GetSoundDead(c2));
1763 MineObj(point, null, c);
1764 if (point.cell.HasBridge && removePlatform)
1765 {
1766 DropBlockComponent(EClass.pc.pos, point.sourceBridge, point.matBridge, recoverBlock, isPlatform: true, c);
1767 EClass._map.SetBridge(point.x, point.z);
1768 if (point.IsSky)
1769 {
1770 EClass.pc.Kick(point, ignoreSelf: true);
1771 }
1772 return;
1773 }
1775 {
1776 DropBlockComponent(EClass.pc.pos, point.sourceFloor, row, recoverBlock, isPlatform: false, c);
1777 SetFloor(point.x, point.z, 0, 90);
1778 if (point.IsSky)
1779 {
1780 EClass.pc.Kick(point, ignoreSelf: true);
1781 }
1782 return;
1783 }
1784 if (zone.IsRegion || point.cell._floor == 40)
1785 {
1786 Thing thing = ThingGen.CreateRawMaterial(row);
1787 thing.ChangeMaterial(row.alias);
1788 TrySmoothPick(point, thing, c);
1789 }
1790 else
1791 {
1792 DropBlockComponent(point, point.sourceFloor, row, recoverBlock, isPlatform: false, c);
1793 }
1794 if (!EClass._zone.IsRegion && !point.sourceFloor.components[0].Contains("chunk@soil"))
1795 {
1796 point.SetFloor(EClass.sources.floors.rows[1].DefaultMaterial.id, 40);
1797 }
1798 }
1799
1800 public void RefreshShadow(int x, int z)
1801 {
1802 }
1803
1804 public void TrySmoothPick(Cell cell, Thing t, Chara c)
1805 {
1806 TrySmoothPick(cell.GetPoint(), t, c);
1807 }
1808
1809 public void TrySmoothPick(Point p, Thing t, Chara c)
1810 {
1811 if (c != null && c.IsAgent)
1812 {
1813 EClass.pc.PickOrDrop(p, t);
1814 }
1815 else if (c != null && (c.pos.Equals(p) || EClass.core.config.game.smoothPick || EClass._zone.IsRegion))
1816 {
1817 c.PickOrDrop(p, t);
1818 }
1819 else
1820 {
1821 EClass._zone.AddCard(t, p);
1822 }
1823 }
1824
1825 public void DestroyObj(Point point)
1826 {
1827 Cell cell = point.cell;
1828 SourceObj.Row sourceObj = cell.sourceObj;
1829 SourceMaterial.Row matObj = cell.matObj;
1830 if (sourceObj.tileType.IsBlockPass)
1831 {
1832 Effect.Get("smoke").Play(point);
1833 }
1834 Effect.Get("mine").Play(point).SetParticleColor(cell.matObj.GetColor())
1835 .Emit(10 + EClass.rnd(10));
1836 point.PlaySound(matObj.GetSoundDead());
1837 matObj.AddBlood(point, 3);
1838 }
1839
1840 public void MineObj(Point point, Task task = null, Chara c = null)
1841 {
1842 if (!point.IsValid || !point.HasObj)
1843 {
1844 return;
1845 }
1846 Cell cell = point.cell;
1847 SourceObj.Row sourceObj = cell.sourceObj;
1848 if (c == null && task != null)
1849 {
1850 c = task.owner;
1851 }
1852 bool num = c == null || c.IsAgent || c.IsPCFactionOrMinion;
1853 DestroyObj(point);
1854 if (num)
1855 {
1856 SourceMaterial.Row matObj_fixed = cell.matObj_fixed;
1857 if (task is TaskHarvest { IsReapSeed: not false })
1858 {
1859 int num2 = 1 + EClass.rnd(2) + ((EClass.rnd(3) == 0) ? 1 : 0);
1860 int soilCost = EClass._zone.GetSoilCost();
1861 int maxSoil = EClass._zone.MaxSoil;
1862 if (soilCost > maxSoil)
1863 {
1864 num2 -= EClass.rnd(2 + (soilCost - maxSoil) / 10);
1865 }
1866 if (num2 <= 0)
1867 {
1868 Msg.Say("seedSpoiled", cell.GetObjName());
1869 }
1870 else if (!EClass._zone.IsUserZone)
1871 {
1872 Thing t2 = TraitSeed.MakeSeed(sourceObj, TryGetPlant(cell)).SetNum(num2);
1873 EClass.pc.PickOrDrop(point, t2);
1874 }
1875 if (cell.growth.IsTree)
1876 {
1877 cell.isHarvested = true;
1878 return;
1879 }
1880 }
1881 else if (sourceObj.HasGrowth)
1882 {
1883 cell.growth.PopMineObj(c);
1884 }
1885 else
1886 {
1887 if (cell.HasBlock && (sourceObj.id == 18 || sourceObj.id == 19))
1888 {
1889 MineBlock(point, recoverBlock: false, c, mineObj: false);
1890 }
1892 {
1893 if (EClass.game.survival.OnMineWreck(point))
1894 {
1895 Rand.SetSeed();
1896 return;
1897 }
1898 Rand.SetSeed();
1899 }
1900 switch (sourceObj.alias)
1901 {
1902 case "nest_bird":
1903 if (EClass.rnd(5) <= 1)
1904 {
1905 Pop(ThingGen.Create((EClass.rnd(10) == 0) ? "egg_fertilized" : "_egg").TryMakeRandomItem());
1906 }
1907 break;
1908 }
1909 int num3 = EClass.rnd(EClass.rnd(sourceObj.components.Length) + 1);
1910 string[] array = sourceObj.components[num3].Split('/');
1911 Thing thing = ThingGen.Create(array[0].Split('|')[0], matObj_fixed.alias);
1912 if (array.Length > 1)
1913 {
1914 thing.SetNum(EClass.rnd(array[1].ToInt()) + 1);
1915 }
1916 Pop(thing);
1917 }
1918 }
1919 SetObj(point.x, point.z);
1920 cell.gatherCount = 0;
1921 void Pop(Thing t)
1922 {
1924 {
1926 {
1927 EClass._map.PutAway(t);
1928 }
1929 else
1930 {
1931 TrySmoothPick(point, t, c);
1932 }
1933 }
1934 }
1935 }
1936
1937 public void MineObjSound(Point point)
1938 {
1939 point.PlaySound(point.cell.matObj.GetSoundDead(point.cell.sourceObj));
1940 }
1941
1943 {
1944 return plants.TryGetValue(p.index);
1945 }
1946
1948 {
1949 return plants.TryGetValue(c.index);
1950 }
1951
1953 {
1954 PlantData plantData = new PlantData
1955 {
1956 seed = seed
1957 };
1958 plants[pos.index] = plantData;
1959 return plantData;
1960 }
1961
1962 public void RemovePlant(Point pos)
1963 {
1964 plants.Remove(pos.index);
1965 }
1966
1968 {
1969 _ValidateInstalled(p.x, p.z);
1970 _ValidateInstalled(p.x + 1, p.z);
1971 _ValidateInstalled(p.x - 1, p.z);
1972 _ValidateInstalled(p.x, p.z + 1);
1973 _ValidateInstalled(p.x, p.z - 1);
1974 }
1975
1976 public void _ValidateInstalled(int x, int y)
1977 {
1978 Point point = Point.shared.Set(x, y);
1979 if (!point.IsValid)
1980 {
1981 return;
1982 }
1983 List<Card> list = point.ListCards();
1984 CellDetail detail = point.cell.detail;
1985 if (detail == null)
1986 {
1987 return;
1988 }
1989 foreach (Card item in list)
1990 {
1991 if (!item.isThing || !item.trait.CanBeDestroyed || !item.IsInstalled)
1992 {
1993 continue;
1994 }
1995 HitResult hitResult = item.TileType._HitTest(point, item.Thing, canIgnore: false);
1996 if (item.Thing.stackOrder != detail.things.IndexOf(item.Thing) || (hitResult != HitResult.Valid && hitResult != HitResult.Warning))
1997 {
1998 if (EClass._zone.IsPCFaction || (!item.isNPCProperty && !(item.trait is TraitHarvest)))
1999 {
2000 item.SetPlaceState(PlaceState.roaming);
2001 }
2002 else if (item.rarity < Rarity.Legendary)
2003 {
2004 item.Die();
2005 }
2006 }
2007 }
2008 }
2009
2010 public void RemoveLonelyRamps(Cell cell)
2011 {
2012 for (int i = 0; i < 4; i++)
2013 {
2014 Cell dependedRamp = GetDependedRamp(cell);
2015 if (dependedRamp != null)
2016 {
2017 MineBlock(dependedRamp.GetPoint());
2018 continue;
2019 }
2020 break;
2021 }
2022 }
2023
2024 public void DestroyBlock(int x, int z)
2025 {
2026 SetBlock(x, z);
2027 }
2028
2029 public void AddDecal(int x, int z, int id, int amount = 1, bool refresh = true)
2030 {
2031 if (x < 0 || z < 0 || x >= Size || z >= Size)
2032 {
2033 return;
2034 }
2035 Cell cell = cells[x, z];
2036 if (cell.sourceFloor.tileType.AllowBlood && (cell.decal / 8 == id || cell.decal % 8 <= amount))
2037 {
2038 if (cell.decal / 8 != id && cell.decal % 8 == 0)
2039 {
2040 amount--;
2041 }
2042 int num = Mathf.Clamp(((cell.decal / 8 == id) ? (cell.decal % 8) : 0) + amount, 0, 7);
2043 cell.decal = (byte)(id * 8 + num);
2044 if (refresh)
2045 {
2047 }
2048 }
2049 }
2050
2051 public void SetDecal(int x, int z, int id = 0, int amount = 1, bool refresh = true)
2052 {
2053 cells[x, z].decal = (byte)((id != 0 && amount != 0) ? ((uint)(id * 8 + amount)) : 0u);
2054 if (refresh)
2055 {
2057 }
2058 }
2059
2060 public void SetFoormark(Point pos, int id, int angle, int offset = 0)
2061 {
2062 Cell cell = pos.cell;
2063 int tile = AngleToIndex(angle) + offset;
2064 Footmark footmark = new Footmark
2065 {
2066 tile = tile,
2067 remaining = 10
2068 };
2069 footmark.pos.Set(pos);
2070 footmarks.Add(footmark);
2071 cell.GetOrCreateDetail().footmark = footmark;
2072 }
2073
2074 public int AngleToIndex(int a)
2075 {
2076 if (EClass._zone.IsRegion)
2077 {
2078 return a switch
2079 {
2080 135 => 7,
2081 180 => 0,
2082 225 => 1,
2083 -90 => 2,
2084 -45 => 3,
2085 0 => 4,
2086 45 => 5,
2087 _ => 6,
2088 };
2089 }
2090 return a switch
2091 {
2092 135 => 0,
2093 180 => 1,
2094 225 => 2,
2095 -90 => 3,
2096 -45 => 4,
2097 0 => 5,
2098 45 => 6,
2099 _ => 7,
2100 };
2101 }
2102
2103 public void RefreshSingleTile(int x, int z)
2104 {
2105 cells[x, z].Refresh();
2106 }
2107
2108 public void RefreshAllTiles()
2109 {
2110 for (int i = 0; i < Size; i++)
2111 {
2112 for (int j = 0; j < Size; j++)
2113 {
2114 cells[i, j].Refresh();
2115 }
2116 }
2117 }
2118
2119 public void RefreshNeighborTiles(int x, int z)
2120 {
2121 cells[x, z].Refresh();
2122 for (int i = x - 2; i < x + 3; i++)
2123 {
2124 if (i < 0 || i >= Size)
2125 {
2126 continue;
2127 }
2128 for (int j = z - 2; j < z + 3; j++)
2129 {
2130 if (j >= 0 && j < Size && (x != i || z != j))
2131 {
2132 cells[i, j].Refresh();
2133 }
2134 }
2135 }
2136 }
2137
2138 public void QuickRefreshTile(int x, int z)
2139 {
2140 Cell cell = cells[x, z];
2141 Cell cell2 = ((x > 0) ? cells[x - 1, z] : Cell.Void);
2142 Cell cell3 = ((x + 1 < Size) ? cells[x + 1, z] : Cell.Void);
2143 Cell cell4 = ((z > 0) ? cells[x, z - 1] : Cell.Void);
2144 Cell cell5 = ((z + 1 < Size) ? cells[x, z + 1] : Cell.Void);
2145 Cell cell6 = ((x > 0 && z > 0) ? cells[x - 1, z - 1] : Cell.Void);
2146 Cell cell7 = ((x + 1 < Size && z > 0) ? cells[x + 1, z - 1] : Cell.Void);
2147 Cell cell8 = ((x > 0 && z + 1 < Size) ? cells[x - 1, z + 1] : Cell.Void);
2148 Cell cell9 = ((x + 1 < Size && z + 1 < Size) ? cells[x + 1, z + 1] : Cell.Void);
2149 cell.isSurrounded4d = cell2.HasFullBlock && cell3.HasFullBlock && cell4.HasFullBlock && cell5.HasFullBlock;
2150 cell.isSurrounded = cell.isSurrounded4d && cell6.HasFullBlock && cell7.HasFullBlock && cell8.HasFullBlock && cell9.HasFullBlock;
2151 }
2152
2153 public int GetRampDir(int x, int z, TileType blockType = null)
2154 {
2155 Cell cell = cells[x, z];
2156 if (cell.HasFullBlock)
2157 {
2158 if (blockType == null)
2159 {
2160 blockType = cell.sourceBlock.tileType;
2161 }
2162 Cell right = cell.Right;
2163 Cell front = cell.Front;
2164 Cell left = cell.Left;
2165 Cell back = cell.Back;
2166 if (!right.HasBlock && !right.IsVoid && left.HasFullBlock && front.CanBuildRamp(1) && back.CanBuildRamp(1))
2167 {
2168 return 1;
2169 }
2170 if (!front.HasBlock && !front.IsVoid && back.HasFullBlock && left.CanBuildRamp(0) && right.CanBuildRamp(0))
2171 {
2172 return 0;
2173 }
2174 if (!left.HasBlock && !left.IsVoid && right.HasFullBlock && front.CanBuildRamp(3) && back.CanBuildRamp(3))
2175 {
2176 return 3;
2177 }
2178 if (!back.HasBlock && !back.IsVoid && front.HasFullBlock && left.CanBuildRamp(2) && right.CanBuildRamp(2))
2179 {
2180 return 2;
2181 }
2182 if (!blockType.IsRamp)
2183 {
2184 return 0;
2185 }
2186 }
2187 return -1;
2188 }
2189
2191 {
2192 Cell right = cell.Right;
2193 if (right.HasRamp && !right.HasStairs && right.blockDir == 1)
2194 {
2195 return right;
2196 }
2197 Cell front = cell.Front;
2198 if (front.HasRamp && !front.HasStairs && front.blockDir == 0)
2199 {
2200 return front;
2201 }
2202 Cell left = cell.Left;
2203 if (left.HasRamp && !left.HasStairs && left.blockDir == 3)
2204 {
2205 return left;
2206 }
2207 Cell back = cell.Back;
2208 if (back.HasRamp && !back.HasStairs && back.blockDir == 2)
2209 {
2210 return back;
2211 }
2212 return null;
2213 }
2214
2215 public Point GetRandomPoint(Point center, int radius, int tries = 100, bool mustBeWalkable = true, bool requireLos = true)
2216 {
2217 Point point = new Point();
2218 for (int i = 0; i < tries; i++)
2219 {
2220 point.x = center.x + EClass.rnd(radius * 2 + 1) - radius;
2221 point.z = center.z + EClass.rnd(radius * 2 + 1) - radius;
2222 point.Clamp();
2223 if ((!mustBeWalkable || !point.cell.blocked) && (!requireLos || Los.IsVisible(center, point)))
2224 {
2225 return point;
2226 }
2227 }
2228 Debug.Log("GetRandomPoint failed center:" + center?.ToString() + " rad:" + radius);
2229 point.IsValid = false;
2230 return point;
2231 }
2232
2233 public new Point GetRandomEdge(int r = 3)
2234 {
2235 int num = 0;
2236 int num2 = 0;
2237 for (int i = 0; i < 10000; i++)
2238 {
2239 if (EClass.rnd(2) == 0)
2240 {
2241 num = ((EClass.rnd(2) == 0) ? EClass.rnd(r) : (Size - 1 - EClass.rnd(r)));
2242 num2 = EClass.rnd(Size);
2243 }
2244 else
2245 {
2246 num2 = ((EClass.rnd(2) == 0) ? EClass.rnd(r) : (Size - 1 - EClass.rnd(r)));
2247 num = EClass.rnd(Size);
2248 }
2249 Point surface = GetSurface(num, num2, walkable: false);
2250 if (surface.IsValid)
2251 {
2252 return surface;
2253 }
2254 }
2255 return GetSurface(Size / 2, Size / 2, walkable: false);
2256 }
2257
2259 {
2260 Point point = new Point();
2261 int num = ((EClass.rnd(2) == 0) ? 1 : (-1));
2262 int num2 = ((EClass.rnd(2) == 0) ? 1 : (-1));
2263 for (int i = 0; i < 3; i++)
2264 {
2265 point.x = center.x - num + i * num;
2266 for (int j = 0; j < 3; j++)
2267 {
2268 point.z = center.z - num2 + j * num2;
2269 if (point.IsValid && point.area == null && point.cell.CanHarvest())
2270 {
2271 return point;
2272 }
2273 }
2274 }
2275 return Point.Invalid;
2276 }
2277
2278 public List<Point> ListPointsInCircle(Point center, float radius, bool mustBeWalkable = true, bool los = true)
2279 {
2280 List<Point> list = new List<Point>();
2281 ForeachSphere(center.x, center.z, radius, delegate(Point p)
2282 {
2283 if ((!mustBeWalkable || !p.cell.blocked) && (!los || Los.IsVisible(center, p)))
2284 {
2285 list.Add(p.Copy());
2286 }
2287 });
2288 return list;
2289 }
2290
2291 public List<Chara> ListCharasInCircle(Point center, float radius, bool los = true)
2292 {
2293 List<Chara> list = new List<Chara>();
2294 foreach (Point item in ListPointsInCircle(center, radius, mustBeWalkable: false, los))
2295 {
2296 CellDetail detail = item.detail;
2297 if (detail == null || detail.charas.Count <= 0)
2298 {
2299 continue;
2300 }
2301 foreach (Chara chara in item.detail.charas)
2302 {
2303 list.Add(chara);
2304 }
2305 }
2306 return list;
2307 }
2308
2309 public List<Point> ListPointsInArc(Point center, Point to, int radius, float angle)
2310 {
2311 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));
2312 Point point = new Point(0, 0);
2313 List<Point> list = new List<Point>();
2314 float diff = point.GetAngle2(to2);
2315 ForeachSphere(center.x, center.z, radius, delegate(Point p)
2316 {
2317 float angle2 = center.GetAngle2(p);
2318 if ((Mathf.Abs(diff - angle2) < angle || Mathf.Abs(diff - angle2 + 360f) < angle || Mathf.Abs(360f - diff + angle2) < angle) && Los.IsVisible(center, p) && !p.IsBlocked)
2319 {
2320 list.Add(p.Copy());
2321 }
2322 });
2323 return list;
2324 }
2325
2326 public List<Point> ListPointsInLine(Point center, Point to, int radius)
2327 {
2328 return Los.ListVisible(center, to, radius);
2329 }
2330
2331 public void SetBounds(int size)
2332 {
2333 if (size > Size / 2 + 1)
2334 {
2335 size = Size / 2 - 1;
2336 }
2337 bounds.SetBounds(Size / 2 - size, Size / 2 - size, Size / 2 + size, Size / 2 + size);
2338 }
2339
2340 public void SetBounds(MapBounds b)
2341 {
2342 bounds.SetBounds(b.x, b.z, b.maxX, b.maxZ);
2343 bounds.Size = b.Size;
2344 }
2345
2346 public new void ForeachCell(Action<Cell> action)
2347 {
2348 for (int i = 0; i < Size; i++)
2349 {
2350 for (int j = 0; j < Size; j++)
2351 {
2352 action(cells[i, j]);
2353 }
2354 }
2355 }
2356
2357 public new void ForeachPoint(Action<Point> action)
2358 {
2359 Point point = new Point();
2360 for (int i = 0; i < Size; i++)
2361 {
2362 for (int j = 0; j < Size; j++)
2363 {
2364 action(point.Set(i, j));
2365 }
2366 }
2367 }
2368
2369 public new void ForeachXYZ(Action<int, int> action)
2370 {
2371 for (int i = 0; i < Size; i++)
2372 {
2373 for (int j = 0; j < Size; j++)
2374 {
2375 action(i, j);
2376 }
2377 }
2378 }
2379
2380 public void ForeachSphere(int _x, int _z, float r, Action<Point> action)
2381 {
2382 Point point = new Point();
2383 int num = (int)Mathf.Ceil(r);
2384 for (int i = _x - num; i < _x + num + 1; i++)
2385 {
2386 if (i < 0 || i >= Size)
2387 {
2388 continue;
2389 }
2390 for (int j = _z - num; j < _z + num + 1; j++)
2391 {
2392 if (j >= 0 && j < Size && (float)((i - _x) * (i - _x) + (j - _z) * (j - _z)) < r * r)
2393 {
2394 point.Set(i, j);
2395 action(point);
2396 }
2397 }
2398 }
2399 }
2400
2401 public void ForeachNeighbor(Point center, Action<Point> action)
2402 {
2403 int num = center.x;
2404 int num2 = center.z;
2405 Point point = new Point();
2406 for (int i = num - 1; i < num + 2; i++)
2407 {
2408 if (i < 0 || i >= Size)
2409 {
2410 continue;
2411 }
2412 for (int j = num2 - 1; j < num2 + 2; j++)
2413 {
2414 if (j >= 0 && j < Size)
2415 {
2416 point.Set(i, j);
2417 action(point);
2418 }
2419 }
2420 }
2421 }
2422
2423 public void Quake()
2424 {
2425 Point point = new Point();
2426 int num;
2427 for (num = 0; num < Size; num++)
2428 {
2429 int num2;
2430 for (num2 = 0; num2 < Size; num2++)
2431 {
2432 point.x = num;
2433 point.z = num2;
2434 point.Copy().Animate(AnimeID.Quake, animeBlock: true);
2435 num2 += EClass.rnd(2);
2436 }
2437 num += EClass.rnd(2);
2438 }
2439 }
2440
2441 public int CountChara(Faction faction)
2442 {
2443 int num = 0;
2444 foreach (Chara chara in charas)
2445 {
2446 if (chara.faction == faction)
2447 {
2448 num++;
2449 }
2450 }
2451 return num;
2452 }
2453
2454 public int CountGuest()
2455 {
2456 int num = 0;
2457 foreach (Chara chara in charas)
2458 {
2459 if (chara.IsGuest())
2460 {
2461 num++;
2462 }
2463 }
2464 return num;
2465 }
2466
2467 public int CountHostile()
2468 {
2469 int num = 0;
2470 foreach (Chara chara in charas)
2471 {
2472 if (!chara.IsPCFaction && chara.IsHostile())
2473 {
2474 num++;
2475 }
2476 }
2477 return num;
2478 }
2479
2480 public int CountWildAnimal()
2481 {
2482 int num = 0;
2483 foreach (Chara chara in charas)
2484 {
2485 if (!chara.IsPCFaction && chara.IsAnimal)
2486 {
2487 num++;
2488 }
2489 }
2490 return num;
2491 }
2492
2493 public int CountNonHostile()
2494 {
2495 int num = 0;
2496 foreach (Chara chara in charas)
2497 {
2498 if (!chara.IsPCFaction && !chara.IsHostile())
2499 {
2500 num++;
2501 }
2502 }
2503 return num;
2504 }
2505
2506 public List<Chara> ListChara(Faction faction)
2507 {
2508 List<Chara> list = new List<Chara>();
2509 foreach (Chara chara in charas)
2510 {
2511 if (chara.faction == faction)
2512 {
2513 list.Add(chara);
2514 }
2515 }
2516 return list;
2517 }
2518
2519 public List<Thing> ListThing<T>() where T : Trait
2520 {
2521 List<Thing> list = new List<Thing>();
2522 foreach (Thing thing in things)
2523 {
2524 if (thing.IsInstalled && thing.trait is T)
2525 {
2526 list.Add(thing);
2527 }
2528 }
2529 return list;
2530 }
2531
2532 public bool PutAway(Card c)
2533 {
2535 {
2536 return false;
2537 }
2538 if (c.isChara)
2539 {
2541 {
2542 return false;
2543 }
2544 c.Destroy();
2545 return true;
2546 }
2547 Thing thing = c.Thing;
2548 if (thing.parent != null)
2549 {
2550 thing.parent.RemoveCard(thing);
2551 }
2552 thing.isMasked = false;
2553 thing.isRoofItem = false;
2554 if (EClass._zone.IsPCFaction && EClass._map.props.installed.traits.GetRandomThing<TraitSpotStockpile>() != null)
2555 {
2556 EClass._zone.TryAddThingInSpot<TraitSpotStockpile>(thing);
2557 return true;
2558 }
2559 if (EClass.debug.enable)
2560 {
2562 return true;
2563 }
2564 EClass.pc.Pick(thing, msg: false);
2565 return true;
2566 }
2567
2568 public Chara FindChara(string id)
2569 {
2570 foreach (Chara chara in charas)
2571 {
2572 if (chara.id == id)
2573 {
2574 return chara;
2575 }
2576 }
2577 return null;
2578 }
2579
2580 public Chara FindChara(int uid)
2581 {
2582 foreach (Chara chara in charas)
2583 {
2584 if (chara.uid == uid)
2585 {
2586 return chara;
2587 }
2588 }
2589 return null;
2590 }
2591
2592 public Thing FindThing(Func<Thing, bool> func)
2593 {
2594 foreach (Thing thing in things)
2595 {
2596 if (func(thing))
2597 {
2598 return thing;
2599 }
2600 }
2601 return null;
2602 }
2603
2604 public Thing FindThing(int uid)
2605 {
2606 foreach (Thing thing in things)
2607 {
2608 if (thing.uid == uid)
2609 {
2610 return thing;
2611 }
2612 }
2613 return null;
2614 }
2615
2616 public T FindThing<T>() where T : Trait
2617 {
2618 foreach (Thing thing in things)
2619 {
2620 if (thing.trait is T)
2621 {
2622 return thing.trait as T;
2623 }
2624 }
2625 return null;
2626 }
2627
2628 public Thing FindThing(Type type, Chara c = null)
2629 {
2630 _things.Clear();
2631 foreach (Thing thing in EClass._map.props.installed.things)
2632 {
2633 if (type.IsAssignableFrom(thing.trait.GetType()) && thing.pos.IsPublicSpace())
2634 {
2635 _things.Add(thing);
2636 }
2637 }
2638 if (_things.Count <= 0)
2639 {
2640 return null;
2641 }
2642 return _things.RandomItem();
2643 }
2644
2645 public Thing FindThing(Type type, BaseArea area1, BaseArea area2 = null)
2646 {
2647 if (area1 == null && area2 == null)
2648 {
2649 return null;
2650 }
2651 Thing thing = Find(area1);
2652 if (thing == null && area2 != null)
2653 {
2654 thing = Find(area2);
2655 }
2656 return thing;
2657 Thing Find(BaseArea area)
2658 {
2659 _things.Clear();
2660 foreach (Thing thing2 in EClass._map.props.installed.things)
2661 {
2662 if (type.IsAssignableFrom(thing2.trait.GetType()) && thing2.pos.HasRoomOrArea(area))
2663 {
2664 _things.Add(thing2);
2665 }
2666 }
2667 if (_things.Count <= 0)
2668 {
2669 return null;
2670 }
2671 return _things.RandomItem();
2672 }
2673 }
2674
2675 public Thing FindThing(string workTag, BaseArea area1 = null, BaseArea area2 = null)
2676 {
2677 if (area1 == null && area2 == null)
2678 {
2679 return null;
2680 }
2681 Thing thing = null;
2682 PropSet orCreate = EClass._map.Installed.workMap.GetOrCreate(workTag);
2683 if (area1 != null)
2684 {
2685 IEnumerable<Card> enumerable = orCreate.Where((Card a) => a.pos.HasRoomOrArea(area1));
2686 if (enumerable.Count() > 0)
2687 {
2688 thing = enumerable.RandomItem() as Thing;
2689 }
2690 }
2691 if (thing == null && area2 != null)
2692 {
2693 IEnumerable<Card> enumerable2 = orCreate.Where((Card a) => a.pos.HasRoomOrArea(area2));
2694 if (enumerable2.Count() > 0)
2695 {
2696 thing = enumerable2.RandomItem() as Thing;
2697 }
2698 }
2699 return thing;
2700 }
2701
2702 public Thing FindThing(string workTag, Chara c)
2703 {
2704 Thing result = null;
2705 IEnumerable<Card> enumerable = from a in EClass._map.Installed.workMap.GetOrCreate(workTag)
2706 where a.pos.IsPublicSpace()
2707 select a;
2708 if (enumerable.Count() > 0)
2709 {
2710 result = enumerable.RandomItem() as Thing;
2711 }
2712 return result;
2713 }
2714
2716 {
2717 return (from a in ((IEnumerable<BaseArea>)rooms.listArea).Concat((IEnumerable<BaseArea>)rooms.listRoom)
2718 where a.type.IsPublicArea
2719 select a).RandomItem();
2720 }
2721
2722 public void RefreshSunMap()
2723 {
2724 if (!isDirtySunMap)
2725 {
2726 return;
2727 }
2728 sunMap.Clear();
2729 foreach (Card sun in EClass._map.props.installed.traits.suns)
2730 {
2731 foreach (Point item in sun.trait.ListPoints(null, onlyPassable: false))
2732 {
2733 sunMap.Add(item.index);
2734 }
2735 }
2736 isDirtySunMap = false;
2737 }
2738}
AnimeID
Definition: AnimeID.cs:2
EditorTag
Definition: EditorTag.cs:2
HitResult
Definition: HitResult.cs:2
PlaceState
Definition: PlaceState.cs:2
Rarity
Definition: Rarity.cs:2
int itemLost
Definition: AM_Adv.cs:109
override bool IsRoofEditMode(Card c=null)
Definition: AM_Mine.cs:19
void Add(Act a, string s="")
Definition: ActPlan.cs:11
static AM_Copy Copy
Definition: ActionMode.cs:45
bool IsActive
Definition: ActionMode.cs:121
virtual bool IsBuildMode
Definition: ActionMode.cs:181
static AM_Mine Mine
Definition: ActionMode.cs:33
static AM_Adv Adv
Definition: ActionMode.cs:15
static int indexTree
Definition: BackerContent.cs:3
static int indexRemain
Definition: BackerContent.cs:5
Version version
Definition: BaseCore.cs:17
static BaseCore Instance
Definition: BaseCore.cs:11
void KillActor()
string id
Definition: CardRow.cs:7
Definition: Card.cs:11
bool isDestroyed
Definition: Card.cs:73
Thing TryMakeRandomItem(int lv=-1, TryMakeRandomItemSource itemSource=TryMakeRandomItemSource.Default, Chara crafter=null)
Definition: Card.cs:5204
bool IsPCFactionOrMinion
Definition: Card.cs:2234
virtual bool IsMultisize
Definition: Card.cs:2120
virtual bool isThing
Definition: Card.cs:2043
virtual Chara Chara
Definition: Card.cs:2032
Thing Split(int a)
Definition: Card.cs:3382
bool IsAgent
Definition: Card.cs:2211
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3639
ElementContainerCard elements
Definition: Card.cs:39
string id
Definition: Card.cs:33
virtual void Die(Element e=null, Card origin=null, AttackSource attackSource=AttackSource.None, Chara originalTarget=null)
Definition: Card.cs:4783
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:2994
string c_altName
Definition: Card.cs:1567
virtual bool IsPCParty
Definition: Card.cs:2111
void CalculateFOV()
Definition: Card.cs:6176
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3057
string Name
Definition: Card.cs:2099
ICardParent parent
Definition: Card.cs:53
Thing SetNum(int a)
Definition: Card.cs:3393
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:7480
bool IsFood
Definition: Card.cs:2137
Point pos
Definition: Card.cs:57
void ClearFOV()
Definition: Card.cs:6265
int uid
Definition: Card.cs:120
Trait trait
Definition: Card.cs:51
void ModCharge(int a, bool destroy=false)
Definition: Card.cs:3842
void Destroy()
Definition: Card.cs:4850
bool HasEditorTag(EditorTag tag)
Definition: Card.cs:2562
ThingContainer things
Definition: Card.cs:36
bool IsInstalled
Definition: Card.cs:2343
virtual bool IsPC
Definition: Card.cs:2105
virtual bool isChara
Definition: Card.cs:2045
virtual Thing Thing
Definition: Card.cs:2020
Card GetRootCard()
Definition: Card.cs:3324
int Evalue(int ele)
Definition: Card.cs:2533
virtual bool IsPCFaction
Definition: Card.cs:2231
Cell Cell
Definition: Card.cs:2017
bool isPlayerCreation
Definition: Card.cs:480
Card parentCard
Definition: Card.cs:101
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:3034
int Num
Definition: Card.cs:156
SourceCategory.Row category
Definition: Card.cs:2011
int c_charges
Definition: Card.cs:1243
CardRenderer renderer
Definition: Card.cs:59
List< Thing > things
Definition: CellDetail.cs:11
List< Chara > charas
Definition: CellDetail.cs:13
Footmark footmark
Definition: CellDetail.cs:17
int amount
Definition: CellEffect.cs:26
int FireAmount
Definition: CellEffect.cs:150
bool IsFire
Definition: CellEffect.cs:135
Definition: Cell.cs:7
byte _block
Definition: Cell.cs:30
bool CanHarvest()
Definition: Cell.cs:1664
Room room
Definition: Cell.cs:102
void RemoveCard(Card c)
Definition: Cell.cs:1566
SourceBlock.Row sourceBlock
Definition: Cell.cs:1052
bool IsSnowTile
Definition: Cell.cs:782
bool HasBlock
Definition: Cell.cs:643
byte objMat
Definition: Cell.cs:42
bool CanBuildRamp(int dir)
Definition: Cell.cs:1143
SourceFloor.Row sourceFloor
Definition: Cell.cs:1054
CellEffect effect
Definition: Cell.cs:94
byte _bridge
Definition: Cell.cs:46
byte _floor
Definition: Cell.cs:34
Cell Back
Definition: Cell.cs:153
bool HasStairs
Definition: Cell.cs:855
byte decal
Definition: Cell.cs:44
bool HasBridge
Definition: Cell.cs:671
Point GetSharedPoint()
Definition: Cell.cs:1106
bool isHarvested
Definition: Cell.cs:330
bool IsTopWaterAndNoSnow
Definition: Cell.cs:712
bool isClearSnow
Definition: Cell.cs:450
Cell Front
Definition: Cell.cs:129
SourceMaterial.Row matObj
Definition: Cell.cs:1036
CellDetail GetOrCreateDetail()
Definition: Cell.cs:1533
byte objVal
Definition: Cell.cs:40
byte _floorMat
Definition: Cell.cs:36
byte _blockMat
Definition: Cell.cs:32
void Refresh()
Definition: Cell.cs:1152
void Reset()
Definition: Cell.cs:1526
bool isModified
Definition: Cell.cs:438
byte _roofBlock
Definition: Cell.cs:50
byte _bridgeMat
Definition: Cell.cs:48
bool IsTopWater
Definition: Cell.cs:700
byte height
Definition: Cell.cs:72
GrowSystem growth
Definition: Cell.cs:225
bool isWatered
Definition: Cell.cs:342
CellDetail detail
Definition: Cell.cs:92
byte _roofBlockDir
Definition: Cell.cs:54
bool HasFloodBlock
Definition: Cell.cs:1017
bool isToggleWallPillar
Definition: Cell.cs:558
byte z
Definition: Cell.cs:58
Cell Left
Definition: Cell.cs:165
byte _roofBlockMat
Definition: Cell.cs:52
bool isSeen
Definition: Cell.cs:282
void AddCard(Card c)
Definition: Cell.cs:1550
byte obj
Definition: Cell.cs:38
SourceObj.Row sourceObj
Definition: Cell.cs:1072
Cell BackLeft
Definition: Cell.cs:213
string GetObjName()
Definition: Cell.cs:1604
bool isForceFloat
Definition: Cell.cs:306
byte x
Definition: Cell.cs:56
Point GetPoint()
Definition: Cell.cs:1101
bool impassable
Definition: Cell.cs:402
static Cell Void
Definition: Cell.cs:10
bool HasObj
Definition: Cell.cs:641
Cell Right
Definition: Cell.cs:141
bool crossWall
Definition: Cell.cs:630
bool isObjDyed
Definition: Cell.cs:618
bool HasRamp
Definition: Cell.cs:837
byte bridgeHeight
Definition: Cell.cs:74
int index
Definition: Cell.cs:114
bool hasDoor
Definition: Cell.cs:258
int blockDir
Definition: Cell.cs:898
byte _dirs
Definition: Cell.cs:28
bool HasFullBlock
Definition: Cell.cs:817
bool IsVoid
Definition: Cell.cs:959
SourceMaterial.Row matObj_fixed
Definition: Cell.cs:1039
Cell FrontRight
Definition: Cell.cs:177
byte bridgePillar
Definition: Cell.cs:82
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:501
Faction faction
Definition: Chara.cs:425
override bool IsPC
Definition: Chara.cs:610
override bool IsGlobal
Definition: Chara.cs:608
Point orgPos
Definition: Chara.cs:21
bool IsAnimal
Definition: Chara.cs:865
void PickOrDrop(Point p, string idThing, int idMat=-1, int num=1, bool msg=true)
Definition: Chara.cs:4167
override bool IsPCFaction
Definition: Chara.cs:669
void Kick(Point p, bool ignoreSelf=false)
Definition: Chara.cs:5484
bool IsGuest()
Definition: Chara.cs:6308
bool IsHostile()
Definition: Chara.cs:6225
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4187
Definition: ConWet.cs:2
bool ignoreBackerDestoryFlag
Definition: CoreConfig.cs:555
new GameConfig game
Definition: CoreConfig.cs:602
bool enable
Definition: CoreDebug.cs:286
bool godBuild
Definition: CoreDebug.cs:304
Thing GetOrCreateDebugContainer()
Definition: CoreDebug.cs:747
bool ignoreBuildRule
Definition: CoreDebug.cs:185
CoreConfig config
Definition: Core.cs:70
static void MakeDish(Thing food, int lv, Chara crafter=null)
Definition: CraftUtil.cs:61
static void RebuildCritter(Cell cell)
Definition: Critter.cs:93
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Scene scene
Definition: EClass.cs:30
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:68
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static int rnd(long a)
Definition: EClass.cs:58
static SourceManager sources
Definition: EClass.cs:42
static FactionBranch Branch
Definition: EClass.cs:22
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
Definition: Effect.cs:7
static Effect Get(Effect original)
Definition: Effect.cs:85
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:100
Element ModBase(int ele, int v)
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1097
bool HasItemProtection
Point pos
Definition: Footmark.cs:3
static FowProfile Load(string id)
Definition: FowProfile.cs:9
Definition: GameIO.cs:10
static void SaveFile(string path, object obj)
Definition: GameIO.cs:244
bool disableUsermapBenefit
Definition: Game.cs:8
SurvivalManager survival
Definition: Game.cs:224
static void Load(string id, bool cloud)
Definition: Game.cs:318
GamePrincipal principal
Definition: Game.cs:221
static string id
Definition: Game.cs:147
bool Save(bool isAutoSave=false, bool silent=false)
Definition: Game.cs:1008
bool IsSurvival
Definition: Game.cs:272
void PopMineObj(Chara c=null)
Definition: GrowSystem.cs:528
virtual bool IsMature
Definition: GrowSystem.cs:103
virtual void OnSetObj()
Definition: GrowSystem.cs:264
virtual bool IsTree
Definition: GrowSystem.cs:87
Compression
Definition: IO.cs:13
LogicalPoint GetOrCreate(Point point)
Definition: Los.cs:5
static List< Point > ListVisible(Point p1, Point p2, int radius, Action< Point, bool > _onVisit=null)
Definition: Los.cs:90
static bool IsVisible(Point p1, Point p2, Action< Point, bool > _onVisit=null)
Definition: Los.cs:167
static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string cat, SourceMaterial.Row fallback)
Definition: MATERIAL.cs:85
int Size
Definition: MapBounds.cs:20
int maxZ
Definition: MapBounds.cs:17
void SetBounds(int _x, int _z, int _maxX, int _maxZ)
Definition: MapBounds.cs:30
Point GetSurface(int x, int z, bool walkable=true)
Definition: MapBounds.cs:171
int maxX
Definition: MapBounds.cs:14
void ForeachCell(Action< Cell > action)
Definition: MapBounds.cs:279
int x
Definition: MapBounds.cs:8
Point GetCenterPos()
Definition: MapBounds.cs:52
string idSceneProfile
Definition: MapConfig.cs:8
bool indoor
Definition: MapConfig.cs:29
string idFowProfile
Definition: MapConfig.cs:11
Definition: Map.cs:13
bool IsIndoor
Definition: Map.cs:131
new void ForeachXYZ(Action< int, int > action)
Definition: Map.cs:2369
List< int > _plNight
Definition: Map.cs:58
new void ForeachCell(Action< Cell > action)
Definition: Map.cs:2346
void TrySmoothPick(Point p, Thing t, Chara c)
Definition: Map.cs:1809
Thing FindThing(Type type, BaseArea area1, BaseArea area2=null)
Definition: Map.cs:2645
void ResetEditorPos()
Definition: Map.cs:357
void RefreshNeighborTiles(int x, int z)
Definition: Map.cs:2119
Thing FindThing(Func< Thing, bool > func)
Definition: Map.cs:2592
bool isGenerated
Definition: Map.cs:129
Cell GetCell(int index)
Definition: Map.cs:887
PlantData TryGetPlant(Point p)
Definition: Map.cs:1942
void ForeachSphere(int _x, int _z, float r, Action< Point > action)
Definition: Map.cs:2380
Dictionary< int, int > gatherCounts
Definition: Map.cs:61
BitArray32 bits
Definition: Map.cs:75
void Shift(Vector2Int offset)
Definition: Map.cs:254
Thing FindThing(Type type, Chara c=null)
Definition: Map.cs:2628
void ExportMetaData(string _path, string id, PartialMap partial=null)
Definition: Map.cs:720
Chara FindChara(string id)
Definition: Map.cs:2568
IEnumerable< Card > Cards
Definition: Map.cs:135
void RefreshSunMap()
Definition: Map.cs:2722
void RefreshSingleTile(int x, int z)
Definition: Map.cs:2103
void SetBridge(int x, int z, int height=0, int idMat=0, int idBridge=0, int dir=0)
Definition: Map.cs:972
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
Definition: Map.cs:2215
void RemovePlant(Point pos)
Definition: Map.cs:1962
BaseArea FindPublicArea()
Definition: Map.cs:2715
static void UpdateMetaData(string pathZip, PartialMap partial=null)
Definition: Map.cs:765
void DestroyObj(Point point)
Definition: Map.cs:1825
void Save(string path, ZoneExportData export=null, PartialMap partial=null)
Definition: Map.cs:376
void Reset()
Definition: Map.cs:345
int SizeXZ
Definition: Map.cs:133
PropsInstalled Installed
Definition: Map.cs:123
void TrySmoothPick(Cell cell, Thing t, Chara c)
Definition: Map.cs:1804
void AddCardOnActivate(Card c)
Definition: Map.cs:783
Thing FindThing(int uid)
Definition: Map.cs:2604
Dictionary< int, CellEffect > cellEffects
Definition: Map.cs:64
void TryShatter(Point pos, int ele, int power)
Definition: Map.cs:1200
void RefreshFOV(int x, int z, int radius=6, bool recalculate=false)
Definition: Map.cs:929
List< Point > ListPointsInArc(Point center, Point to, int radius, float angle)
Definition: Map.cs:2309
HashSet< int > roomHash
Definition: Map.cs:105
int CountNonHostile()
Definition: Map.cs:2493
void MoveCard(Point p, Card t)
Definition: Map.cs:841
Thing FindThing(string workTag, Chara c)
Definition: Map.cs:2702
void AddBackerTree(bool draw)
Definition: Map.cs:1576
void Reveal(Point center, int power=100)
Definition: Map.cs:918
FloodSpiller flood
Definition: Map.cs:93
void SetBlockDir(int x, int z, int dir)
Definition: Map.cs:1165
void SetBounds(int size)
Definition: Map.cs:2331
void MineObj(Point point, Task task=null, Chara c=null)
Definition: Map.cs:1840
void OnDeactivate()
Definition: Map.cs:205
void SetLiquid(int x, int z, CellEffect effect=null)
Definition: Map.cs:1477
void OnCardRemovedFromZone(Card t)
Definition: Map.cs:825
void SetZone(Zone _zone)
Definition: Map.cs:181
Point GetNearbyResourcePoint(Point center)
Definition: Map.cs:2258
void SetDecal(int x, int z, int id=0, int amount=1, bool refresh=true)
Definition: Map.cs:2051
PropsRoaming Roaming
Definition: Map.cs:125
PlantData TryGetPlant(Cell c)
Definition: Map.cs:1947
int CountChara(Faction faction)
Definition: Map.cs:2441
void MineBlock(Point point, bool recoverBlock=false, Chara c=null, bool mineObj=true)
Definition: Map.cs:1668
bool revealed
Definition: Map.cs:103
List< Chara > ListCharasInCircle(Point center, float radius, bool los=true)
Definition: Map.cs:2291
int CountHostile()
Definition: Map.cs:2467
void SetFloor(int x, int z, int idMat, int idFloor, int dir)
Definition: Map.cs:962
List< Thing > things
Definition: Map.cs:49
void OnDeserialized(StreamingContext context)
Definition: Map.cs:148
void SetFoormark(Point pos, int id, int angle, int offset=0)
Definition: Map.cs:2060
void RefreshFOVAll()
Definition: Map.cs:949
byte[] TryLoadFile(string path, string s, int size)
Definition: Map.cs:535
void _ValidateInstalled(int x, int y)
Definition: Map.cs:1976
int GetRampDir(int x, int z, TileType blockType=null)
Definition: Map.cs:2153
List< Thing > ListThing< T >()
Definition: Map.cs:2519
Dictionary< int, int > backerObjs
Definition: Map.cs:67
int CountGuest()
Definition: Map.cs:2454
List< Point > ListPointsInLine(Point center, Point to, int radius)
Definition: Map.cs:2326
List< int > _plDay
Definition: Map.cs:55
Playlist plDay
Definition: Map.cs:77
int AngleToIndex(int a)
Definition: Map.cs:2074
CustomData custom
Definition: Map.cs:40
List< Chara > deadCharas
Definition: Map.cs:46
void ModFire(int x, int z, int amount)
Definition: Map.cs:1172
void _AddCard(int x, int z, Card t, bool onAddToZone)
Definition: Map.cs:846
void Burn(int x, int z, bool instant=false)
Definition: Map.cs:1409
void MineObjSound(Point point)
Definition: Map.cs:1937
void OnSerializing(StreamingContext context)
Definition: Map.cs:138
void SetSeen(int x, int z, bool seen=true, bool refresh=true)
Definition: Map.cs:892
PropsManager props
Definition: Map.cs:91
void ModLiquid(int x, int z, int amount)
Definition: Map.cs:1513
void MineFloor(Point point, Chara c=null, bool recoverBlock=false, bool removePlatform=true)
Definition: Map.cs:1752
void SetFloor(int x, int z, int idMat=0, int idFloor=0)
Definition: Map.cs:957
void SetBounds(MapBounds b)
Definition: Map.cs:2340
int seed
Definition: Map.cs:19
void SetBlock(int x, int z, int idMat=0, int idBlock=0)
Definition: Map.cs:996
PlantData AddPlant(Point pos, Thing seed)
Definition: Map.cs:1952
RoomManager rooms
Definition: Map.cs:31
bool PutAway(Card c)
Definition: Map.cs:2532
void TryRemoveRoom(int x, int z)
Definition: Map.cs:1072
void SetReference()
Definition: Map.cs:195
BiomeProfile[,] biomes
Definition: Map.cs:95
List< Footmark > footmarks
Definition: Map.cs:99
POIMap poiMap
Definition: Map.cs:97
void SetRoofBlock(int x, int z, int idMat, int idBlock, int dir, int height)
Definition: Map.cs:987
void ClearRainAndDecal()
Definition: Map.cs:1526
void Reload()
Definition: Map.cs:310
new Point GetRandomEdge(int r=3)
Definition: Map.cs:2233
void OnLoad()
Definition: Map.cs:708
void OnImport(ZoneExportData data)
Definition: Map.cs:714
int CountWildAnimal()
Definition: Map.cs:2480
new void ForeachPoint(Action< Point > action)
Definition: Map.cs:2357
void TryAddRoom(int x, int z)
Definition: Map.cs:1084
void DestroyBlock(int x, int z)
Definition: Map.cs:2024
void QuickRefreshTile(int x, int z)
Definition: Map.cs:2138
List< Chara > serializedCharas
Definition: Map.cs:43
float sizeModifier
Definition: Map.cs:127
Cell[,] cells
Definition: Map.cs:85
static bool isDirtySunMap
Definition: Map.cs:16
static MapMetaData GetMetaData(string pathZip)
Definition: Map.cs:738
virtual void OnSerializing()
Definition: Map.cs:143
List< Thing > _things
Definition: Map.cs:107
void _RemoveCard(Card t)
Definition: Map.cs:871
Zone zone
Definition: Map.cs:87
void RemoveLonelyRamps(Cell cell)
Definition: Map.cs:2010
void SetBlock(int x, int z, int idMat, int idBlock, int dir)
Definition: Map.cs:1001
T FindThing< T >()
Definition: Map.cs:2616
int _bits
Definition: Map.cs:22
void SetLiquid(int x, int z, int id, int value=1)
Definition: Map.cs:1486
TaskManager tasks
Definition: Map.cs:34
void ValidateInstalled(Point p)
Definition: Map.cs:1967
void DropBlockComponent(Point point, TileRow r, SourceMaterial.Row mat, bool recoverBlock, bool isPlatform=false, Chara c=null)
Definition: Map.cs:1627
MapExportSetting exportSetting
Definition: Map.cs:73
void SetEffect(int x, int z, CellEffect effect=null)
Definition: Map.cs:1508
void OnCardAddedToZone(Card t, int x, int z)
Definition: Map.cs:806
Version version
Definition: Map.cs:28
Thing FindThing(string workTag, BaseArea area1=null, BaseArea area2=null)
Definition: Map.cs:2675
FowProfile fowProfile
Definition: Map.cs:101
void ForeachNeighbor(Point center, Action< Point > action)
Definition: Map.cs:2401
bool isBreakerDown
Definition: Map.cs:110
MapConfig config
Definition: Map.cs:37
void OnSetBlockOrDoor(int x, int z)
Definition: Map.cs:1024
void Load(string path, bool import=false, PartialMap partial=null)
Definition: Map.cs:546
Chara FindChara(int uid)
Definition: Map.cs:2580
Playlist plNight
Definition: Map.cs:79
CellEffectManager effectManager
Definition: Map.cs:89
void ReloadRoom()
Definition: Map.cs:325
Cell GetDependedRamp(Cell cell)
Definition: Map.cs:2190
PropsStocked Stocked
Definition: Map.cs:121
void MineRamp(Point point, int ramp, bool recoverBlock=false)
Definition: Map.cs:1735
void ValidateVersion()
Definition: Map.cs:703
List< Point > ListPointsInCircle(Point center, float radius, bool mustBeWalkable=true, bool los=true)
Definition: Map.cs:2278
void CreateNew(int size, bool setReference=true)
Definition: Map.cs:153
List< Chara > charas
Definition: Map.cs:81
void AddDecal(int x, int z, int id, int amount=1, bool refresh=true)
Definition: Map.cs:2029
void RevealAll(bool reveal=true)
Definition: Map.cs:905
IO.Compression compression
Definition: Map.cs:25
void SetObj(int x, int z, int idMat, int idObj, int value, int dir, bool ignoreRandomMat=false)
Definition: Map.cs:1540
void Resize(int newSize)
Definition: Map.cs:226
Dictionary< int, PlantData > plants
Definition: Map.cs:70
void RefreshAllTiles()
Definition: Map.cs:2108
void Quake()
Definition: Map.cs:2423
List< Chara > ListChara(Faction faction)
Definition: Map.cs:2506
List< TransAnime > pointAnimes
Definition: Map.cs:83
void RefreshShadow(int x, int z)
Definition: Map.cs:1800
void ApplyBackerObj(Point p, int id=-1)
Definition: Map.cs:1601
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
Definition: Map.cs:1535
SourceBacker.Row GetBackerObj(Point p)
Definition: Map.cs:1592
static HashSet< int > sunMap
Definition: Map.cs:14
MapBounds bounds
Definition: Map.cs:52
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
Definition: NoGoal.cs:4
Definition: POIMap.cs:4
IPathfinder pathfinder
Definition: PathManager.cs:24
static PathManager Instance
Definition: PathManager.cs:16
HashSet< int > doneBackers
Definition: Player.cs:993
void ClearMapHighlights()
Definition: Player.cs:2316
Definition: Point.cs:9
static Point shared
Definition: Point.cs:20
SourceMaterial.Row matBlock
Definition: Point.cs:55
SourceMaterial.Row matFloor
Definition: Point.cs:57
int index
Definition: Point.cs:49
static Point Invalid
Definition: Point.cs:28
bool HasBridge
Definition: Point.cs:209
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1035
Point Copy()
Definition: Point.cs:479
bool IsSky
Definition: Point.cs:212
Point Set(int _x, int _z)
Definition: Point.cs:491
bool IsBlocked
Definition: Point.cs:351
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
SourceMaterial.Row matBridge
Definition: Point.cs:59
void SetFloor(int idMat=0, int idFloor=0)
Definition: Point.cs:907
SoundSource PlaySound(string id, bool synced=true, float v=1f, bool spatial=true)
Definition: Point.cs:1237
SourceObj.Row sourceObj
Definition: Point.cs:69
bool Equals(int _x, int _z)
Definition: Point.cs:944
SourceFloor.Row sourceFloor
Definition: Point.cs:65
void SetBlock(int idMat=0, int idBlock=0)
Definition: Point.cs:902
bool IsValid
Definition: Point.cs:88
bool HasObj
Definition: Point.cs:137
bool HasRoomOrArea(BaseArea a)
Definition: Point.cs:409
Area area
Definition: Point.cs:73
bool HasFloor
Definition: Point.cs:207
int Distance(Point p)
Definition: Point.cs:973
Point Clamp(bool useBounds=false)
Definition: Point.cs:992
bool IsInBounds
Definition: Point.cs:104
Cell cell
Definition: Point.cs:51
float GetAngle2(Point to)
Definition: Point.cs:601
void Animate(AnimeID id, bool animeBlock=false)
Definition: Point.cs:1286
SourceFloor.Row sourceBridge
Definition: Point.cs:67
bool IsPublicSpace()
Definition: Point.cs:437
PropsInstalled installed
Definition: PropsManager.cs:8
PropsRoaming roaming
Definition: PropsManager.cs:10
void OnCardAddedToZone(Card c)
Definition: PropsManager.cs:25
PropsStocked stocked
Definition: PropsManager.cs:6
TraitManager traits
Definition: Props.cs:18
List< Thing > things
Definition: Props.cs:20
Dictionary< string, PropSet > workMap
Definition: Props.cs:16
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37
static void BuildList()
static List< RecipeSource > list
Definition: RecipeManager.cs:9
static RecipeSource Get(string id)
RenderRow row
Definition: RecipeSource.cs:5
string GetIDIngredient()
string[] tag
Definition: RenderRow.cs:58
virtual string RecipeID
Definition: RenderRow.cs:105
TileType tileType
Definition: RenderRow.cs:77
string[] components
Definition: RenderRow.cs:52
Room AddRoom(Room r)
Definition: RoomManager.cs:110
void RefreshAll()
Definition: RoomManager.cs:43
void RemoveRoom(Room r)
Definition: RoomManager.cs:119
List< Room > listRoom
Definition: RoomManager.cs:13
List< Area > listArea
Definition: RoomManager.cs:10
void OnLoad()
Definition: RoomManager.cs:26
Definition: Room.cs:4
void SetDirty()
Definition: Room.cs:213
static SceneProfile Load(string id)
Definition: SceneProfile.cs:18
Definition: Scene.cs:8
ActionMode actionMode
Definition: Scene.cs:79
void AddActorEx(Card c, Action< ActorEx > onBeforeSetOwner=null)
Definition: Scene.cs:1015
void Init(Mode newMode)
Definition: Scene.cs:178
Mode
Definition: Scene.cs:10
void Restore(Map map, Map orgMap, bool addToZone, PartialMap partial=null)
List< Row > listRemain
Definition: SourceBacker.cs:67
List< Row > listTree
Definition: SourceBacker.cs:73
SourceMaterial materials
SourceObj objs
SourceBlock blocks
SourceBacker backers
SourceFloor floors
void AddBlood(Point p, int a=1)
string GetSoundDead(RenderRow c=null)
bool HasGrowth
Definition: SourceObj.cs:26
string matCategory
Definition: SourceObj.cs:21
virtual bool IsRegion
Definition: Spatial.cs:503
virtual string Name
Definition: Spatial.cs:497
bool OnMineWreck(Point point)
void OnLoad()
Definition: TaskManager.cs:66
Definition: Task.cs:4
static Thing CreateRawMaterial(SourceMaterial.Row m)
Definition: ThingGen.cs:68
static Thing CreateBlock(int id, int idMat)
Definition: ThingGen.cs:101
static Thing CreateFloor(int id, int idMat, bool platform=false)
Definition: ThingGen.cs:108
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
int stackOrder
Definition: Thing.cs:13
string alias
Definition: TileRow.cs:12
int id
Definition: TileRow.cs:8
virtual bool IsBlockPass
Definition: TileType.cs:153
virtual bool IsUnique
Definition: TraitChara.cs:33
TraitMap suns
Definition: TraitManager.cs:14
static Thing MakeSeed(SourceObj.Row obj, PlantData plant=null)
Definition: TraitSeed.cs:88
Definition: Trait.cs:7
virtual string IDActorEx
Definition: Trait.cs:174
virtual List< Point > ListPoints(Point center=null, bool onlyPassable=true)
Definition: Trait.cs:748
virtual bool IsDoor
Definition: Trait.cs:57
virtual void OnAddedToZone()
Definition: Trait.cs:675
virtual bool CanCopyInBlueprint
Definition: Trait.cs:153
virtual void OnRemovedFromZone()
Definition: Trait.cs:679
virtual bool CanOnlyCarry
Definition: Trait.cs:290
static void UpdateMap(List< Cell > newPoints)
static void Say(string text, FontColor fontColor=FontColor.Default, Sprite sprite=null)
SerializedCards serializedCards
Definition: Zone.cs:12
void Revive()
Definition: Zone.cs:1097
virtual bool IsSkyLevel
Definition: Zone.cs:262
virtual bool DisableRooms
Definition: Zone.cs:118
virtual int MaxSoil
Definition: Zone.cs:513
virtual bool IsUserZone
Definition: Zone.cs:266
void RemoveCard(Card t)
Definition: Zone.cs:1977
override int DangerLv
Definition: Zone.cs:107
bool IsPCFaction
Definition: Zone.cs:470
virtual bool IsUnderwater
Definition: Zone.cs:264
int GetSoilCost()
Definition: Zone.cs:3588
Card AddCard(Card t, Point point)
Definition: Zone.cs:1937
void RemoveCard(Card c)
void Init(IPathfindGrid _grid, WeightCell[,] _weightMap, int size)
uint Bits
Definition: BitArray32.cs:6
int GetInt()
Definition: Version.cs:21