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