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