2using System.Collections.Generic;
5using System.Runtime.Serialization;
14 public static HashSet<int>
sunMap =
new HashSet<int>();
28 public Dictionary<string, int>
cellWidths =
new Dictionary<string, int>();
52 public List<Thing>
things =
new List<Thing>();
58 public List<int>
_plDay =
new List<int>();
64 public Dictionary<int, int>
gatherCounts =
new Dictionary<int, int>();
67 public Dictionary<int, CellEffect>
cellEffects =
new Dictionary<int, CellEffect>();
70 public Dictionary<int, int>
backerObjs =
new Dictionary<int, int>();
73 public Dictionary<int, PlantData>
plants =
new Dictionary<int, PlantData>();
84 public List<Chara>
charas =
new List<Chara>();
96 public FloodSpiller
flood =
new FloodSpiller();
110 private HashSet<int>
roomHash =
new HashSet<int>();
112 private List<Thing>
_things =
new List<Thing>();
140 public IEnumerable<Card>
Cards => ((IEnumerable<Card>)
things).Concat((IEnumerable<Card>)
charas);
155 bits.Bits = (uint)
_bits;
158 public void CreateNew(
int size,
bool setReference =
true)
160 Debug.Log(
"Map CreateNew:");
202 Fov.map = (Cell.map = (Wall.map = (Point.map = (CellDetail.map =
this))));
207 pathfinder.
Init(
this, weightMap,
Size);
218 c.currentZone =
zone;
236 if (thing.
pos.
x >= newSize || thing.
pos.
z >= newSize)
243 if (chara.
pos.
x >= newSize || chara.
pos.
z >= newSize)
248 Size = (bounds.Size = newSize);
259 public void Shift(Vector2Int offset)
261 TweenUtil.Tween(0.1f,
null, delegate
265 item.pos.x += offset.x;
266 item.pos.z += offset.y;
270 for (
int i = 0; i <
Size; i++)
272 int num = i - offset.y;
273 for (
int j = 0; j <
Size; j++)
275 int num2 = j - offset.
x;
276 if (num2 >= 0 && num2 < Size && num >= 0 && num <
Size)
278 array[j, i] =
cells[num2, num];
282 array[j, i] =
new Cell
291 bounds.x += offset.
x;
292 bounds.z += offset.y;
293 bounds.maxX += offset.x;
294 bounds.maxZ += offset.y;
324 TweenUtil.Tween(0.1f,
null, delegate
332 List<Thing> list =
new List<Thing>();
352 for (
int i = 0; i <
Size; i++)
354 for (
int j = 0; j <
Size; j++)
384 Debug.Log(
"#io saving map:" + path);
385 IO.CreateDirectory(path);
392 num = partial.offsetX;
393 num2 = partial.offsetZ;
397 int num5 = num3 * num4;
398 byte[] array =
new byte[num5];
399 int[] array2 =
new int[num5];
400 int[] array3 =
new int[num5];
401 int[] array4 =
new int[num5];
402 int[] array5 =
new int[num5];
403 int[] array6 =
new int[num5];
404 int[] array7 =
new int[num5];
405 byte[] array8 =
new byte[num5];
406 byte[] array9 =
new byte[num5];
407 byte[] array10 =
new byte[num5];
408 byte[] array11 =
new byte[num5];
409 byte[] array12 =
new byte[num5];
410 int[] array13 =
new int[num5];
411 int[] array14 =
new int[num5];
412 byte[] array15 =
new byte[num5];
413 int[] array16 =
new int[num5];
414 byte[] array17 =
new byte[num5];
415 int[] array18 =
new int[num5];
416 int[] array19 =
new int[num5];
417 int[] array20 =
new int[num5];
418 int[] array21 =
new int[num5];
421 for (
int i = num; i < num + num3; i++)
423 for (
int j = num2; j < num2 + num4; j++)
426 array[num6] = cell.
objVal;
428 array2[num6] = cell.
_block;
430 array4[num6] = cell.
_floor;
431 array6[num6] = cell.
obj;
432 array20[num6] = cell.
_deco;
434 array7[num6] = cell.
objMat;
435 array8[num6] = cell.
decal;
436 array9[num6] = cell.
_dirs;
437 array12[num6] = cell.
height;
445 array10[num6] = array10[num6].SetBit(1, cell.
isSeen);
446 array10[num6] = array10[num6].SetBit(2, cell.
isHarvested);
447 array10[num6] = array10[num6].SetBit(3, cell.
impassable);
448 array10[num6] = array10[num6].SetBit(4, cell.
isModified);
449 array10[num6] = array10[num6].SetBit(5, cell.
isClearSnow);
450 array10[num6] = array10[num6].SetBit(6, cell.
isForceFloat);
452 array11[num6] = array11[num6].SetBit(0, cell.
isWatered);
453 array11[num6] = array11[num6].SetBit(1, cell.
isObjDyed);
454 array11[num6] = array11[num6].SetBit(2, cell.
crossWall);
455 array11[num6] = array11[num6].SetBit(3, cell.
hidePillar);
466 Write(
"objVals", array);
467 WriteIds(
"blocks", array2);
468 WriteIds(
"blockMats", array3);
469 WriteIds(
"floors", array4);
470 WriteIds(
"floorMats", array5);
471 WriteIds(
"objs", array6);
472 WriteIds(
"objMats", array7);
473 Write(
"decal", array8);
474 Write(
"flags", array10);
475 Write(
"flags2", array11);
476 Write(
"dirs", array9);
477 Write(
"heights", array12);
478 WriteIds(
"bridges", array13);
479 WriteIds(
"bridgeMats", array14);
480 Write(
"bridgeHeights", array15);
481 WriteIds(
"bridgePillars", array16);
482 WriteIds(
"roofBlocks", array18);
483 WriteIds(
"roofBlockMats", array19);
484 Write(
"roofBlockDirs", array17);
485 WriteIds(
"decos", array20);
486 WriteIds(
"decoMats", array21);
501 export.serializedCards.cards.Clear();
511 export.serializedCards.Add(chara2);
516 export.serializedCards.Add(chara2);
523 export.serializedCards.Add(thing);
533 export.serializedCards.Add(thing2);
537 List<Thing> list =
things;
538 things =
new List<Thing>();
543 void Write(
string name,
byte[] bytes)
547 void WriteIds(
string name,
int[] ids)
559 byte[] array = IO.ReadLZ4(path + s, size,
compression);
562 Debug.Log(
"Couldn't load:" + s);
563 return new byte[size];
572 return path +
".w" + width;
581 foreach (
int b
in array)
583 num = Mathf.Max(num, b);
585 int num2 = ((num <= 255) ? 1 : ((num <= 65535) ? 2 : 4));
586 byte[] array2 =
new byte[ids.Length * num2];
587 for (
int j = 0; j < ids.Length; j++)
589 for (
int k = 0; k < num2; k++)
591 array2[j * num2 + k] = (byte)(ids[j] >> 8 * k);
596 foreach (
int num3
in array)
602 for (
int l = 1; l < 5; l++)
604 IO.DeleteFile(text +
".b" + l);
611 private int[]
ReadCellIds(
string file,
string s,
int size,
int width)
613 byte[] array = IO.ReadLZ4(file, size * width,
compression);
618 if ((width != 1 && width != 2 && width != 4) || array.Length != (
long)size * (
long)width)
620 Debug.Log(
"Couldn't load:" + s);
623 int[] array2 =
new int[size];
624 for (
int i = 0; i < size; i++)
626 for (
int j = 0; j < width; j++)
628 array2[i] |= array[i * width + j] << 8 * j;
648 int size = num * num2;
655 byte[] data = TryLoad(
"objVals");
656 int[] data2 = TryLoadIds(
"blockMats");
657 int[] data3 = TryLoadIds(
"blocks");
658 int[] data4 = TryLoadIds(
"floorMats");
659 int[] data5 = TryLoadIds(
"floors");
660 int[] data6 = TryLoadIds(
"objs");
661 int[] data7 = TryLoadIds(
"objMats");
662 byte[] data8 = TryLoad(
"decal");
663 int[] data9 = TryLoadIds(
"decos");
664 int[] data10 = TryLoadIds(
"decoMats");
665 byte[] data11 = TryLoad(
"dirs");
666 byte[] data12 = TryLoad(
"flags");
667 byte[] data13 = TryLoad(
"flags2");
668 byte[] data14 = TryLoad(
"heights");
669 int[] data15 = TryLoadIds(
"bridges");
670 int[] data16 = TryLoadIds(
"bridgeMats");
671 byte[] data17 = TryLoad(
"bridgeHeights");
672 int[] data18 = TryLoadIds(
"bridgePillars");
673 int[] data19 = TryLoadIds(
"roofBlocks");
674 int[] data20 = TryLoadIds(
"roofBlockMats");
675 byte[] data21 = TryLoad(
"roofBlockDirs");
676 if (data18.Length < size)
678 data18 =
new int[size];
680 if (data.Length < size)
682 data =
new byte[size];
684 if (data13.Length < size)
686 data13 =
new byte[size];
688 Validate<byte>(ref data,
"objVals");
689 Validate<int>(ref data2,
"blockMats");
690 Validate<int>(ref data3,
"blocks");
691 Validate<int>(ref data4,
"floorMats");
692 Validate<int>(ref data5,
"floors");
693 Validate<int>(ref data6,
"objs");
694 Validate<int>(ref data7,
"objMats");
695 Validate<byte>(ref data8,
"decal");
696 Validate<int>(ref data9,
"decos");
697 Validate<int>(ref data10,
"decoMats");
698 Validate<byte>(ref data11,
"dirs");
699 Validate<byte>(ref data12,
"flags");
700 Validate<byte>(ref data13,
"flags2");
701 Validate<byte>(ref data14,
"heights");
702 Validate<int>(ref data15,
"bridges");
703 Validate<int>(ref data16,
"bridgeMats");
704 Validate<byte>(ref data17,
"bridgeHeights");
705 Validate<int>(ref data18,
"bridgePillars");
706 Validate<int>(ref data19,
"roofBlocks");
707 Validate<int>(ref data20,
"roofBlockMats");
708 Validate<byte>(ref data21,
"roofBlockDirs");
710 for (
int i = 0; i < num; i++)
712 for (
int j = 0; j < num2; j++)
719 _blockMat = data2[num3],
720 _block = data3[num3],
721 _floorMat = data4[num3],
722 _floor = data5[num3],
724 objMat = data7[num3],
727 _decoMat = data10[num3],
728 _dirs = data11[num3],
729 height = data14[num3],
730 _bridge = data15[num3],
731 _bridgeMat = data16[num3],
732 bridgeHeight = data17[num3],
733 bridgePillar = data18[num3],
734 _roofBlock = data19[num3],
735 _roofBlockMat = data20[num3],
736 _roofBlockDir = data21[num3],
737 isSeen = data12[num3].GetBit(1),
738 isHarvested = data12[num3].GetBit(2),
739 impassable = data12[num3].GetBit(3),
740 isModified = data12[num3].GetBit(4),
741 isClearSnow = data12[num3].GetBit(5),
742 isForceFloat = data12[num3].GetBit(6),
743 isToggleWallPillar = data12[num3].GetBit(7),
744 isWatered = data13[num3].GetBit(0),
745 isObjDyed = data13[num3].GetBit(1),
746 crossWall = data13[num3].GetBit(2),
747 hidePillar = data13[num3].GetBit(3),
748 toggleOcclusion = data13[num3].GetBit(4)
752 cell.bridgePillar = 0;
753 cell.hidePillar =
true;
775 foreach (KeyValuePair<int, CellEffect> cellEffect
in cellEffects)
777 int key = cellEffect.Key;
778 int num4 = key %
Size;
779 int num5 = key /
Size;
781 if (cellEffect.Value.IsFire)
788 byte[] TryLoad(
string s)
792 int[] TryLoadIds(
string s)
798 void Validate<T>(ref T[] reference,
string id)
800 if (reference.Length < size)
802 Debug.LogError(
"exception: size invalid:" +
id +
" " + reference.Length +
"/" + size);
803 reference =
new T[size];
839 custom.id = (mapMetaData.id = id);
840 IO.SaveFile(_path +
"meta", mapMetaData);
847 using ZipFile zipFile = ZipFile.Read(pathZip);
848 ZipEntry zipEntry = zipFile[
"meta"];
849 if (zipEntry !=
null)
851 using (MemoryStream stream =
new MemoryStream())
853 zipEntry.Extract(stream);
855 mapMetaData.path = pathZip;
860 catch (Exception message)
862 if (Application.isEditor)
872 IO.CreateTempDirectory();
873 ZipFile zipFile = ZipFile.Read(pathZip);
874 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
875 zipFile.ExtractAll(IO.TempPath);
878 using (zipFile =
new ZipFile())
880 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
881 zipFile.AddDirectory(IO.TempPath);
882 zipFile.Save(pathZip);
885 IO.DeleteTempDirectory();
998 public void SetSeen(
int x,
int z,
bool seen =
true,
bool refresh =
true)
1000 if (
cells[
x,
z].isSeen != seen)
1013 for (
int i = 0; i <
Size; i++)
1015 for (
int j = 0; j <
Size; j++)
1030 EClass._map.SetSeen(p.x, p.z);
1035 public void RefreshFOV(
int x,
int z,
int radius = 6,
bool recalculate =
false)
1044 item.RecalculateFOV();
1048 foreach (
Card item2
in list)
1059 item.RecalculateFOV();
1063 public void SetFloor(
int x,
int z,
int idMat = 0,
int idFloor = 0)
1068 public void SetFloor(
int x,
int z,
int idMat,
int idFloor,
int dir)
1071 cell._floorMat = idMat;
1072 cell._floor = idFloor;
1073 cell.floorDir = dir;
1074 cell.isWatered =
false;
1082 cell._decoMat = idMat;
1083 cell._deco = idDeco;
1087 public void SetBridge(
int x,
int z,
int height = 0,
int idMat = 0,
int idBridge = 0,
int dir = 0,
int idPillar = 0,
bool hidePillar =
false)
1090 cell.bridgeHeight = (byte)height;
1091 cell._bridgeMat = idMat;
1092 cell._bridge = idBridge;
1093 cell.bridgePillar = idPillar;
1094 cell.hidePillar = hidePillar;
1095 cell.floorDir = dir;
1096 if (cell.
room !=
null)
1106 cell._roofBlockMat = idMat;
1107 cell._roofBlock = idBlock;
1108 cell._roofBlockDir = (byte)(dir + height * 4);
1112 public void SetBlock(
int x,
int z,
int idMat = 0,
int idBlock = 0)
1117 public void SetBlock(
int x,
int z,
int idMat,
int idBlock,
int dir)
1121 cell._blockMat = idMat;
1122 cell._block = idBlock;
1123 cell.blockDir = dir;
1128 cell.isToggleWallPillar =
false;
1129 if (cell.
room !=
null)
1160 if (
x > 0 &&
z <
Size - 1)
1182 if (
x > 0 &&
z <
Size - 1)
1190 if (!
cells[
x,
z].HasFloodBlock)
1206 FloodSpiller floodSpiller =
flood;
1207 IFloodCell[,] array =
cells;
1208 FloodSpiller.Result result = floodSpiller.SpillFlood(array,
x,
z);
1209 if (!result.IsValid)
1214 foreach (IFloodCell
item in result.visited)
1230 foreach (IFloodCell item2
in result.visited)
1256 foreach (IFloodCell item3
in result.visited)
1261 room.AddPoint(
new Point(b, b2));
1265 room.AddPoint(
new Point(b, b2 - 1));
1270 room.AddPoint(
new Point(b + 1, b2));
1275 room.AddPoint(
new Point(b + 1, b2 - 1));
1285 cell.blockDir = dir;
1293 if (cell.
effect ==
null && amount > 0)
1319 if (CC !=
null && CC.IsPCFactionOrMinion && (CC.HasElement(1651) ||
EClass.
pc.
Evalue(1651) >= 2))
1324 List<Card> list =
new List<Card>();
1325 bool fire = ele == 910;
1326 bool cold = ele == 911;
1343 if (
item.IsPCFactionOrMinion)
1348 else if (!CanCook(
item))
1355 Card rootCard =
item.GetRootCard();
1365 if (
item.isThing &&
item.things.Count == 0)
1371 if (ele == 911 &&
item.HasElement(1236))
1379 Card rootCard2 =
item.GetRootCard();
1382 Msg.
Say((
item.isChara ?
"blanketInv_" :
"blanketGround_") + element.source.alias, thing,
item);
1394 foreach (
Thing item2
in item.things.List((
Thing a) => a.things.Count == 0))
1407 foreach (
Card item3
in list)
1414 if (item3.IsEquipmentOrRangedOrAmmo && (
EClass.
rnd(4) != 0 || ((item3.IsRangedWeapon || item3.Thing.isEquipped) && rootCard3.
IsPCFaction &&
EClass.
rnd(4) != 0)))
1421 if (item3.isFireproof || (!item3.category.IsChildOf(
"book") &&
EClass.
rnd(2) == 0))
1427 if (!item3.category.IsChildOf(
"drink") &&
EClass.
rnd(5) == 0)
1437 bool flag3 = CanCook(item3);
1446 if (!(item4.
row is
SourceThing.
Row { isOrigin: false, chance: not 0 } row) || row.components.IsEmpty() || (row.components.Length >= 3 && !row.components[2].StartsWith(
'+')) || !row.Category.IsChildOf(
"meal") || (row.HasTag(
CTAG.dish_fail) && power >
EClass.
rnd(500)))
1450 if (!row.factory.IsEmpty())
1452 switch (row.factory[0])
1461 if (row.components[0].Split(
'|').Contains(item3.id) || row.components[0].Split(
'|').Contains(item3.sourceCard._origin))
1466 if (list3.Count > 0)
1468 text = list3.RandomItemWeighted((
SourceThing.
Row r) => r.chance)?.
id;
1476 if (flag3 && !text.IsEmpty())
1479 List<Thing> list4 =
new List<Thing>();
1486 Msg.
Say(((rootCard3 == item3) ?
"cook_groundItem" :
"cook_invItem") + (fire ?
"" :
"_cold"), thing2, rootCard3, thing3.
Name);
1488 if (rootCard3 == item3)
1494 rootCard3.
Chara.
Pick(thing3, msg:
false);
1504 int num2 =
EClass.
rnd(item3.Num) / 2 + 1;
1505 if (item3.Num > num2)
1510 Msg.
Say((rootCard3 == item3) ?
"damage_groundItem" :
"damage_invItem", thing4, rootCard3);
1533 pos.PlayEffect(fire ?
"Element/eleFire" :
"Element/eleCold");
1539 bool CanCook(
Card c)
1541 if ((fire || cold) && c.
IsFood)
1543 return c.
category.IsChildOf(
"foodstuff");
1549 public void Burn(
int x,
int z,
bool instant =
false)
1579 if (cell.
room !=
null)
1596 foreach (
Card item in sharedPoint.ListCards())
1607 item.DamageHP(30L, 910);
1622 cell.effect = effect;
1658 cell.effect.amount += amount;
1675 public void SetObj(
int x,
int z,
int id = 0,
int value = 1,
int dir = 0)
1680 public void SetObj(
int x,
int z,
int idMat,
int idObj,
int value,
int dir,
bool ignoreRandomMat =
false)
1683 if (cell.
sourceObj.id == 118 || idObj == 118)
1685 EClass._zone.dirtyElectricity =
true;
1688 cell.objVal = (byte)value;
1689 cell.objMat = idMat;
1691 cell.isHarvested =
false;
1692 cell.isObjDyed =
false;
1694 if (!ignoreRandomMat && !sourceObj.
matCategory.IsEmpty())
1697 if (sourceObj.
tag.Contains(
"spot"))
1719 int num = ((!draw) ? 1 : 2);
1747 bool flag = p.sourceObj.id == 82;
1758 p.cell.objDir = row.
skin;
1786 if (recipeSource ==
null)
1791 if (iDIngredient ==
null)
1816 int num = (flag ? point.cell._roofBlock : point.
cell.
_block);
1823 bool flag2 = c ==
null || c.IsAgent || c.IsPCFactionOrMinion;
1830 point.cell._roofBlock = 0;
1840 if (flag2 && point.
sourceObj.tileType.IsBlockMount && mineObj)
1871 point.cell.isModified =
true;
1988 if (c ==
null && task !=
null)
1992 bool num = c ==
null || c.IsAgent || c.IsPCFactionOrMinion;
2002 if (soilCost > maxSoil)
2004 num2 -=
EClass.
rnd(2 + (soilCost - maxSoil) / 10);
2017 cell.isHarvested =
true;
2027 if (cell.
HasBlock && (sourceObj.
id == 18 || sourceObj.
id == 19))
2029 MineBlock(point, recoverBlock:
false, c, mineObj:
false);
2040 switch (sourceObj.
alias)
2050 string[] array = sourceObj.
components[num3].Split(
'/');
2052 if (array.Length > 1)
2060 cell.gatherCount = 0;
2061 void Pop(
Thing thing2)
2131 if (!
item.isThing || !
item.trait.CanBeDestroyed || !
item.IsInstalled)
2135 HitResult hitResult =
item.TileType._HitTest(point,
item.Thing, canIgnore:
false);
2136 if (
item.Thing.stackOrder != detail.things.IndexOf(
item.Thing) || (hitResult !=
HitResult.Valid && hitResult !=
HitResult.Warning))
2152 for (
int i = 0; i < 4; i++)
2155 if (dependedRamp !=
null)
2169 public void AddDecal(
int x,
int z,
int id,
int amount = 1,
bool refresh =
true)
2171 if (
x < 0 || z < 0 || x >=
Size ||
z >=
Size)
2178 if (cell.
decal / 8 !=
id && cell.
decal % 8 == 0)
2182 int num = Mathf.Clamp(((cell.
decal / 8 ==
id) ? (cell.
decal % 8) : 0) + amount, 0, 7);
2183 cell.decal = (byte)(
id * 8 + num);
2191 public void SetDecal(
int x,
int z,
int id = 0,
int amount = 1,
bool refresh =
true)
2193 cells[
x,
z].
decal = (byte)((
id != 0 && amount != 0) ? ((uint)(
id * 8 + amount)) : 0u);
2250 for (
int i = 0; i <
Size; i++)
2252 for (
int j = 0; j <
Size; j++)
2262 for (
int i =
x - 2; i <
x + 3; i++)
2264 if (i < 0 || i >=
Size)
2268 for (
int j =
z - 2; j <
z + 3; j++)
2270 if (j >= 0 && j <
Size && (
x != i ||
z != j))
2289 cell.isSurrounded4d = cell2.HasFullBlock && cell3.HasFullBlock && cell4.HasFullBlock && cell5.
HasFullBlock;
2290 cell.isSurrounded = cell.isSurrounded4d && cell6.HasFullBlock && cell7.HasFullBlock && cell8.HasFullBlock && cell9.
HasFullBlock;
2298 if (blockType ==
null)
2322 if (!blockType.IsRamp)
2343 if (
left.HasRamp && !
left.HasStairs &&
left.blockDir == 3)
2348 if (
back.HasRamp && !
back.HasStairs &&
back.blockDir == 2)
2358 for (
int i = 0; i < tries; i++)
2360 point.x = center.x +
EClass.
rnd(radius * 2 + 1) - radius;
2361 point.z = center.z +
EClass.
rnd(radius * 2 + 1) - radius;
2368 Debug.Log(
"GetRandomPoint failed center:" + center?.ToString() +
" rad:" + radius);
2369 point.IsValid =
false;
2377 for (
int i = 0; i < 10000; i++)
2401 int num = ((
EClass.
rnd(2) == 0) ? 1 : (-1));
2402 int num2 = ((
EClass.
rnd(2) == 0) ? 1 : (-1));
2403 for (
int i = 0; i < 3; i++)
2405 point.x = center.x - num + i * num;
2406 for (
int j = 0; j < 3; j++)
2408 point.z = center.z - num2 + j * num2;
2420 List<Point> list =
new List<Point>();
2433 List<Point> list =
new List<Point>();
2446 List<Point> list =
new List<Point>();
2459 List<Chara> list =
new List<Chara>();
2463 if (detail ==
null || detail.
charas.Count <= 0)
2467 foreach (
Chara chara
in item.detail.charas)
2477 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));
2479 List<Point> list =
new List<Point>();
2484 if ((Mathf.Abs(diff - angle2) < angle || Mathf.Abs(diff - angle2 + 360f) < angle || Mathf.Abs(360f - diff + angle2) < angle) &&
Los.
IsVisible(center, p) && !p.
IsBlocked)
2494 return Los.
ListVisible(center, to, radius,
null, returnOnBlocked);
2499 if (size >
Size / 2 + 1)
2501 size =
Size / 2 - 1;
2509 bounds.Size = b.
Size;
2514 for (
int i = 0; i <
Size; i++)
2516 for (
int j = 0; j <
Size; j++)
2518 action(
cells[i, j]);
2526 for (
int i = 0; i <
Size; i++)
2528 for (
int j = 0; j <
Size; j++)
2530 action(point.
Set(i, j));
2537 for (
int i = 0; i <
Size; i++)
2539 for (
int j = 0; j <
Size; j++)
2549 int num = (int)Mathf.Ceil(r);
2550 for (
int i = _x - num; i < _x + num + 1; i++)
2552 if (i < 0 || i >=
Size)
2556 for (
int j = _z - num; j < _z + num + 1; j++)
2558 if (j >= 0 && j <
Size && (
float)((i - _x) * (i - _x) + (j - _z) * (j - _z)) < r * r)
2570 for (
int i = _x - r; i < _x + r + 1; i++)
2572 if (i < 0 || i >=
Size)
2576 for (
int j = _z - r; j < _z + r + 1; j++)
2578 if (j >= 0 && j <
Size)
2590 int num2 = center.
z;
2592 for (
int i = num - 1; i < num + 2; i++)
2594 if (i < 0 || i >=
Size)
2598 for (
int j = num2 - 1; j < num2 + 2; j++)
2600 if (j >= 0 && j <
Size)
2613 for (num = 0; num <
Size; num++)
2616 for (num2 = 0; num2 <
Size; num2++)
2694 List<Chara> list =
new List<Chara>();
2707 List<Thing> list =
new List<Thing>();
2734 if (thing.
parent !=
null)
2738 thing.isMasked =
false;
2739 thing.isRoofItem =
false;
2770 if (chara.
uid == uid)
2794 if (thing.
uid == uid)
2806 if (thing.
trait is T)
2808 return thing.trait as T;
2837 if (type ==
null || (area1 ==
null && area2 ==
null))
2841 Thing thing = Find(area1);
2842 if (thing ==
null && area2 !=
null)
2844 thing = Find(area2);
2867 if (area1 ==
null && area2 ==
null)
2876 if (enumerable.Count() > 0)
2878 thing = enumerable.RandomItem() as
Thing;
2881 if (thing ==
null && area2 !=
null)
2884 if (enumerable2.Count() > 0)
2886 thing = enumerable2.RandomItem() as
Thing;
2894 Thing result =
null;
2896 where a.pos.IsPublicSpace()
2898 if (enumerable.Count() > 0)
2900 result = enumerable.RandomItem() as
Thing;
2908 where a.type.IsPublicArea
2909 select a).RandomItem();
static bool not(DramaManager dm, Dictionary< string, string > line, params string[] parameters)
override bool IsRoofEditMode(Card c=null)
void Add(Act a, string s="")
Thing TryMakeRandomItem(int lv=-1, TryMakeRandomItemSource itemSource=TryMakeRandomItemSource.Default, Chara crafter=null)
void SetPlaceState(PlaceState newState, bool byPlayer=false)
ElementContainerCard elements
virtual void Die(Element e=null, Card origin=null, AttackSource attackSource=AttackSource.None, Chara originalTarget=null)
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Thing AddThing(string id, int lv=-1)
void Kick(Point p, bool ignoreSelf=false, bool checkWall=true)
void ForeachPoint(Action< Point, bool > action)
void ModCharge(int a, bool destroy=false)
bool HasEditorTag(EditorTag tag)
Thing Add(string id, int num=1, int lv=1)
SourceCategory.Row category
SourceBlock.Row sourceBlock
bool CanBuildRamp(int dir)
SourceFloor.Row sourceFloor
SourceMaterial.Row matObj
CellDetail GetOrCreateDetail()
SourceMaterial.Row matObj_fixed
void PickOrDrop(Point p, string idThing, int idMat=-1, int num=1, bool msg=true)
override bool IsPCFaction
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
bool ignoreBackerDestoryFlag
Thing GetOrCreateDebugContainer()
static void MakeDish(Thing food, int lv, Chara crafter=null, int seed=-1)
static void RebuildCritter(Cell cell)
static int curve(long _a, int start, int step, int rate=75)
static SourceManager sources
static FactionBranch Branch
static Effect Get(Effect original)
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Element ModBase(int ele, int v)
static Element Create(int id, int v=0)
static FowProfile Load(string id)
static void SaveFile(string path, object obj)
bool disableUsermapBenefit
static void Load(string id, bool cloud)
bool Save(bool isAutoSave=false, bool silent=false)
void PopMineObj(Chara c=null)
LogicalPoint GetOrCreate(Point point)
static List< Point > ListVisible(Point p1, Point p2, int radius, Action< Point, bool > _onVisit=null, bool returnOnBlocked=true)
static bool IsVisible(Point p1, Point p2, Action< Point, bool > _onVisit=null)
static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string cat, SourceMaterial.Row fallback)
void SetBounds(int _x, int _z, int _maxX, int _maxZ)
Point GetSurface(int x, int z, bool walkable=true)
void ForeachCell(Action< Cell > action)
new void ForeachXYZ(Action< int, int > action)
new void ForeachCell(Action< Cell > action)
void TrySmoothPick(Point p, Thing t, Chara c)
Thing FindThing(Type type, BaseArea area1, BaseArea area2=null)
void RefreshNeighborTiles(int x, int z)
Thing FindThing(Func< Thing, bool > func)
PlantData TryGetPlant(Point p)
void ForeachSphere(int _x, int _z, float r, Action< Point > action)
Dictionary< int, int > gatherCounts
void SetBridge(int x, int z, int height=0, int idMat=0, int idBridge=0, int dir=0, int idPillar=0, bool hidePillar=false)
static readonly int[] CellIdWidths
void Shift(Vector2Int offset)
Thing FindThing(Type type, Chara c=null)
void ExportMetaData(string _path, string id, PartialMap partial=null)
Chara FindChara(string id)
IEnumerable< Card > Cards
int[] ReadCellIds(string file, string s, int size, int width)
void RefreshSingleTile(int x, int z)
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
void RemovePlant(Point pos)
BaseArea FindPublicArea()
static void UpdateMetaData(string pathZip, PartialMap partial=null)
void DestroyObj(Point point)
void Save(string path, ZoneExportData export=null, PartialMap partial=null)
void TrySmoothPick(Cell cell, Thing t, Chara c)
Dictionary< string, int > cellWidths
void AddCardOnActivate(Card c)
Dictionary< int, CellEffect > cellEffects
void RefreshFOV(int x, int z, int radius=6, bool recalculate=false)
List< Point > ListPointsInArc(Point center, Point to, int radius, float angle)
void MoveCard(Point p, Card t)
Thing FindThing(string workTag, Chara c)
void AddBackerTree(bool draw)
void Reveal(Point center, int power=100)
void SetBlockDir(int x, int z, int dir)
void MineObj(Point point, Task task=null, Chara c=null)
void SetLiquid(int x, int z, CellEffect effect=null)
void OnCardRemovedFromZone(Card t)
Point GetNearbyResourcePoint(Point center)
void SetDecal(int x, int z, int id=0, int amount=1, bool refresh=true)
PlantData TryGetPlant(Cell c)
int CountChara(Faction faction)
void MineBlock(Point point, bool recoverBlock=false, Chara c=null, bool mineObj=true)
List< Chara > ListCharasInCircle(Point center, float radius, bool los=true)
void SetFloor(int x, int z, int idMat, int idFloor, int dir)
void OnDeserialized(StreamingContext context)
void SetFoormark(Point pos, int id, int angle, int offset=0)
byte[] TryLoadFile(string path, string s, int size)
void _ValidateInstalled(int x, int y)
int GetRampDir(int x, int z, TileType blockType=null)
List< Thing > ListThing< T >()
Dictionary< int, int > backerObjs
void ModFire(int x, int z, int amount)
void SetDeco(int x, int z, int idMat, int idDeco)
void _AddCard(int x, int z, Card t, bool onAddToZone)
void Burn(int x, int z, bool instant=false)
void MineObjSound(Point point)
void OnSerializing(StreamingContext context)
void SetSeen(int x, int z, bool seen=true, bool refresh=true)
void ModLiquid(int x, int z, int amount)
void MineFloor(Point point, Chara c=null, bool recoverBlock=false, bool removePlatform=true)
void SetFloor(int x, int z, int idMat=0, int idFloor=0)
void SetBounds(MapBounds b)
void TryShatter(Point pos, int ele, int power, Card CC=null)
void SetBlock(int x, int z, int idMat=0, int idBlock=0)
PlantData AddPlant(Point pos, Thing seed)
void ForeachSquare(int _x, int _z, int r, Action< Point > action)
void TryRemoveRoom(int x, int z)
List< Footmark > footmarks
void SetRoofBlock(int x, int z, int idMat, int idBlock, int dir, int height)
new Point GetRandomEdge(int r=3)
void OnImport(ZoneExportData data)
List< Point > ListPointsInSquare(Point center, int radius, bool mustBeWalkable=true, bool los=true)
new void ForeachPoint(Action< Point > action)
void TryAddRoom(int x, int z)
void DestroyBlock(int x, int z)
void QuickRefreshTile(int x, int z)
List< Chara > serializedCharas
static bool isDirtySunMap
static MapMetaData GetMetaData(string pathZip)
virtual void OnSerializing()
static int WriteCellIds(string path, int[] ids, IO.Compression compression)
void RemoveLonelyRamps(Cell cell)
void SetBlock(int x, int z, int idMat, int idBlock, int dir)
void SetLiquid(int x, int z, int id, int value=1)
void ValidateInstalled(Point p)
void DropBlockComponent(Point point, TileRow r, SourceMaterial.Row mat, bool recoverBlock, bool isPlatform=false, Chara c=null)
MapExportSetting exportSetting
void SetEffect(int x, int z, CellEffect effect=null)
void OnCardAddedToZone(Card t, int x, int z)
Thing FindThing(string workTag, BaseArea area1=null, BaseArea area2=null)
void ForeachNeighbor(Point center, Action< Point > action)
void OnSetBlockOrDoor(int x, int z)
void Load(string path, bool import=false, PartialMap partial=null)
CellEffectManager effectManager
List< Point > ListPointsOnEdge(Point center, int destDist, bool mustBeWalkable=true, bool los=true)
List< Point > ListPointsInLine(Point center, Point to, int radius, bool returnOnBlocked=true)
Cell GetDependedRamp(Cell cell)
void MineRamp(Point point, int ramp, bool recoverBlock=false)
List< Point > ListPointsInCircle(Point center, float radius, bool mustBeWalkable=true, bool los=true)
void CreateNew(int size, bool setReference=true)
void AddDecal(int x, int z, int id, int amount=1, bool refresh=true)
void RevealAll(bool reveal=true)
IO.Compression compression
void SetObj(int x, int z, int idMat, int idObj, int value, int dir, bool ignoreRandomMat=false)
Dictionary< int, PlantData > plants
List< Chara > ListChara(Faction faction)
List< TransAnime > pointAnimes
void RefreshShadow(int x, int z)
void ApplyBackerObj(Point p, int id=-1)
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
SourceBacker.Row GetBackerObj(Point p)
static string CellIdPath(string path, int width)
static HashSet< int > sunMap
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
static PathManager Instance
HashSet< int > doneBackers
void ClearMapHighlights()
SourceMaterial.Row matBlock
SourceMaterial.Row matFloor
List< Card > ListCards(bool includeMasked=false)
Point Set(int _x, int _z)
SourceMaterial.Row matBridge
void SetFloor(int idMat=0, int idFloor=0)
SoundSource PlaySound(string id, bool synced=true, float v=1f, bool spatial=true)
bool Equals(int _x, int _z)
SourceFloor.Row sourceFloor
void SetBlock(int idMat=0, int idBlock=0)
bool HasRoomOrArea(BaseArea a)
Point Clamp(bool useBounds=false)
float GetAngle2(Point to)
void Animate(AnimeID id, bool animeBlock=false)
SourceFloor.Row sourceBridge
void OnCardAddedToZone(Card c)
Dictionary< string, PropSet > workMap
static void SetSeed(int a=-1)
static List< RecipeSource > list
static RecipeSource Get(string id)
static SceneProfile Load(string id)
void AddActorEx(Card c, Action< ActorEx > onBeforeSetOwner=null)
void Restore(Map map, Map orgMap, bool addToZone, PartialMap partial=null)
void AddBlood(Point p, int a=1)
string GetSoundDead(RenderRow c=null)
bool OnMineWreck(Point point)
static Thing CreateRawMaterial(SourceMaterial.Row m)
static Thing CreateBlock(int id, int idMat)
static Thing CreateFloor(int id, int idMat, bool platform=false)
static Thing Create(string id, int idMat=-1, int lv=-1)
static Thing MakeSeed(string idSource)
virtual void OnAddedToZone()
virtual bool CanCopyInBlueprint
virtual void OnRemovedFromZone()
virtual List< Point > ListPoints(Point center=null, bool onlyPassable=true, bool allowChara=true)
virtual bool CanOnlyCarry
static void Say(string text, FontColor fontColor=FontColor.Default, Sprite sprite=null)
SerializedCards serializedCards
virtual bool DisableRooms
virtual bool IsUnderwater
Card AddCard(Card t, Point point)
void Init(IPathfindGrid _grid, WeightCell[,] _weightMap, int size)
bool IsBelow(int _major, int _minor, int _batch)