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