19 public bool isBreakerDown
37 return this.props.stocked;
47 return this.props.installed;
57 return this.props.roaming;
63 public float sizeModifier
67 return 1f / (16384f / (float)this.SizeXZ);
73 public bool isGenerated
77 return this.Size != 0;
87 return this.config.indoor;
97 return this.Size * this.Size;
103 public IEnumerable<Card> Cards
107 return this.things.Concat(this.charas);
113 private void OnSerializing(StreamingContext context)
115 this._bits = (int)this.bits.Bits;
119 protected virtual void OnSerializing()
125 private void OnDeserialized(StreamingContext context)
127 this.bits.Bits = (uint)this._bits;
131 public void CreateNew(
int size,
bool setReference =
true)
133 Debug.Log(
"Map CreateNew:");
135 this.cells =
new Cell[this.Size, this.Size];
140 maxX = this.Size - 1,
141 maxZ = this.Size - 1,
144 base.SetBounds(0, 0, this.Size - 1, this.Size - 1);
145 this.ForeachXYZ(delegate(
int x,
int z)
147 this.cells[x, z] =
new Cell
160 public void SetZone(
Zone _zone)
163 this.zone.bounds = this.bounds;
164 this.bounds.Size = this.Size;
167 EClass.scene.profile =
SceneProfile.Load(this.config.idSceneProfile.IsEmpty(
"default"));
168 if (!this.config.idFowProfile.IsEmpty())
170 this.fowProfile =
FowProfile.Load(this.config.idFowProfile);
175 public void SetReference()
177 CellDetail.map =
this;
182 Cell.Size = this.Size;
183 Cell.cells = this.cells;
186 pathfinder.Init(
this, weightMap, this.Size);
190 public void OnDeactivate()
192 this.charas.ForeachReverse(delegate(
Chara c)
197 this.zone.RemoveCard(c);
198 c.currentZone = this.zone;
201 foreach (
Thing thing
in this.things)
203 if (thing.renderer.hasActor)
205 thing.renderer.KillActor();
208 EClass.player.ClearMapHighlights();
212 public void Resize(
int newSize)
217 if (thing.pos.x >= newSize || thing.pos.z >= newSize)
219 this.MoveCard(p, thing);
224 if (chara.pos.x >= newSize || chara.pos.z >= newSize)
226 this.MoveCard(p, chara);
229 this.bounds.Size = newSize;
231 this.maxX = (this.maxZ = this.Size);
232 this.cells = Util.ResizeArray<
Cell>(
EClass._map.cells, newSize, newSize, (
int x,
int y) =>
new Cell
242 public void Shift(Vector2Int offset)
244 TweenUtil.Tween(0.1f,
null, delegate()
248 card.pos.x += offset.x;
249 card.pos.z += offset.y;
250 card.pos.Clamp(
false);
252 Cell[,] array =
new Cell[this.Size, this.Size];
253 for (
int i = 0; i < this.Size; i++)
255 int num = i - offset.y;
256 for (
int j = 0; j < this.Size; j++)
258 int num2 = j - offset.x;
259 if (num2 >= 0 && num2 < this.Size && num >= 0 && num < this.Size)
261 array[j, i] = this.cells[num2, num];
265 array[j, i] =
new Cell
274 this.bounds.x += offset.x;
275 this.bounds.z += offset.y;
276 this.bounds.maxX += offset.x;
277 this.bounds.maxZ += offset.y;
278 if (this.bounds.x < 0)
282 if (this.bounds.z < 0)
286 if (this.bounds.maxX >
this.Size)
288 this.bounds.maxX = this.Size;
290 if (this.bounds.maxZ >
this.Size)
292 this.bounds.maxZ = this.Size;
304 EClass.game.Save(
false,
null,
false);
307 this.RevealAll(
true);
308 TweenUtil.Tween(0.1f,
null, delegate()
315 public void ReloadRoom()
317 List<Thing> list =
new List<Thing>();
318 foreach (
Thing thing
in this.things)
320 if (thing.trait.IsDoor)
325 foreach (
Thing thing2
in list)
327 Point pos = thing2.pos;
328 EClass._zone.RemoveCard(thing2);
329 EClass._zone.AddCard(thing2, pos);
332 this.rooms.RefreshAll();
338 for (
int i = 0; i < this.Size; i++)
340 for (
int j = 0; j < this.Size; j++)
342 this.cells[i, j].Reset();
349 public void ResetEditorPos()
352 foreach (
Chara chara
in this.charas)
354 if (chara.isPlayerCreation && chara.orgPos !=
null)
356 this.MoveCard(chara.orgPos, chara);
359 foreach (
Thing thing
in this.things)
371 this.version =
EClass.core.version;
372 Debug.Log(
"#io saving map:" + path);
373 IO.CreateDirectory(path);
376 int num3 = this.Size;
377 int num4 = this.Size;
380 num = partial.offsetX;
381 num2 = partial.offsetZ;
385 int num5 = num3 * num4;
386 byte[] array =
new byte[num5];
387 byte[] array2 =
new byte[num5];
388 byte[] array3 =
new byte[num5];
389 byte[] array4 =
new byte[num5];
390 byte[] array5 =
new byte[num5];
391 byte[] array6 =
new byte[num5];
392 byte[] array7 =
new byte[num5];
393 byte[] array8 =
new byte[num5];
394 byte[] array9 =
new byte[num5];
395 byte[] array10 =
new byte[num5];
396 byte[] array11 =
new byte[num5];
397 byte[] array12 =
new byte[num5];
398 byte[] array13 =
new byte[num5];
399 byte[] array14 =
new byte[num5];
400 byte[] array15 =
new byte[num5];
401 byte[] array16 =
new byte[num5];
402 byte[] array17 =
new byte[num5];
403 byte[] array18 =
new byte[num5];
404 byte[] array19 =
new byte[num5];
405 this.cellEffects.Clear();
407 for (
int i = num; i < num + num3; i++)
409 for (
int j = num2; j < num2 + num4; j++)
411 Cell cell = this.cells[i, j];
412 array[num6] = cell.objVal;
413 array3[num6] = cell._blockMat;
414 array2[num6] = cell._block;
415 array5[num6] = cell._floorMat;
416 array4[num6] = cell._floor;
417 array6[num6] = cell.obj;
418 array7[num6] = cell.objMat;
419 array8[num6] = cell.decal;
420 array9[num6] = cell._dirs;
421 array12[num6] = cell.height;
422 array13[num6] = cell._bridge;
423 array14[num6] = cell._bridgeMat;
424 array15[num6] = cell.bridgeHeight;
425 array17[num6] = cell._roofBlockDir;
426 array18[num6] = cell._roofBlock;
427 array19[num6] = cell._roofBlockMat;
428 array16[num6] = cell.bridgePillar;
429 array10[num6] = array10[num6].SetBit(1, cell.isSeen);
430 array10[num6] = array10[num6].SetBit(2, cell.isHarvested);
431 array10[num6] = array10[num6].SetBit(3, cell.impassable);
432 array10[num6] = array10[num6].SetBit(4, cell.isModified);
433 array10[num6] = array10[num6].SetBit(5, cell.isClearSnow);
434 array10[num6] = array10[num6].SetBit(6, cell.isForceFloat);
435 array10[num6] = array10[num6].SetBit(7, cell.isToggleWallPillar);
436 array11[num6] = array11[num6].SetBit(0, cell.isWatered);
437 array11[num6] = array11[num6].SetBit(1, cell.isObjDyed);
438 if (cell.effect !=
null)
440 this.cellEffects[j * num4 + i] = cell.effect;
445 IO.WriteLZ4(path +
"objVals", array);
446 IO.WriteLZ4(path +
"blocks", array2);
447 IO.WriteLZ4(path +
"blockMats", array3);
448 IO.WriteLZ4(path +
"floors", array4);
449 IO.WriteLZ4(path +
"floorMats", array5);
450 IO.WriteLZ4(path +
"objs", array6);
451 IO.WriteLZ4(path +
"objMats", array7);
452 IO.WriteLZ4(path +
"decal", array8);
453 IO.WriteLZ4(path +
"flags", array10);
454 IO.WriteLZ4(path +
"flags2", array11);
455 IO.WriteLZ4(path +
"dirs", array9);
456 IO.WriteLZ4(path +
"heights", array12);
457 IO.WriteLZ4(path +
"bridges", array13);
458 IO.WriteLZ4(path +
"bridgeMats", array14);
459 IO.WriteLZ4(path +
"bridgeHeights", array15);
460 IO.WriteLZ4(path +
"bridgePillars", array16);
461 IO.WriteLZ4(path +
"roofBlocks", array18);
462 IO.WriteLZ4(path +
"roofBlockMats", array19);
463 IO.WriteLZ4(path +
"roofBlockDirs", array17);
464 this.things.Sort((
Thing a,
Thing b) => a.stackOrder - b.stackOrder);
467 foreach (
Chara chara
in this.charas)
471 this.serializedCharas.Add(chara);
474 GameIO.SaveFile(path +
"map",
this);
478 export.serializedCards.cards.Clear();
481 foreach (
Chara chara2
in this.charas)
485 if (!chara2.trait.IsUnique && !chara2.IsPC)
487 export.serializedCards.Add(chara2);
490 else if (!chara2.IsGlobal && chara2.isPlayerCreation)
492 export.serializedCards.Add(chara2);
495 using (List<Thing>.Enumerator enumerator2 = this.things.GetEnumerator())
497 while (enumerator2.MoveNext())
499 Thing thing = enumerator2.Current;
500 if (thing.isPlayerCreation && thing.c_altName !=
"DebugContainer")
502 export.serializedCards.Add(thing);
508 foreach (
Thing thing2
in this.things)
510 if ((
ActionMode.Copy.IsActive || thing2.trait.CanCopyInBlueprint) && thing2.pos.x >= num && thing2.pos.z >= num2 && thing2.pos.x < num + num3 && thing2.pos.z < num2 + num4)
512 export.serializedCards.Add(thing2);
516 List<Thing> list = this.things;
517 this.things =
new List<Thing>();
518 GameIO.SaveFile(path +
"map",
this);
521 this.serializedCharas.Clear();
525 public void Load(
string path,
bool import =
false,
PartialMap partial =
null)
527 Map.<>c__DisplayClass67_0 CS$<>8__locals1 =
new Map.<>c__DisplayClass67_0();
528 CS$<>8__locals1.path = path;
529 CS$<>8__locals1.<>4__this =
this;
532 Debug.Log(
"Map Load:" + CS$<>8__locals1.path);
535 int num2 = this.Size;
540 Debug.Log(num.ToString() +
"/" + num2.ToString());
542 CS$<>8__locals1.size = num * num2;
543 this.cells =
new Cell[num, num2];
544 if (this.bounds.maxX == 0)
546 this.bounds.SetBounds(0, 0, num - 1, num2 - 1);
548 base.SetBounds(0, 0, num - 1, num2 - 1);
549 byte[] array = CS$<>8__locals1.<Load>g__TryLoad|0(
"objVals");
550 byte[] array2 = CS$<>8__locals1.<Load>g__TryLoad|0(
"blockMats");
551 byte[] array3 = CS$<>8__locals1.<Load>g__TryLoad|0(
"blocks");
552 byte[] array4 = CS$<>8__locals1.<Load>g__TryLoad|0(
"floorMats");
553 byte[] array5 = CS$<>8__locals1.<Load>g__TryLoad|0(
"floors");
554 byte[] array6 = CS$<>8__locals1.<Load>g__TryLoad|0(
"objs");
555 byte[] array7 = CS$<>8__locals1.<Load>g__TryLoad|0(
"objMats");
556 byte[] array8 = CS$<>8__locals1.<Load>g__TryLoad|0(
"decal");
557 byte[] array9 = CS$<>8__locals1.<Load>g__TryLoad|0(
"dirs");
558 byte[] array10 = CS$<>8__locals1.<Load>g__TryLoad|0(
"flags");
559 byte[] array11 = CS$<>8__locals1.<Load>g__TryLoad|0(
"flags2");
560 byte[] array12 = CS$<>8__locals1.<Load>g__TryLoad|0(
"heights");
561 byte[] array13 = CS$<>8__locals1.<Load>g__TryLoad|0(
"bridges");
562 byte[] array14 = CS$<>8__locals1.<Load>g__TryLoad|0(
"bridgeMats");
563 byte[] array15 = CS$<>8__locals1.<Load>g__TryLoad|0(
"bridgeHeights");
564 byte[] array16 = CS$<>8__locals1.<Load>g__TryLoad|0(
"bridgePillars");
565 byte[] array17 = CS$<>8__locals1.<Load>g__TryLoad|0(
"roofBlocks");
566 byte[] array18 = CS$<>8__locals1.<Load>g__TryLoad|0(
"roofBlockMats");
567 byte[] array19 = CS$<>8__locals1.<Load>g__TryLoad|0(
"roofBlockDirs");
568 if (array16.Length < CS$<>8__locals1.size)
570 array16 =
new byte[CS$<>8__locals1.size];
572 if (array.Length < CS$<>8__locals1.size)
574 array =
new byte[CS$<>8__locals1.size];
576 if (array11.Length < CS$<>8__locals1.size)
578 array11 =
new byte[CS$<>8__locals1.size];
580 CS$<>8__locals1.<Load>g__Validate|1(ref array,
"objVals");
581 CS$<>8__locals1.<Load>g__Validate|1(ref array2,
"blockMats");
582 CS$<>8__locals1.<Load>g__Validate|1(ref array3,
"blocks");
583 CS$<>8__locals1.<Load>g__Validate|1(ref array4,
"floorMats");
584 CS$<>8__locals1.<Load>g__Validate|1(ref array5,
"floors");
585 CS$<>8__locals1.<Load>g__Validate|1(ref array6,
"objs");
586 CS$<>8__locals1.<Load>g__Validate|1(ref array7,
"objMats");
587 CS$<>8__locals1.<Load>g__Validate|1(ref array8,
"decal");
588 CS$<>8__locals1.<Load>g__Validate|1(ref array9,
"dirs");
589 CS$<>8__locals1.<Load>g__Validate|1(ref array10,
"flags");
590 CS$<>8__locals1.<Load>g__Validate|1(ref array11,
"flags2");
591 CS$<>8__locals1.<Load>g__Validate|1(ref array12,
"heights");
592 CS$<>8__locals1.<Load>g__Validate|1(ref array13,
"bridges");
593 CS$<>8__locals1.<Load>g__Validate|1(ref array14,
"bridgeMats");
594 CS$<>8__locals1.<Load>g__Validate|1(ref array15,
"bridgeHeights");
595 CS$<>8__locals1.<Load>g__Validate|1(ref array16,
"bridgePillars");
596 CS$<>8__locals1.<Load>g__Validate|1(ref array17,
"roofBlocks");
597 CS$<>8__locals1.<Load>g__Validate|1(ref array18,
"roofBlockMats");
598 CS$<>8__locals1.<Load>g__Validate|1(ref array19,
"roofBlockDirs");
600 for (
int i = 0; i < num; i++)
602 for (
int j = 0; j < num2; j++)
604 this.cells[i, j] =
new Cell
608 objVal = array[num3],
609 _blockMat = array2[num3],
610 _block = array3[num3],
611 _floorMat = array4[num3],
612 _floor = array5[num3],
614 objMat = array7[num3],
615 decal = array8[num3],
616 _dirs = array9[num3],
617 height = array12[num3],
618 _bridge = array13[num3],
619 _bridgeMat = array14[num3],
620 bridgeHeight = array15[num3],
621 bridgePillar = array16[num3],
622 _roofBlock = array17[num3],
623 _roofBlockMat = array18[num3],
624 _roofBlockDir = array19[num3],
625 isSeen = array10[num3].GetBit(1),
626 isHarvested = array10[num3].GetBit(2),
627 impassable = array10[num3].GetBit(3),
628 isModified = array10[num3].GetBit(4),
629 isClearSnow = array10[num3].GetBit(5),
630 isForceFloat = array10[num3].GetBit(6),
631 isToggleWallPillar = array10[num3].GetBit(7),
632 isWatered = array11[num3].GetBit(0),
633 isObjDyed = array11[num3].GetBit(1)
635 Critter.RebuildCritter(this.cells[i, j]);
639 this.things.ForeachReverse(delegate(
Thing t)
641 if (t.Num <= 0 || t.isDestroyed)
643 Debug.Log(
string.Concat(
new string[]
645 "[bug] Removing bugged thing:",
648 t.isDestroyed.ToString(),
650 (t !=
null) ? t.ToString() :
null
652 CS$<>8__locals1.<>4__this.things.Remove(t);
655 foreach (KeyValuePair<int, CellEffect> keyValuePair
in this.cellEffects)
657 int key = keyValuePair.Key;
658 int num4 = key % this.Size;
659 int num5 = key / this.Size;
660 this.cells[num4, num5].effect = keyValuePair.Value;
661 if (keyValuePair.Value.IsFire)
663 this.effectManager.GetOrCreate(
new Point(num4, num5));
666 this.cellEffects.Clear();
667 this.ValidateVersion();
671 public void ValidateVersion()
673 this.version =
EClass.core.version;
687 data.serializedCards.Restore(
this, data.orgMap,
false,
null);
691 public void ExportMetaData(
string _path,
string id,
PartialMap partial =
null)
693 if (this.custom ==
null)
700 version = BaseCore.Instance.version.GetInt(),
706 IO.SaveFile(_path +
"meta", mapMetaData,
false,
null);
710 public static MapMetaData GetMetaData(
string pathZip)
714 using (ZipFile zipFile = ZipFile.Read(pathZip))
716 ZipEntry zipEntry = zipFile[
"meta"];
717 if (zipEntry !=
null)
720 using (MemoryStream memoryStream =
new MemoryStream())
722 zipEntry.Extract(memoryStream);
724 Debug.Log(mapMetaData);
725 mapMetaData.path = pathZip;
731 catch (Exception message)
739 public static void UpdateMetaData(
string pathZip,
PartialMap partial =
null)
741 IO.CreateTempDirectory(
null);
742 ZipFile zipFile = ZipFile.Read(pathZip);
743 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
744 zipFile.ExtractAll(IO.TempPath);
746 EClass._map.ExportMetaData(IO.TempPath +
"/", Path.GetFileNameWithoutExtension(pathZip), partial);
748 zipFile = (zipFile2 =
new ZipFile());
751 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
752 zipFile.AddDirectory(IO.TempPath);
753 zipFile.Save(pathZip);
758 if (zipFile2 !=
null)
760 ((IDisposable)zipFile2).Dispose();
763 IO.DeleteTempDirectory(
null);
767 public void AddCardOnActivate(
Card c)
769 c.parent = this.zone;
770 this.props.OnCardAddedToZone(c);
771 Chara chara = c.Chara;
774 chara.currentZone =
EClass._zone;
776 this._AddCard(c.pos.x, c.pos.z, c,
true);
780 public void OnCardAddedToZone(
Card t,
int x,
int z)
784 this.charas.Add(t.Chara);
788 this.things.Add(t.Thing);
790 this.props.OnCardAddedToZone(t);
791 if (t.isChara &&
new Point(x, z).cell.HasFullBlock)
793 this.DestroyBlock(x, z);
795 this._AddCard(x, z, t,
true);
796 t.trait.OnAddedToZone();
800 public void OnCardRemovedFromZone(
Card t)
802 t.trait.OnRemovedFromZone();
803 t.SetPlaceState(PlaceState.none,
false);
808 this.charas.Remove(t.Chara);
811 this.things.Remove(t.Thing);
817 this._AddCard(p.x, p.z, t,
false);
821 public void _AddCard(
int x,
int z,
Card t,
bool onAddToZone)
830 t.ForeachPoint(delegate(
Point p,
bool main)
840 if (t.isThing && !t.trait.IDActorEx.IsEmpty())
842 EClass.scene.AddActorEx(t,
null);
847 public void _RemoveCard(
Card t)
851 t.ForeachPoint(delegate(
Point p,
bool main)
853 p.cell.RemoveCard(t);
858 t.Cell.RemoveCard(t);
864 public Cell GetCell(
int index)
866 return this.cells[index % this.Size, index % this.SizeXZ / this.Size];
870 public void SetSeen(
int x,
int z,
bool seen =
true,
bool refresh =
true)
872 if (this.cells[x, z].isSeen == seen)
876 this.cells[x, z].isSeen = seen;
881 EClass._map.RefreshNeighborTiles(x, z);
885 public void RevealAll(
bool reveal =
true)
887 for (
int i = 0; i < this.Size; i++)
889 for (
int j = 0; j < this.Size; j++)
891 EClass._map.SetSeen(i, j, reveal,
false);
894 this.revealed = !this.revealed;
899 public void Reveal(
Point center,
int power = 100)
901 this.ForeachSphere(center.x, center.z, (
float)(10 + power / 5), delegate(
Point p)
903 if (
EClass.rnd(power) >= Mathf.Min(p.Distance(center) * 10, power - 10))
905 EClass._map.SetSeen(p.x, p.z,
true,
true);
911 public void RefreshFOV(
int x,
int z,
int radius = 6,
bool recalculate =
false)
913 this.ForeachSphere(x, z, (
float)radius, delegate(
Point p)
915 List<Card> list = p.ListCards(
false);
918 using (List<Card>.Enumerator enumerator = list.GetEnumerator())
920 while (enumerator.MoveNext())
922 Card card = enumerator.Current;
923 card.RecalculateFOV();
928 foreach (
Card card2
in list)
930 card2.CalculateFOV();
936 public void RefreshFOVAll()
940 card.RecalculateFOV();
945 public void SetFloor(
int x,
int z,
int idMat = 0,
int idFloor = 0)
947 this.SetFloor(x, z, idMat, idFloor, 0);
951 public void SetFloor(
int x,
int z,
int idMat,
int idFloor,
int dir)
953 Cell cell = this.cells[x, z];
954 cell._floorMat = (byte)idMat;
955 cell._floor = (byte)idFloor;
958 this.RefreshNeighborTiles(x, z);
962 public void SetBridge(
int x,
int z,
int height = 0,
int idMat = 0,
int idBridge = 0,
int dir = 0)
964 Cell cell = this.cells[x, z];
965 cell.bridgeHeight = (byte)height;
966 cell._bridgeMat = (byte)idMat;
967 cell._bridge = (byte)idBridge;
968 cell.bridgePillar = 0;
970 if (cell.room !=
null)
972 cell.room.SetDirty();
974 this.RefreshNeighborTiles(x, z);
978 public void SetRoofBlock(
int x,
int z,
int idMat,
int idBlock,
int dir,
int height)
980 Cell cell = this.cells[x, z];
981 cell._roofBlockMat = (byte)idMat;
982 cell._roofBlock = (byte)idBlock;
983 cell._roofBlockDir = (byte)(dir + height * 4);
984 this.RefreshSingleTile(x, z);
988 public void SetBlock(
int x,
int z,
int idMat = 0,
int idBlock = 0)
990 this.SetBlock(x, z, idMat, idBlock, 0);
994 public void SetBlock(
int x,
int z,
int idMat,
int idBlock,
int dir)
996 Cell cell = this.cells[x, z];
997 bool hasFloodBlock = cell.HasFloodBlock;
998 cell._blockMat = (byte)idMat;
999 cell._block = (byte)idBlock;
1000 cell.blockDir = dir;
1001 if (cell.effect ==
null || !cell.effect.IsFire)
1005 cell.isToggleWallPillar =
false;
1006 if (cell.room !=
null)
1008 cell.room.SetDirty();
1010 if (hasFloodBlock || cell.HasFloodBlock)
1012 this.OnSetBlockOrDoor(x, z);
1014 this.RefreshNeighborTiles(x, z);
1018 public void OnSetBlockOrDoor(
int x,
int z)
1021 this.TryRemoveRoom(x, z);
1024 this.TryRemoveRoom(x - 1, z);
1026 if (x < this.Size - 1)
1028 this.TryRemoveRoom(x + 1, z);
1032 this.TryRemoveRoom(x, z - 1);
1034 if (z < this.Size - 1)
1036 this.TryRemoveRoom(x, z + 1);
1038 if (x > 0 && z < this.Size - 1)
1040 this.TryRemoveRoom(x - 1, z + 1);
1042 this.roomHash.Clear();
1043 this.TryAddRoom(x, z);
1046 this.TryAddRoom(x - 1, z);
1048 if (x < this.Size - 1)
1050 this.TryAddRoom(x + 1, z);
1054 this.TryAddRoom(x, z - 1);
1056 if (z < this.Size - 1)
1058 this.TryAddRoom(x, z + 1);
1060 if (x > 0 && z < this.Size - 1)
1062 this.TryAddRoom(x - 1, z + 1);
1067 public void TryRemoveRoom(
int x,
int z)
1069 if (this.cells[x, z].HasFloodBlock)
1073 Room room = this.cells[x, z].room;
1076 this.rooms.RemoveRoom(room);
1081 public void TryAddRoom(
int x,
int z)
1083 if (
EClass._zone.DisableRooms)
1087 if (this.roomHash.Contains(x + z *
this.Size) ||
this.cells[x, z].HasFloodBlock)
1091 FloodSpiller floodSpiller = this.flood;
1092 IFloodCell[,] array = this.cells;
1093 FloodSpiller.Result result = floodSpiller.SpillFlood(array, x, z);
1094 if (!result.IsValid)
1099 foreach (IFloodCell floodCell
in result.visited)
1101 if (floodCell.hasDoor)
1107 if (cell.sourceBlock.tileType.IsFloodDoor || cell.Front.hasDoor || cell.Right.hasDoor || cell.FrontRight.hasDoor || cell.Back.hasDoor || cell.Left.hasDoor || cell.BackLeft.hasDoor)
1113 if (!flag && this.IsIndoor)
1115 foreach (IFloodCell floodCell2
in result.visited)
1118 if (cell2.detail !=
null && cell2.detail.things.Count != 0)
1120 foreach (
Thing thing
in cell2.detail.things)
1139 Room room = this.rooms.AddRoom(
new Room());
1140 foreach (IFloodCell floodCell3
in result.visited)
1145 room.AddPoint(
new Point((
int)x2, (
int)z2));
1146 this.roomHash.Add((
int)x2 + (
int)z2 * this.Size);
1147 if (z2 > 0 && cell3.Front.HasFloodBlock && cell3.Front.room ==
null)
1149 room.AddPoint(
new Point((
int)x2, (
int)(z2 - 1)));
1150 this.roomHash.Add((
int)x2 + (
int)(z2 - 1) * this.Size);
1152 if ((
int)x2 < this.Size - 1 && cell3.Right.HasFloodBlock && cell3.Right.room ==
null)
1154 room.AddPoint(
new Point((
int)(x2 + 1), (
int)z2));
1155 this.roomHash.Add((
int)(x2 + 1) + (
int)z2 * this.Size);
1157 if (z2 > 0 && (
int)x2 < this.Size - 1 && cell3.FrontRight.HasFloodBlock && cell3.FrontRight.room ==
null)
1159 room.AddPoint(
new Point((
int)(x2 + 1), (
int)(z2 - 1)));
1160 this.roomHash.Add((
int)(x2 + 1) + (
int)(z2 - 1) * this.Size);
1166 public void SetBlockDir(
int x,
int z,
int dir)
1168 Cell cell = this.cells[x, z];
1169 cell._block = (byte)cell.sourceBlock.id;
1170 cell.blockDir = dir;
1174 public void ModFire(
int x,
int z,
int amount)
1176 Cell cell = this.cells[x, z];
1177 if (cell.IsTopWaterAndNoSnow)
1181 if (cell.effect ==
null && amount > 0)
1186 int num = amount + ((effect !=
null) ? effect.FireAmount : 0);
1201 this.effectManager.GetOrCreate(
new Point(x, z));
1205 public void TryShatter(
Point pos,
int ele,
int power)
1208 List<Card> list =
new List<Card>();
1209 Map.<>c__DisplayClass99_0 CS$<>8__locals1;
1210 CS$<>8__locals1.fire = (ele == 910);
1211 bool fire = CS$<>8__locals1.fire;
1212 List<Card> list2 = pos.ListCards(
false);
1213 if (CS$<>8__locals1.fire && (pos.cell.IsSnowTile || pos.cell.IsTopWater))
1217 foreach (
Card card
in list2)
1219 if (card.ResistLvFrom(ele) < 3 && !(card.trait is
TraitBlanket) && (
EClass.rnd(3) != 0 ||
Map.<TryShatter>g__CanCook|99_0(card, ref CS$<>8__locals1)))
1221 if (card.isThing && card.things.Count == 0)
1230 thing.ModCharge(-1,
false);
1233 Msg.Say((pos.HasChara ?
"blanketInv_" :
"blanketGround_") + element.source.alias, thing, pos.FirstChara,
null,
null);
1235 if (thing.c_charges <= 0)
1237 thing.Die(element,
null, AttackSource.None);
1242 foreach (
Thing thing2
in card.things.List((
Thing a) => a.things.Count == 0,
false))
1244 Card parentCard = thing2.parentCard;
1245 if (parentCard ==
null || (!(parentCard.trait is
TraitChestMerchant) && !parentCard.HasEditorTag(EditorTag.PreciousContainer)))
1254 list.Shuffle<
Card>();
1256 foreach (
Card card2
in list)
1258 if (card2.trait.CanBeDestroyed && !card2.category.IsChildOf(
"currency") && !(card2.trait is
TraitDoor) && !(card2.trait is
TraitFigure) && !(card2.trait is
TraitTrainingDummy) && card2.rarity < Rarity.Legendary)
1260 Card rootCard = card2.GetRootCard();
1261 if (!card2.IsEquipmentOrRanged || (
EClass.rnd(4) == 0 && ((!card2.IsRangedWeapon && !card2.Thing.isEquipped) || !rootCard.IsPCFaction ||
EClass.rnd(4) == 0)))
1263 if (
EClass._zone.IsPCFaction &&
EClass.Branch.lv >= 3 && (!rootCard.isChara || rootCard.Chara.IsPCFaction))
1267 Msg.Say(
"damage_protectCore", card2,
null,
null,
null);
1276 if (!card2.category.IsChildOf(
"drink") &&
EClass.rnd(5) == 0)
1284 if (card2.isFireproof)
1288 if (!card2.category.IsChildOf(
"book") &&
EClass.rnd(2) == 0)
1293 if (
EClass.rnd(num * num) == 0)
1295 bool flag =
Map.<TryShatter>g__CanCook|99_0(card2, ref CS$<>8__locals1);
1303 if (row !=
null && !row.isOrigin && !row.components.IsEmpty() && row.components.Length < 3 && row.Category.IsChildOf(
"meal"))
1305 if (!row.factory.IsEmpty())
1307 string a2 = row.factory[0];
1308 if (a2 ==
"chopper" || a2 ==
"mixer" || a2 ==
"camppot" || a2 ==
"cauldron")
1313 if (row.components[0] == card2.id || row.components[0] == card2.sourceCard._origin)
1319 if (list3.Count > 0)
1324 if (flag && !text.IsEmpty())
1327 Thing thing3 = card2.Split(1);
1328 List<Thing> list4 =
new List<Thing>();
1332 thing4.elements.ModBase(2,
EClass.curve(power / 10, 50, 10, 75));
1335 Msg.Say((rootCard == card2) ?
"cook_groundItem" :
"cook_invItem", thing3, rootCard, thing4.Name,
null);
1337 if (rootCard == card2)
1339 EClass._zone.AddCard(thing4, card2.pos);
1341 else if (rootCard.isChara)
1343 rootCard.Chara.Pick(thing4,
false,
true);
1347 rootCard.AddThing(thing4,
true, -1, -1);
1353 int num2 =
EClass.rnd(card2.Num) / 2 + 1;
1354 if (card2.Num > num2)
1356 Thing thing5 = card2.Split(num2);
1359 Msg.Say((rootCard == card2) ?
"damage_groundItem" :
"damage_invItem", thing5, rootCard,
null,
null);
1365 card2.Die(element,
null, AttackSource.None);
1374 this._ValidateInstalled(pos.x, pos.z);
1378 public void Burn(
int x,
int z,
bool instant =
false)
1380 Cell cell = this.cells[x, z];
1381 Point sharedPoint = cell.GetSharedPoint();
1382 if ((instant ||
EClass.rnd(10) == 0) && cell.HasObj)
1386 this.SetObj(x, z, cell.matObj_fixed.id, 59, 0,
EClass.rnd(4));
1390 this.SetObj(x, z, 0, 1, 0);
1393 EClass._zone.AddCard(
ThingGen.Create((
EClass.rnd(2) == 0) ?
"ash" :
"ash2", -1, -1), sharedPoint);
1397 if ((instant ||
EClass.rnd(5) == 0) && cell._block != 0 && cell._block != 96)
1399 if (
EClass.rnd(10) == 0 || !cell.sourceBlock.tileType.IsWall)
1407 if (cell.room !=
null)
1409 cell.room.SetDirty();
1411 this.RefreshNeighborTiles(x, z);
1413 if (instant ||
EClass.rnd(10) == 0)
1419 if (cell._bridge != 0 &&
EClass.rnd(5) != 0)
1424 foreach (
Card card
in sharedPoint.ListCards(
false))
1431 EClass._zone.AddCard(
ThingGen.Create((
EClass.rnd(2) == 0) ?
"ash" :
"ash2", -1, -1), sharedPoint);
1435 card.DamageHP(30, 910, 100, AttackSource.None,
null,
true);
1446 public void SetLiquid(
int x,
int z,
CellEffect effect =
null)
1448 Cell cell = this.cells[x, z];
1449 if (cell.IsTopWaterAndNoSnow && effect !=
null)
1453 cell.effect = effect;
1457 public void SetLiquid(
int x,
int z,
int id,
int value = 1)
1459 Cell cell = this.cells[x, z];
1460 if (cell.IsTopWaterAndNoSnow && value != 0)
1481 public void SetEffect(
int x,
int z,
CellEffect effect =
null)
1483 this.cells[x, z].effect = effect;
1487 public void ModLiquid(
int x,
int z,
int amount)
1489 Cell cell = this.cells[x, z];
1490 if (cell.IsTopWaterAndNoSnow || cell.effect ==
null)
1494 cell.effect.amount += amount;
1495 if (cell.effect.amount <= 0)
1502 public void ClearRainAndDecal()
1504 this.ForeachCell(delegate(
Cell c)
1512 public void SetObj(
int x,
int z,
int id = 0,
int value = 1,
int dir = 0)
1514 this.SetObj(x, z, (
int)((
byte)
EClass.sources.objs.rows[
id].DefaultMaterial.id),
id, value, dir);
1518 public void SetObj(
int x,
int z,
int idMat,
int idObj,
int value,
int dir)
1520 Cell cell = this.cells[x, z];
1521 cell.obj = (byte)idObj;
1522 cell.objVal = (byte)value;
1523 cell.objMat = (byte)idMat;
1525 cell.isHarvested =
false;
1526 cell.isObjDyed =
false;
1528 if (!sourceObj.matCategory.IsEmpty())
1530 int num =
EClass._zone.DangerLv;
1531 if (sourceObj.tag.Contains(
"spot"))
1533 num +=
EClass.pc.Evalue(1656) * 5;
1535 cell.objMat = (byte)
MATERIAL.GetRandomMaterialFromCategory(num, sourceObj.matCategory.Split(
',', StringSplitOptions.None), cell.matObj).id;
1537 if (this.backerObjs.ContainsKey(cell.index))
1539 this.backerObjs.Remove(cell.index);
1541 if (this.plants.ContainsKey(cell.index))
1543 this.plants.Remove(cell.index);
1546 this.RefreshNeighborTiles(x, z);
1550 public void AddBackerTree()
1554 EClass._map.bounds.ForeachCell(delegate(
Cell c)
1557 if (num <= 0 || c.growth ==
null || !c.growth.IsTree || !c.growth.IsMature || (
EClass.player.doneBackers.Contains(item.id) && !
EClass.core.config.test.ignoreBackerDestoryFlag))
1561 if (c.sourceObj.alias == item.tree || item.tree ==
"random")
1563 this.backerObjs[c.index] = item.id;
1564 Debug.Log(
string.Concat(
new string[]
1588 if (!this.backerObjs.ContainsKey(p.index))
1592 return EClass.sources.backers.map.TryGetValue(this.backerObjs[p.index],
null);
1596 public void ApplyBackerObj(
Point p,
int id = -1)
1602 bool flag = p.sourceObj.id == 82;
1606 if (!
EClass.player.doneBackers.Contains(row.id) ||
EClass.core.config.test.ignoreBackerDestoryFlag)
1608 this.backerObjs[p.index] = row.id;
1611 p.cell.objDir = row.skin;
1617 this.backerObjs.Remove(p.index);
1625 if (r.components.Length == 0)
1635 thing =
ThingGen.CreateFloor(r.id, mat.id, isPlatform);
1639 thing =
ThingGen.CreateBlock(r.id, mat.id);
1645 if (recipeSource ==
null)
1649 string idingredient = recipeSource.GetIDIngredient();
1650 if (idingredient ==
null)
1654 thing =
ThingGen.Create(idingredient, -1, -1);
1655 thing.ChangeMaterial(mat.alias);
1657 if (
EClass.scene.actionMode.IsBuildMode &&
EClass.debug.godBuild)
1659 this.PutAway(thing);
1662 this.TrySmoothPick(point, thing, c);
1666 public void MineBlock(
Point point,
bool recoverBlock =
false,
Chara c =
null)
1668 bool flag =
ActionMode.Mine.IsRoofEditMode(
null) && point.cell._roofBlock > 0;
1669 if (!point.IsValid || (!flag && !point.cell.HasBlock))
1674 byte b = flag ? point.cell._roofBlock : point.cell._block;
1676 Effect.Get(
"smoke").Play(point, 0f,
null,
null);
1677 Effect.Get(
"mine").Play(point, 0f,
null,
null).SetParticleColor(row.GetColor()).Emit(10 +
EClass.rnd(10));
1678 point.PlaySound(row.GetSoundDead(row2),
true, 1f,
true);
1679 row.AddBlood(point, 8);
1680 bool flag2 = c ==
null || c.IsAgent || c.IsPCFactionOrMinion;
1683 point.cell._roofBlock = 0;
1684 this.RefreshSingleTile(point.x, point.z);
1688 if (point.cell.HasFullBlock)
1690 this.RemoveLonelyRamps(point.cell);
1692 point.SetBlock(0, 0);
1693 if (flag2 && point.sourceObj.tileType.IsBlockMount)
1695 this.MineObj(point,
null, c);
1700 this.DropBlockComponent(point, row2, row, recoverBlock,
false, c);
1702 this.RefreshShadow(point.x, point.z);
1703 this.RefreshShadow(point.x, point.z - 1);
1704 this.ValidateInstalled(point);
1705 this.RefreshFOV(point.x, point.z, 6,
false);
1706 if (flag2 && !point.cell.isModified && !flag)
1708 if (b == 17 ||
EClass.rnd(100) == 0)
1710 this.zone.AddCard(
ThingGen.Create(
"money2", -1, -1), point);
1712 if (
EClass._zone.DangerLv >= 10 &&
EClass.rnd(200) == 0)
1714 this.zone.AddCard(
ThingGen.Create(
"crystal_earth", -1, -1), point);
1716 if (
EClass._zone.DangerLv >= 25 &&
EClass.rnd(200) == 0)
1718 this.zone.AddCard(
ThingGen.Create(
"crystal_sun", -1, -1), point);
1720 if (
EClass._zone.DangerLv >= 40 &&
EClass.rnd(200) == 0)
1722 this.zone.AddCard(
ThingGen.Create(
"crystal_mana", -1, -1), point);
1724 point.cell.isModified =
true;
1729 public void MineRamp(
Point point,
int ramp,
bool recoverBlock =
false)
1731 if (!point.IsValid || !point.cell.HasFullBlock)
1736 byte block = point.cell._block;
1737 Effect.Get(
"smoke").Play(point, 0f,
null,
null);
1738 Effect.Get(
"mine").Play(point, 0f,
null,
null).SetParticleColor(point.matBlock.GetColor()).Emit(10 +
EClass.rnd(10));
1739 this.MineObj(point,
null,
null);
1740 int rampDir =
EClass._map.GetRampDir(point.x, point.z,
EClass.sources.blocks.rows[ramp].tileType);
1741 this.RemoveLonelyRamps(point.cell);
1742 this.SetBlock(point.x, point.z, (
int)point.cell._blockMat, ramp, rampDir);
1743 this.DropBlockComponent(point,
EClass.sources.blocks.rows[(
int)block], matBlock, recoverBlock,
false,
null);
1747 public void MineFloor(
Point point,
Chara c =
null,
bool recoverBlock =
false,
bool removePlatform =
true)
1749 if (!point.IsValid || (!point.HasFloor && !point.HasBridge))
1754 SourceFloor.Row c2 = point.cell.HasBridge ? point.sourceBridge : point.sourceFloor;
1755 Effect.Get(
"mine").Play(point, 0f,
null,
null).SetParticleColor(row.GetColor()).Emit(10 +
EClass.rnd(10));
1756 point.PlaySound(row.GetSoundDead(c2),
true, 1f,
true);
1757 this.MineObj(point,
null, c);
1758 if (point.cell.HasBridge && removePlatform)
1760 this.DropBlockComponent(
EClass.pc.pos, point.sourceBridge, point.matBridge, recoverBlock,
true, c);
1761 EClass._map.SetBridge(point.x, point.z, 0, 0, 0, 0);
1764 EClass.pc.Kick(point,
true);
1768 if (
EClass._zone.IsSkyLevel)
1770 this.DropBlockComponent(
EClass.pc.pos, point.sourceFloor, row, recoverBlock,
false, c);
1771 this.SetFloor(point.x, point.z, 0, 90);
1774 EClass.pc.Kick(point,
true);
1778 if (this.zone.IsRegion || point.cell._floor == 40)
1781 thing.ChangeMaterial(row.alias);
1782 this.TrySmoothPick(point, thing, c);
1786 this.DropBlockComponent(point, point.sourceFloor, row, recoverBlock,
false, c);
1788 if (
EClass._zone.IsRegion || point.sourceFloor.components[0].Contains(
"chunk@soil"))
1792 point.SetFloor(
EClass.sources.floors.rows[1].DefaultMaterial.id, 40);
1796 public void RefreshShadow(
int x,
int z)
1803 this.TrySmoothPick(cell.GetPoint(), t, c);
1809 if (c !=
null && c.IsAgent)
1811 EClass.pc.PickOrDrop(p, t,
true);
1814 if (c !=
null && (c.pos.Equals(p) ||
EClass.core.config.game.smoothPick ||
EClass._zone.IsRegion))
1816 c.PickOrDrop(p, t,
true);
1819 EClass._zone.AddCard(t, p);
1823 public void DestroyObj(
Point point)
1825 Cell cell = point.cell;
1828 if (sourceObj.tileType.IsBlockPass)
1830 Effect.Get(
"smoke").Play(point, 0f,
null,
null);
1832 Effect.Get(
"mine").Play(point, 0f,
null,
null).SetParticleColor(cell.matObj.GetColor()).Emit(10 +
EClass.rnd(10));
1833 point.PlaySound(matObj.GetSoundDead(
null),
true, 1f,
true);
1834 matObj.AddBlood(point, 3);
1838 public void MineObj(
Point point,
Task task =
null,
Chara c =
null)
1840 Map.<>c__DisplayClass119_0 CS$<>8__locals1;
1841 CS$<>8__locals1.<>4__this =
this;
1842 CS$<>8__locals1.point = point;
1843 CS$<>8__locals1.c = c;
1844 if (!CS$<>8__locals1.point.IsValid || !CS$<>8__locals1.point.HasObj)
1848 Cell cell = CS$<>8__locals1.point.cell;
1851 if (CS$<>8__locals1.c ==
null && task !=
null)
1853 CS$<>8__locals1.c = task.owner;
1855 bool flag2 = CS$<>8__locals1.c ==
null || CS$<>8__locals1.c.IsAgent || CS$<>8__locals1.c.IsPCFactionOrMinion;
1856 this.DestroyObj(CS$<>8__locals1.point);
1861 if (taskHarvest !=
null && taskHarvest.IsReapSeed)
1863 int num = 1 +
EClass.rnd(2) + ((
EClass.rnd(3) == 0) ? 1 : 0);
1864 if (
EClass._zone.IsPCFaction)
1866 int soilCost =
EClass._zone.GetSoilCost();
1867 int maxSoil =
EClass.Branch.MaxSoil;
1868 if (soilCost > maxSoil)
1870 num -=
EClass.rnd(2 + (soilCost - maxSoil) / 10);
1875 Msg.Say(
"seedSpoiled", cell.GetObjName(),
null,
null,
null);
1879 Thing t =
TraitSeed.MakeSeed(sourceObj, this.TryGetPlant(cell)).SetNum(num);
1880 EClass.pc.PickOrDrop(CS$<>8__locals1.point, t,
true);
1882 if (cell.growth.IsTree)
1884 cell.isHarvested =
true;
1888 else if (sourceObj.HasGrowth)
1890 cell.growth.PopMineObj(CS$<>8__locals1.c);
1894 if (cell.HasBlock && (sourceObj.id == 18 || sourceObj.id == 19))
1896 this.MineBlock(CS$<>8__locals1.point,
false, CS$<>8__locals1.c);
1898 string alias = sourceObj.alias;
1899 uint num2 = <PrivateImplementationDetails>.ComputeStringHash(alias);
1900 if (num2 <= 529228496U)
1902 if (num2 != 414349311U)
1904 if (num2 != 489301296U)
1906 if (num2 == 529228496U)
1908 if (!(alias ==
"wreck_junk"))
1913 else if (!(alias ==
"wreck_precious"))
1917 else if (alias ==
"nest_bird")
1921 this.<MineObj>g__Pop|119_0(
ThingGen.Create((
EClass.rnd(10) == 0) ?
"egg_fertilized" :
"_egg", -1, -1).TryMakeRandomItem(-1), ref CS$<>8__locals1);
1925 else if (num2 <= 1575653919U)
1927 if (num2 != 1117262783U)
1929 if (num2 == 1575653919U)
1931 if (!(alias ==
"wreck_scrap"))
1936 else if (!(alias ==
"wreck_stone"))
1940 else if (num2 != 3603235706U)
1942 if (num2 == 3937420123U)
1944 if (!(alias ==
"wreck_wood"))
1949 else if (!(alias ==
"wreck_cloth"))
1952 int num3 =
EClass.rnd(
EClass.rnd(sourceObj.components.Length) + 1);
1953 string[] array = sourceObj.components[num3].Split(
'/', StringSplitOptions.None);
1954 Thing thing =
ThingGen.Create(array[0], matObj_fixed.alias);
1955 if (array.Length > 1)
1957 thing.SetNum(
EClass.rnd(array[1].ToInt()) + 1);
1959 this.<MineObj>g__Pop|119_0(thing, ref CS$<>8__locals1);
1962 this.SetObj(CS$<>8__locals1.point.x, CS$<>8__locals1.point.z, 0, 1, 0);
1963 cell.gatherCount = 0;
1966 this.RefreshFOV(CS$<>8__locals1.point.x, CS$<>8__locals1.point.z, 6,
false);
1971 public void MineObjSound(
Point point)
1973 point.PlaySound(point.cell.matObj.GetSoundDead(point.cell.sourceObj),
true, 1f,
true);
1979 return this.plants.TryGetValue(p.index,
null);
1985 return this.plants.TryGetValue(c.index,
null);
1995 this.plants[pos.index] = plantData;
2000 public void RemovePlant(
Point pos)
2002 this.plants.Remove(pos.index);
2006 public void ValidateInstalled(
Point p)
2008 this._ValidateInstalled(p.x, p.z);
2009 this._ValidateInstalled(p.x + 1, p.z);
2010 this._ValidateInstalled(p.x - 1, p.z);
2011 this._ValidateInstalled(p.x, p.z + 1);
2012 this._ValidateInstalled(p.x, p.z - 1);
2016 public void _ValidateInstalled(
int x,
int y)
2023 List<Card> list = point.ListCards(
false);
2029 foreach (
Card card
in list)
2031 if (card.isThing && card.trait.CanBeDestroyed && card.IsInstalled)
2033 HitResult hitResult = card.TileType._HitTest(point, card.Thing,
false);
2034 if (card.Thing.stackOrder != detail.things.IndexOf(card.Thing) || (hitResult != HitResult.Valid && hitResult != HitResult.Warning))
2036 if (
EClass._zone.IsPCFaction)
2038 card.SetPlaceState(PlaceState.roaming,
false);
2042 card.Die(
null,
null, AttackSource.None);
2050 public void RemoveLonelyRamps(
Cell cell)
2052 for (
int i = 0; i < 4; i++)
2054 Cell dependedRamp = this.GetDependedRamp(cell);
2055 if (dependedRamp ==
null)
2059 this.MineBlock(dependedRamp.GetPoint(),
false,
null);
2064 public void DestroyBlock(
int x,
int z)
2066 this.SetBlock(x, z, 0, 0);
2070 public void AddDecal(
int x,
int z,
int id,
int amount = 1,
bool refresh =
true)
2072 if (x < 0 || z < 0 || x >= this.Size || z >= this.Size)
2076 Cell cell = this.cells[x, z];
2077 if (!cell.sourceFloor.tileType.AllowBlood)
2081 if ((
int)(cell.decal / 8) !=
id && (
int)(cell.decal % 8) > amount)
2085 if ((
int)(cell.decal / 8) !=
id && cell.decal % 8 == 0)
2089 int num = Mathf.Clamp((
int)(((
int)(cell.decal / 8) ==
id) ? (cell.decal % 8) : 0) + amount, 0, 7);
2090 cell.decal = (byte)(
id * 8 + num);
2093 this.RefreshNeighborTiles(x, z);
2098 public void SetDecal(
int x,
int z,
int id = 0,
int amount = 1,
bool refresh =
true)
2100 this.cells[x, z].decal = (byte)(
id * 8 + ((
id == 0) ? 0 : amount));
2103 this.RefreshNeighborTiles(x, z);
2108 public void SetFoormark(
Point pos,
int id,
int angle,
int offset = 0)
2110 Cell cell = pos.cell;
2111 int tile = this.AngleToIndex(angle) + offset;
2117 footmark.pos.Set(pos);
2118 this.footmarks.Add(footmark);
2119 cell.GetOrCreateDetail().footmark = footmark;
2123 public int AngleToIndex(
int a)
2125 if (
EClass._zone.IsRegion)
2192 public void RefreshSingleTile(
int x,
int z)
2194 this.cells[x, z].Refresh();
2198 public void RefreshAllTiles()
2200 for (
int i = 0; i < this.Size; i++)
2202 for (
int j = 0; j < this.Size; j++)
2204 this.cells[i, j].Refresh();
2210 public void RefreshNeighborTiles(
int x,
int z)
2212 this.cells[x, z].Refresh();
2213 for (
int i = x - 2; i < x + 3; i++)
2215 if (i >= 0 && i < this.Size)
2217 for (
int j = z - 2; j < z + 3; j++)
2219 if (j >= 0 && j < this.Size && (x != i || z != j))
2221 this.cells[i, j].Refresh();
2229 public void QuickRefreshTile(
int x,
int z)
2231 Cell cell = this.cells[x, z];
2232 Cell cell2 = (x > 0) ? this.cells[x - 1, z] :
Cell.Void;
2233 Cell cell3 = (x + 1 < this.Size) ? this.cells[x + 1, z] :
Cell.Void;
2234 Cell cell4 = (z > 0) ? this.cells[x, z - 1] :
Cell.Void;
2235 Cell cell5 = (z + 1 < this.Size) ? this.cells[x, z + 1] :
Cell.Void;
2236 Cell cell6 = (x > 0 && z > 0) ? this.cells[x - 1, z - 1] :
Cell.Void;
2237 Cell cell7 = (x + 1 < this.Size && z > 0) ? this.cells[x + 1, z - 1] :
Cell.Void;
2238 Cell cell8 = (x > 0 && z + 1 < this.Size) ? this.cells[x - 1, z + 1] :
Cell.Void;
2239 Cell cell9 = (x + 1 < this.Size && z + 1 < this.Size) ? this.cells[x + 1, z + 1] :
Cell.Void;
2240 cell.isSurrounded4d = (cell2.HasFullBlock && cell3.HasFullBlock && cell4.HasFullBlock && cell5.HasFullBlock);
2241 cell.isSurrounded = (cell.isSurrounded4d && cell6.HasFullBlock && cell7.HasFullBlock && cell8.HasFullBlock && cell9.HasFullBlock);
2245 public int GetRampDir(
int x,
int z,
TileType blockType =
null)
2247 Cell cell = this.cells[x, z];
2248 if (cell.HasFullBlock)
2250 if (blockType ==
null)
2252 blockType = cell.sourceBlock.tileType;
2254 Cell right = cell.Right;
2255 Cell front = cell.Front;
2256 Cell left = cell.Left;
2257 Cell back = cell.Back;
2258 if (!right.HasBlock && !right.IsVoid && left.HasFullBlock && front.CanBuildRamp(1) && back.CanBuildRamp(1))
2262 if (!front.HasBlock && !front.IsVoid && back.HasFullBlock && left.CanBuildRamp(0) && right.CanBuildRamp(0))
2266 if (!left.HasBlock && !left.IsVoid && right.HasFullBlock && front.CanBuildRamp(3) && back.CanBuildRamp(3))
2270 if (!back.HasBlock && !back.IsVoid && front.HasFullBlock && left.CanBuildRamp(2) && right.CanBuildRamp(2))
2274 if (!blockType.IsRamp)
2283 public Cell GetDependedRamp(
Cell cell)
2285 Cell right = cell.Right;
2286 if (right.HasRamp && !right.HasStairs && right.blockDir == 1)
2290 Cell front = cell.Front;
2291 if (front.HasRamp && !front.HasStairs && front.blockDir == 0)
2295 Cell left = cell.Left;
2296 if (left.HasRamp && !left.HasStairs && left.blockDir == 3)
2300 Cell back = cell.Back;
2301 if (back.HasRamp && !back.HasStairs && back.blockDir == 2)
2309 public Point GetRandomPoint(
Point center,
int radius,
int tries = 100,
bool mustBeWalkable =
true,
bool requireLos =
true)
2312 for (
int i = 0; i < tries; i++)
2314 point.x = center.x +
EClass.rnd(radius * 2 + 1) - radius;
2315 point.z = center.z +
EClass.rnd(radius * 2 + 1) - radius;
2317 if ((!mustBeWalkable || !point.cell.blocked) && (!requireLos ||
Los.IsVisible(center, point,
null)))
2322 Debug.Log(
"GetRandomPoint failed center:" + ((center !=
null) ? center.ToString() :
null) +
" rad:" + radius.ToString());
2323 point.IsValid =
false;
2328 public new Point GetRandomEdge(
int r = 3)
2330 for (
int i = 0; i < 10000; i++)
2337 z =
EClass.rnd(this.Size);
2342 x =
EClass.rnd(this.Size);
2344 Point surface = base.GetSurface(x, z,
false);
2345 if (surface.IsValid)
2350 return base.GetSurface(this.Size / 2, this.Size / 2,
false);
2354 public Point GetNearbyResourcePoint(
Point center)
2357 int num = (
EClass.rnd(2) == 0) ? 1 : -1;
2358 int num2 = (
EClass.rnd(2) == 0) ? 1 : -1;
2359 for (
int i = 0; i < 3; i++)
2361 point.x = center.x - num + i * num;
2362 for (
int j = 0; j < 3; j++)
2364 point.z = center.z - num2 + j * num2;
2365 if (point.IsValid && point.area ==
null && point.cell.CanHarvest())
2371 return Point.Invalid;
2375 public List<Point> ListPointsInCircle(
Point center,
float radius,
bool mustBeWalkable =
true,
bool los =
true)
2377 List<Point> list =
new List<Point>();
2378 this.ForeachSphere(center.x, center.z, radius, delegate(
Point p)
2380 if ((!mustBeWalkable || !p.cell.blocked) && (!los ||
Los.IsVisible(center, p,
null)))
2389 public List<Chara> ListCharasInCircle(
Point center,
float radius,
bool los =
true)
2391 List<Chara> list =
new List<Chara>();
2392 foreach (
Point point
in this.ListPointsInCircle(center, radius,
false, los))
2395 if (detail !=
null && detail.charas.Count > 0)
2397 foreach (
Chara item
in point.detail.charas)
2407 public List<Point> ListPointsInArc(
Point center,
Point to,
int radius,
float angle)
2409 Point to2 =
new Point((to.x > center.x) ? 1 : ((to.x < center.x) ? -1 : 0), (to.z > center.z) ? 1 : ((to.z < center.z) ? -1 : 0));
2411 List<Point> list =
new List<Point>();
2412 float diff = point.GetAngle2(to2);
2413 this.ForeachSphere(center.x, center.z, (
float)radius, delegate(
Point p)
2415 float angle2 = center.GetAngle2(p);
2416 if ((Mathf.Abs(diff - angle2) < angle || Mathf.Abs(diff - angle2 + 360f) < angle || Mathf.Abs(360f - diff + angle2) < angle) &&
Los.IsVisible(center, p,
null) && !p.IsBlocked)
2425 public List<Point> ListPointsInLine(
Point center,
Point to,
int radius)
2427 return Los.ListVisible(center, to, radius,
null);
2431 public void SetBounds(
int size)
2433 if (size > this.Size / 2 + 1)
2435 size = this.Size / 2 - 1;
2437 this.bounds.SetBounds(this.Size / 2 - size, this.Size / 2 - size, this.Size / 2 + size, this.Size / 2 + size);
2443 this.bounds.SetBounds(b.x, b.z, b.maxX, b.maxZ);
2444 this.bounds.Size = b.Size;
2448 public new void ForeachCell(Action<Cell> action)
2450 for (
int i = 0; i < this.Size; i++)
2452 for (
int j = 0; j < this.Size; j++)
2454 action(this.cells[i, j]);
2460 public new void ForeachPoint(Action<Point> action)
2463 for (
int i = 0; i < this.Size; i++)
2465 for (
int j = 0; j < this.Size; j++)
2467 action(point.Set(i, j));
2473 public new void ForeachXYZ(Action<int, int> action)
2475 for (
int i = 0; i < this.Size; i++)
2477 for (
int j = 0; j < this.Size; j++)
2485 public void ForeachSphere(
int _x,
int _z,
float r, Action<Point> action)
2488 int num = (int)Mathf.Ceil(r);
2489 for (
int i = _x - num; i < _x + num + 1; i++)
2491 if (i >= 0 && i < this.Size)
2493 for (
int j = _z - num; j < _z + num + 1; j++)
2495 if (j >= 0 && j < this.Size && (
float)((i - _x) * (i - _x) + (j - _z) * (j - _z)) < r * r)
2506 public void ForeachNeighbor(
Point center, Action<Point> action)
2511 for (
int i = x - 1; i < x + 2; i++)
2513 if (i >= 0 && i < this.Size)
2515 for (
int j = z - 1; j < z + 2; j++)
2517 if (j >= 0 && j < this.Size)
2531 for (
int i = 0; i < this.Size; i++)
2533 for (
int j = 0; j < this.Size; j++)
2537 point.Copy().Animate(AnimeID.Quake,
true);
2545 public int CountChara(
Faction faction)
2548 using (List<Chara>.Enumerator enumerator = this.charas.GetEnumerator())
2550 while (enumerator.MoveNext())
2552 if (enumerator.Current.faction == faction)
2562 public int CountGuest()
2565 using (List<Chara>.Enumerator enumerator = this.charas.GetEnumerator())
2567 while (enumerator.MoveNext())
2569 if (enumerator.Current.IsGuest())
2579 public int CountHostile()
2582 foreach (
Chara chara
in this.charas)
2584 if (!chara.IsPCFaction && chara.IsHostile())
2593 public int CountWildAnimal()
2596 foreach (
Chara chara
in this.charas)
2598 if (!chara.IsPCFaction && chara.race.IsAnimal)
2607 public int CountNonHostile()
2610 foreach (
Chara chara
in this.charas)
2612 if (!chara.IsPCFaction && !chara.IsHostile())
2621 public List<Chara> ListChara(
Faction faction)
2623 List<Chara> list =
new List<Chara>();
2624 foreach (
Chara chara
in this.charas)
2626 if (chara.faction == faction)
2635 public List<Thing> ListThing<T>() where T :
Trait
2637 List<Thing> list =
new List<Thing>();
2638 foreach (
Thing thing
in this.things)
2640 if (thing.IsInstalled && thing.trait is T)
2649 public bool PutAway(
Card c)
2651 if (c.IsPC || (c.trait.CanOnlyCarry && !
EClass.debug.ignoreBuildRule))
2657 if (!
EClass.debug.ignoreBuildRule)
2666 Thing thing = c.Thing;
2667 if (thing.parent !=
null)
2669 thing.parent.RemoveCard(thing);
2671 thing.isMasked =
false;
2672 thing.isRoofItem =
false;
2680 EClass.debug.GetOrCreateDebugContainer().AddThing(thing,
true, -1, -1);
2683 EClass.pc.Pick(thing,
false,
true);
2689 public Chara FindChara(
string id)
2691 foreach (
Chara chara
in this.charas)
2702 public Chara FindChara(
int uid)
2704 foreach (
Chara chara
in this.charas)
2706 if (chara.uid == uid)
2715 public Thing FindThing(Func<Thing, bool> func)
2717 foreach (
Thing thing
in this.things)
2728 public Thing FindThing(
int uid)
2730 foreach (
Thing thing
in this.things)
2732 if (thing.uid == uid)
2741 public T FindThing<T>() where T :
Trait
2743 foreach (
Thing thing
in this.things)
2745 if (thing.trait is T)
2747 return thing.trait as T;
2754 public Thing FindThing(Type type,
Chara c =
null)
2756 this._things.Clear();
2757 foreach (
Thing thing
in EClass._map.props.installed.things)
2759 if (type.IsAssignableFrom(thing.trait.GetType()) && thing.pos.IsPublicSpace())
2761 this._things.Add(thing);
2764 if (this._things.Count <= 0)
2768 return this._things.RandomItem<
Thing>();
2774 Map.<>c__DisplayClass169_0 CS$<>8__locals1;
2775 CS$<>8__locals1.<>4__this =
this;
2776 CS$<>8__locals1.type = type;
2777 if (area1 ==
null && area2 ==
null)
2781 Thing thing = this.<FindThing>g__Find|169_0(area1, ref CS$<>8__locals1);
2782 if (thing ==
null && area2 !=
null)
2784 thing = this.<FindThing>g__Find|169_0(area2, ref CS$<>8__locals1);
2792 if (area1 ==
null && area2 ==
null)
2797 PropSet orCreate =
EClass._map.Installed.workMap.GetOrCreate(workTag,
null);
2800 IEnumerable<Card> enumerable = from a in orCreate.Values
2801 where a.pos.HasRoomOrArea(area1)
2803 if (enumerable.Count<
Card>() > 0)
2805 thing = (enumerable.RandomItem<
Card>() as
Thing);
2808 if (thing ==
null && area2 !=
null)
2810 IEnumerable<Card> enumerable2 = from a in orCreate.Values
2811 where a.pos.HasRoomOrArea(area2)
2813 if (enumerable2.Count<
Card>() > 0)
2815 thing = (enumerable2.RandomItem<
Card>() as
Thing);
2822 public Thing FindThing(
string workTag,
Chara c)
2824 Thing result =
null;
2825 IEnumerable<Card> enumerable = from a in
EClass._map.Installed.workMap.GetOrCreate(workTag,
null).Values
2826 where a.pos.IsPublicSpace()
2828 if (enumerable.Count<
Card>() > 0)
2830 result = (enumerable.RandomItem<
Card>() as
Thing);
2838 return (from a in this.rooms.listArea.Concat(
this.rooms.listRoom)
2839 where a.type.IsPublicArea
2844 public void RefreshSunMap()
2846 if (
Map.isDirtySunMap)
2849 foreach (
Trait trait
in EClass._map.props.installed.traits.suns.Values)
2851 foreach (
Point point
in trait.ListPoints(
null,
false))
2853 Map.sunMap.Add(point.index);
2856 Map.isDirtySunMap =
false;
2862 internal static bool <TryShatter>g__CanCook|99_0(
Card c, ref
Map.<>c__DisplayClass99_0 A_1)
2864 return A_1.fire && c.IsFood && c.category.IsChildOf(
"foodstuff");
2869 private void <MineObj>g__Pop|119_0(
Thing t, ref
Map.<>c__DisplayClass119_0 A_2)
2871 if (
EClass.scene.actionMode.IsBuildMode &&
EClass.debug.godBuild)
2876 this.TrySmoothPick(A_2.point, t, A_2.c);
2881 private Thing <FindThing>g__Find|169_0(
BaseArea area, ref
Map.<>c__DisplayClass169_0 A_2)
2883 this._things.Clear();
2884 foreach (
Thing thing
in EClass._map.props.installed.things)
2886 if (A_2.type.IsAssignableFrom(thing.trait.GetType()) && thing.pos.HasRoomOrArea(area))
2888 this._things.Add(thing);
2891 if (this._things.Count <= 0)
2895 return this._things.RandomItem<
Thing>();
2899 public static HashSet<int> sunMap =
new HashSet<int>();
2902 public static bool isDirtySunMap;
2914 public global::Version version;
2934 public List<Chara> serializedCharas =
new List<Chara>();
2938 public List<Chara> deadCharas =
new List<Chara>();
2942 public List<Thing> things =
new List<Thing>();
2950 public List<int> _plDay =
new List<int>();
2954 public List<int> _plNight =
new List<int>();
2958 public Dictionary<int, int> gatherCounts =
new Dictionary<int, int>();
2962 public Dictionary<int, CellEffect> cellEffects =
new Dictionary<int, CellEffect>();
2966 public Dictionary<int, int> backerObjs =
new Dictionary<int, int>();
2970 public Dictionary<int, PlantData> plants =
new Dictionary<int, PlantData>();
2973 public BitArray32 bits;
2976 public Playlist plDay;
2979 public Playlist plNight;
2982 public List<Chara> charas =
new List<Chara>();
2985 public List<TransAnime> pointAnimes =
new List<TransAnime>();
2988 public Cell[,] cells;
3000 public FloodSpiller flood =
new FloodSpiller();
3009 public List<Footmark> footmarks =
new List<Footmark>();
3015 public bool revealed;
3018 private HashSet<int> roomHash =
new HashSet<int>();
3021 private List<Thing> _things =
new List<Thing>();