1130{
1132 {
1133 idHat = null;
1134 base.dateHat = 0;
1135 }
1137 }
1138
1139 public void OnVisit()
1140 {
1142 {
1143 ResetHostility();
1145 List<Chara> list = new List<Chara>();
1147 {
1150 {
1151 chara.c_fur = 0;
1152 }
1154 {
1155 list.Add(chara);
1156 }
1157 }
1159 {
1161 }
1162 }
1164 {
1165 RefreshDeathSentense();
1166 }
1167 RefreshCriminal();
1169 events.OnVisit();
1170 OnActivate();
1171 UpdateQuests();
1172 OnBeforeSimulate();
1173 isSimulating = true;
1174 try
1175 {
1176 Simulate();
1177 }
1178 catch (Exception exception)
1179 {
1180 Debug.LogException(exception);
1181 }
1182 finally
1183 {
1184 isSimulating = false;
1185 }
1186 OnAfterSimulate();
1190 {
1191 base.visitCount++;
1192 }
1194 if (HasField(10000))
1195 {
1197 }
1198 }
1199
1200 public void RefreshDeathSentense()
1201 {
1203 {
1205 {
1207 }
1208 }
1209 }
1210
1212 {
1214 if (ShouldAutoRevive)
1215 {
1216 foreach (
Chara deadChara
in map.deadCharas)
1217 {
1219 {
1222 {
1224 }
1226 }
1227 }
1228 }
1230 {
1232 {
1234 Point point = GetSpawnPos(value);
1236 {
1238 }
1240 }
1241 }
1242 map.deadCharas.Clear();
1243 }
1244
1245 public virtual void OnRegenerate()
1246 {
1247 }
1248
1249 public virtual void OnActivate()
1250 {
1251 if (!(id == "startVillage2"))
1252 {
1253 return;
1254 }
1256 {
1257 SetBGM(121, refresh: false);
1258 }
1259 int num = 0;
1261 {
1263 {
1264 num++;
1265 }
1266 }
1267 if (num > 0)
1268 {
1269 Msg.
Say(
"num_silvercat", num.ToString() ??
"");
1270 }
1271 }
1272
1273 public virtual void OnBeforeDeactivate()
1274 {
1275 }
1276
1277 public virtual void OnDeactivate()
1278 {
1279 }
1280
1281 public virtual void OnBeforeSimulate()
1282 {
1283 }
1284
1285 public virtual void OnVisitNewMapOrRegenerate()
1286 {
1287 }
1288
1289 public virtual void OnAfterSimulate()
1290 {
1291 }
1292
1293 public virtual void OnAdvanceHour()
1294 {
1295 }
1296
1297 public void Simulate()
1298 {
1300 {
1301 if (
Boss !=
null && IsNefia)
1302 {
1306 }
1307 int num = Mathf.Clamp(MinsSinceLastActive, 1, 10000);
1309 {
1311 {
1312 chara2.hp = 0;
1313 }
1315 {
1317 {
1318 chara2.mana.value = 0;
1319 }
1321 {
1322 chara2.stamina.value = 0;
1323 }
1324 }
1325 if (num > 60)
1326 {
1327 chara2.resistCon = null;
1328 }
1330 {
1331 Msg.ignoreAll = true;
1333 chara2.
HealHP((
int)((
long)Mathf.Max(1, chara2.
MaxHP) * (
long)Mathf.Min(num, 20) / 20));
1334 chara2.
mana.
Mod(Mathf.Max(1, chara2.
mana.
max) * Mathf.Min(num, 20) / 20);
1336 Msg.ignoreAll = false;
1337 }
1338 }
1339 }
1340 Debug.Log(
"Last Active:" + base.lastActive);
1341 if (base.lastActive == 0 || IsRegion)
1342 {
1343 return;
1344 }
1345 if (pendingSimHours < 0)
1346 {
1347 pendingSimHours = 0;
1348 }
1349 int num2 = GetInt(3);
1350 if (num2 == 0)
1351 {
1353 }
1355 int hourSinceLastActive = HourSinceLastActive;
1356 if (hourSinceLastActive <= 1 && pendingSimHours == 0)
1357 {
1358 return;
1359 }
1360 int num3 = hourSinceLastActive + pendingSimHours;
1361 int num4 = ((num2 > 0 && num3 > num2) ? (num3 - num2) : 0);
1362 num3 -= num4;
1363 int num5 = ((EClass.player.simulatingZone && num3 > maxSleepSimHours) ? maxSleepSimHours : num3);
1364 pendingSimHours = num3 - num5;
1365 Debug.Log(
$"{Name} Simulate/{num5}/{pendingSimHours}/skipped {num4}");
1366 try
1367 {
1370 int passed = num5 + num4;
1371 int num6 = passed / 24;
1372 if (num6 > 0)
1373 {
1375 {
1376 if (!
item.IsPCParty)
1377 {
1378 item.OnSleep(200, num6);
1379 if (
item.conSleep !=
null)
1380 {
1381 item.conSleep.Kill();
1382 }
1384 {
1386 }
1387 if (
item.things.Count > 20)
1388 {
1390 }
1391 }
1392 }
1393 }
1394 VirtualDate.current = virtualDate;
1395 int num7 = 0;
1396 for (int i = 0; i < num5; i++)
1397 {
1398 try
1399 {
1401 }
1402 catch (Exception exception)
1403 {
1404 if (num7++ == 0)
1405 {
1406 Debug.LogException(exception);
1407 }
1408 }
1409 }
1411 {
1413 });
1414 VirtualDate.current = null;
1415 if (!IsPCFaction)
1416 {
1417 return;
1418 }
1419 int num8 = 0;
1420 foreach (
Chara item2
in list)
1421 {
1423 {
1424 continue;
1425 }
1427 {
1428 if (item2.
id ==
"bee")
1429 {
1430 num8++;
1431 }
1432 if (num6 > 0 && item2.
IsGuest())
1433 {
1436 }
1437 continue;
1438 }
1439 if (num6 > 0)
1440 {
1442 item2.
SetAI(goalWork);
1444 {
1445 (goalWork as
GoalWork).FindWork(item2);
1446 }
1449 item2.
SetAI(goalWork);
1451 {
1452 (goalWork as
GoalWork).FindWork(item2);
1453 }
1455 }
1458 {
1460 }
1461 }
1462 List<Thing> list2 = new List<Thing>();
1464 {
1466 {
1467 list2.Add(thing);
1468 }
1469 }
1470 if (num8 >= list2.Count)
1471 {
1472 return;
1473 }
1474 for (int num9 = num8; num9 < list2.Count; num9++)
1475 {
1477 {
1479 AddCard(chara, list2.RandomItem().pos);
1481 chara.c_originalHostility = c_originalHostility;
1482 }
1483 }
1484 }
1485 finally
1486 {
1487 VirtualDate.current = null;
1488 }
1489 }
1490
1492 {
1496 bool flag = zone ==
null || zone.lv > base.
lv;
1497 if (IsRegion)
1498 {
1500 {
1502 if (GetZoneAt(topZone.
x, topZone.
y) !=
null)
1503 {
1505 }
1506 }
1507 }
1509 {
1511 }
1513 {
1514 enterState = RegionEnterState;
1515 }
1517 {
1519 }
1520 float rate = zoneTransition?.
ratePos ?? (-1f);
1521 if (IsPCFaction)
1522 {
1524 {
1526 if (spot != null)
1527 {
1529 if (nearestPoint !=
null && nearestPoint.
IsValid)
1530 {
1531 return nearestPoint;
1532 }
1533 }
1534 }
1535 }
1536 while (true)
1537 {
1538 switch (enterState)
1539 {
1541 return new Point(zoneTransition.
x, zoneTransition.
z);
1543 {
1545 {
1547 {
1549 if (traitTeleporter != null)
1550 {
1552 }
1553 if (traitTeleporter !=
null && !zoneTransition.
idTele.IsEmpty() && zoneTransition.
idTele == traitTeleporter.
id.IsEmpty(traitTeleporter.
GetParam(3)))
1554 {
1556 }
1557 }
1558 }
1560 {
1562 {
1564 }
1565 }
1567 if (randomThing2 != null)
1568 {
1570 }
1572 }
1576 {
1578 {
1580 {
1582 {
1584 }
1585 }
1587 if (randomThing != null)
1588 {
1590 }
1591 }
1594 {
1596 if (thing != null)
1597 {
1599 }
1600 }
1602 if (thing != null)
1603 {
1605 }
1607 if (thing != null)
1608 {
1610 }
1611 if (base.lv == 0)
1612 {
1613 goto IL_04da;
1614 }
1615 flag = base.lv <= 0;
1616 break;
1617 }
1620 if (map.config.embarkX != 0)
1621 {
1622 return new Point(map.config.embarkX, map.config.embarkY);
1623 }
1624 return map.GetCenterPos().GetNearestPoint(allowBlock: false, allowChara: false);
1626 return map.bounds.GetTopPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1628 return map.bounds.GetRightPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1630 return map.bounds.GetBottomPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1632 return map.bounds.GetLeftPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1638 {
1639 return new Point(map.config.embarkX, map.config.embarkY);
1640 }
1641 return new Point(zoneTransition.
x, zoneTransition.
z);
1643 return GetRandomVisitPos(c);
1645 flag = true;
1646 break;
1648 flag = false;
1649 break;
1650 }
1651 break;
1652 IL_04da:
1654 }
1656 {
1658 {
1660 {
1661 c.
SetDir(traitNewZone.owner.dir);
1662 }
1663 return traitNewZone.GetExitPos();
1664 }
1665 }
1667 {
1668 if (thing6.
trait is
TraitNewZone traitNewZone2 && ((flag && traitNewZone2.IsUpstairs) || (!flag && traitNewZone2.IsDownstairs)))
1669 {
1671 {
1672 c.
SetDir(traitNewZone2.owner.dir);
1673 }
1674 return traitNewZone2.GetExitPos();
1675 }
1676 }
1677 return GetRandomVisitPos(c);
1678 }
1679
1681 {
1683 if (
EClass.
rnd(3) == 0 && map.rooms.listRoom.Count > 0)
1684 {
1685 point = map.rooms.listRoom.RandomItem().points.RandomItem();
1686 }
1687 if (point ==
null &&
EClass.
rnd(4) != 0)
1688 {
1690 if (ie.Count() > 0)
1691 {
1693 }
1694 }
1695 if (point == null)
1696 {
1697 point = map.bounds.GetRandomSurface(centered:
false, walkable:
true, !IsPCFaction && !(
this is
Zone_Civilized)) ?? map.bounds.
GetRandomPoint();
1698 }
1700 }
1701
1702 public void AddGlobalCharasOnActivate()
1703 {
1704 Point spawnPosPC =
null;
1706 {
1707 spawnPosPC = GetSpawnPos(
EClass.
pc);
1708 }
1709 if (spawnPosPC == null)
1710 {
1711 spawnPosPC = map.GetCenterPos();
1712 }
1714 {
1716 }
1719 {
1721 {
1722 continue;
1723 }
1725 {
1728 }
1729 else
1730 {
1732 {
1733 continue;
1734 }
1736 {
1737 c.isRestrained = false;
1738 }
1740 {
1741 Point pos = (c.IsPC ? spawnPosPC : (c.IsPCParty ? spawnPosPC.
GetNearestPoint(allowBlock:
false, allowChara:
false, allowInstalled:
true, ignoreCenter:
true) : GetSpawnPos(c)));
1743 {
1745 {
1746 pos.
Set(spawnPosPC);
1747 }
1749 {
1752 {
1754 {
1756 return true;
1757 }
1758 return false;
1759 }, allowBlock: false, EClass.pc.party.members.Count >= 12, allowInstalled: true, ignoreCenter: true, EClass._zone.IsRegion ? 2 : 6))
1760 {
1761 pos.
Set(spawnPosPC);
1762 }
1763 }
1764 }
1766 c.global.transition = null;
1767 }
1768 map.charas.Add(c);
1769 map.AddCardOnActivate(c);
1770 }
1771 }
1773 {
1774 Point nearestPoint = spawnPosPC.
GetNearestPoint(allowBlock:
false, allowChara:
false, allowInstalled:
true, ignoreCenter:
true);
1775 item.enemy = null;
1776 item.pos.Set(nearestPoint);
1777 map.charas.Add(
item);
1778 map.AddCardOnActivate(
item);
1779 }
1781 }
1782
1783 public void Deactivate()
1784 {
1785 if (!IsUserZone && !IsPCFaction && map != null)
1786 {
1787 List<Thing> list = new List<Thing>();
1789 {
1791 {
1792 list.Add(thing);
1793 }
1794 }
1796 {
1797 foreach (
Thing item in map.props.stocked.Things.Concat(map.props.roaming.Things))
1798 {
1799 if (
item.IsContainer)
1800 {
1802 {
1804 {
1805 list.Add(thing2);
1806 }
1807 }
1808 }
1810 {
1812 }
1813 }
1814 }
1815 if (list.Count > 0)
1816 {
1817 Msg.
Say(
"pick_valuable");
1818 foreach (
Thing item2
in list)
1819 {
1820 Msg.
Say(
"pick_valuable2", item2);
1822 }
1823 }
1824 }
1826 {
1827 base.isPeace = false;
1828 }
1829 OnBeforeDeactivate();
1830 if (IsPCFaction)
1831 {
1832 foreach (
Chara member
in branch.members)
1833 {
1835 }
1836 }
1839 map.OnDeactivate();
1841 EClass.game.activeZone = null;
1842 if (IsInstance)
1843 {
1844 UnloadMap();
1845 base.isGenerated = false;
1846 }
1847 if (forceRegenerate)
1848 {
1849 UnloadMap();
1850 }
1851 OnDeactivate();
1852 }
1853
1854 public void OnKillGame()
1855 {
1857 {
1859 {
1861 }
1862 }
1863 }
1864
1865 public void UnloadMap()
1866 {
1867 map = null;
1868 if (bp != null)
1869 {
1870 bp.map = null;
1871 }
1872 if (branch != null)
1873 {
1874 branch.OnUnloadMap();
1875 }
1876 Debug.Log(
"Unloaded Map:" +
this);
1877 }
1878
1879 public void ClaimZone(
bool debug =
false,
Point pos =
null)
1880 {
1884 branch.OnCreate(this);
1885 if (base.icon == 0)
1886 {
1887 base.icon = 332;
1888 }
1889 instance = null;
1890 base.dateExpire = 0;
1892 Register();
1894 {
1895 thing.isNPCProperty = false;
1896 }
1899 if (debug)
1900 {
1901 for (int i = 0; i < 7; i++)
1902 {
1905 branch.AddMemeber(chara);
1906 }
1907 }
1908 else
1909 {
1914 if (pos == null)
1915 {
1917 }
1920 }
1921 base.idPrefix = 0;
1923 {
1925 }
1927 {
1930 }
1931 }
1932
1933 public void AbandonZone()
1934 {
1937 {
1940 {
1942 }
1943 });
1945 SetMainFaction(null);
1947 }
1948
1949 public bool CanDestroy()
1950 {
1952 {
1953 return false;
1954 }
1955 if (IsInstance)
1956 {
1957 return true;
1958 }
1959 bool flag = false;
1960 switch (id)
1961 {
1962 case "cave_dragon":
1964 {
1965 flag = true;
1966 }
1967 break;
1968 case "cave_yeek":
1970 {
1971 flag = true;
1972 }
1973 break;
1974 case "cave_mino":
1976 {
1977 flag = true;
1978 }
1979 break;
1980 case "cave_dead":
1982 {
1983 flag = true;
1984 }
1985 break;
1986 case "oldkeep":
1988 {
1989 flag = true;
1990 }
1991 break;
1992 }
1993 Zone topZone = GetTopZone();
1994 if (!flag)
1995 {
1997 {
1998 return false;
1999 }
2000 if (!base.isRandomSite && !(
this is
Zone_Field) && (topZone ==
null || topZone ==
this || topZone.
FindDeepestZone() ==
this))
2001 {
2002 return false;
2003 }
2004 }
2006 {
2007 return false;
2008 }
2010 {
2012 if (zone !=
null && zone.
GetTopZone() ==
this)
2013 {
2014 return false;
2015 }
2016 }
2017 return true;
2018 }
2019
2020 public override void _OnBeforeSave()
2021 {
2022 if (CanDestroy())
2023 {
2024 Debug.Log(
"Deleting Zone:" +
this);
2025 if (!destryoed)
2026 {
2027 Destroy();
2028 }
2029 }
2030 else if (map != null)
2031 {
2032 Debug.Log(
"Saving Zone:" +
this);
2033 map.Save(base.pathSave);
2034 if (!base.isMapSaved)
2035 {
2036 base.isMapSaved = true;
2038 IO.
CopyDir(pathTemp +
"Texture Replace", base.pathSave +
"/Texture Replace");
2039 }
2040 if (!IsActiveZone)
2041 {
2042 UnloadMap();
2043 }
2044 }
2045 }
2046
2047 public override void OnLoad()
2048 {
2049 if (branch != null)
2050 {
2051 branch.SetOwner(this);
2052 }
2053 events.OnLoad(this);
2054 }
2055
2056 public override void Destroy()
2057 {
2058 children.ForeachReverse(delegate(
Spatial z)
2059 {
2061 });
2062 if (map != null)
2063 {
2064 UnloadMap();
2065 }
2066 if (parent != null && parent.IsRegion && instance == null)
2067 {
2069 }
2071 destryoed = true;
2072 base.isGenerated = false;
2073 }
2074
2075 public void ClearZones(
Zone current =
null)
2076 {
2077 if (map != null)
2078 {
2079 UnloadMap();
2080 }
2081 base.isGenerated = false;
2082 Zone topZone = GetTopZone();
2083 if (topZone != this)
2084 {
2086 return;
2087 }
2088 children.ForeachReverse(delegate(
Spatial c)
2089 {
2090 if (c != current)
2091 {
2093 }
2094 });
2095 }
2096
2097 public void OnChildNumChange(
Card c)
2098 {
2099 }
2100
2102 {
2103 return this;
2104 }
2105
2106 public Zone GetTopZone()
2107 {
2108 if (parent == null || parent.IsRegion)
2109 {
2110 return this;
2111 }
2112 return parent as
Zone;
2113 }
2114
2115 public Card AddCardSplinkle(
Card t,
Point center,
int radius = 4)
2116 {
2118 for (int i = 0; i < 1000; i++)
2119 {
2123 {
2124 return AddCard(t, point);
2125 }
2126 }
2127 return AddCard(t, center);
2128 }
2129
2130 public Chara AddChara(
string id,
int x,
int z)
2131 {
2133 }
2134
2136 {
2137 return AddChara(
id, p.
x, p.
z);
2138 }
2139
2140 public Card AddThing(
string id,
int x,
int z)
2141 {
2143 }
2144
2145 public Card AddThing(
string id,
Point p)
2146 {
2147 return AddThing(
id, p.
x, p.
z);
2148 }
2149
2151 {
2152 return AddCard(t, point.
x, point.
z);
2153 }
2154
2156 {
2157 return AddCard(t, 0, 0);
2158 }
2159
2160 public Card AddCard(
Card t,
int x,
int z)
2161 {
2163 {
2165 }
2166 t.parent = this;
2168 if (chara != null)
2169 {
2170 chara.currentZone = this;
2172 }
2173 if (IsActiveZone)
2174 {
2175 map.OnCardAddedToZone(t, x, z);
2177 {
2179 }
2180 ignoreSpawnAnime = false;
2181 }
2183 {
2185 chara.hasSpawned = true;
2186 }
2187 return t;
2188 }
2189
2190 public void RemoveCard(
Card t)
2191 {
2192 if (IsActiveZone)
2193 {
2194 map.OnCardRemovedFromZone(t);
2195 }
2196 t.parent = null;
2198 {
2199 t.Chara.currentZone = null;
2200 }
2202 {
2204 }
2206 {
2208 }
2209 }
2210
2211 public T GetRandomSpot<T>() where T :
Trait
2212 {
2214 }
2215
2216 public bool TryAddThingInSpot<T>(
Thing t,
bool useContainer =
true) where T :
Trait
2217 {
2219 if (randomThing == null)
2220 {
2222 {
2224 }
2225 else
2226 {
2228 }
2229 return false;
2230 }
2232 {
2233 List<Thing> list = new List<Thing>();
2235 {
2236 foreach (
Card item2
in item.ListCards())
2237 {
2239 {
2240 list.Add(item2.
Thing);
2241 }
2242 }
2243 }
2244 if (TryAddThingInSharedContainer(t, list, add: true, msg: false, null, sharedOnly: false))
2245 {
2246 return true;
2247 }
2248 }
2250 {
2252 }
2253 else
2254 {
2256 }
2257 return true;
2258 }
2259
2260 public List<Thing> TryListThingsInSpot<T>(Func<Thing, bool> func =
null) where T :
TraitSpot
2261 {
2262 List<T> list = new List<T>();
2263 List<Thing> list2 = new List<Thing>();
2265 {
2267 {
2268 list.Add(thing.
trait as T);
2269 }
2270 }
2271 foreach (T
item in list)
2272 {
2273 foreach (
Point item2
in item.ListPoints(
null, onlyPassable:
false))
2274 {
2276 {
2278 {
2279 continue;
2280 }
2281 if (thing2.
things.Count == 0)
2282 {
2283 if (IsValid(thing2))
2284 {
2285 list2.Add(thing2);
2286 }
2287 continue;
2288 }
2290 {
2291 list2.Add(item3);
2292 }
2293 }
2294 }
2295 }
2296 return list2;
2297 bool IsValid(
Thing t)
2298 {
2299 if (func != null && !func(t))
2300 {
2301 return false;
2302 }
2303 return true;
2304 }
2305 }
2306
2307 public bool TryAddThingInSharedContainer(
Thing t, List<Thing> containers =
null,
bool add =
true,
bool msg =
false,
Chara chara =
null,
bool sharedOnly =
true)
2308 {
2309 Thing thing = FindSharedContainer(t, containers, sharedOnly);
2310 if (thing == null)
2311 {
2312 return false;
2313 }
2314 if (add)
2315 {
2316 if (msg)
2317 {
2319 }
2321 }
2322 return true;
2323 }
2324
2325 public Thing FindSharedContainer(
Thing t, List<Thing> containers =
null,
bool sharedOnly =
true)
2326 {
2328 int priority = -1;
2331 {
2333 }
2334 if (containers == null)
2335 {
2337 }
2338 SearchDest();
2339 return dest;
2341 {
2342 foreach (
Thing container
in containers)
2343 {
2344 Thing thing = container;
2346 {
2348 }
2350 {
2352 if (windowSaveData != null)
2353 {
2355 {
2356 continue;
2357 }
2360 {
2363 {
2364 continue;
2365 }
2366 }
2368 {
2370 {
2371 bool flag2 = false;
2372 foreach (
int cat
in windowSaveData.
cats)
2373 {
2375 {
2376 flag2 = true;
2377 break;
2378 }
2379 }
2380 if (!flag2)
2381 {
2382 continue;
2383 }
2384 }
2385 else if (windowSaveData.
flag.HasFlag(flag))
2386 {
2387 continue;
2388 }
2389 }
2390 priority = windowSaveData.
priority;
2391 }
2392 else
2393 {
2394 if (priority != -1)
2395 {
2396 continue;
2397 }
2398 priority = 0;
2399 }
2400 dest = thing;
2401 }
2402 }
2403 return null;
2404 }
2405 }
2406
2407 public bool TryAddThing(
Thing target,
Point p,
bool destroyIfFail =
false)
2408 {
2409 int num = 0;
2411 {
2413 {
2415 {
2417 {
2418 return true;
2419 }
2420 num++;
2421 }
2422 }
2423 }
2424 if (num == 0 || !destroyIfFail)
2425 {
2427 return true;
2428 }
2430 return false;
2431 }
2432
2433 public Thing TryGetThingFromSharedContainer(Func<Thing, bool> func)
2434 {
2436 {
2438 {
2440 if (thing != null)
2441 {
2442 return thing;
2443 }
2444 }
2445 }
2446 return null;
2447 }
2448
2450 {
2451 List<T> list = new List<T>();
2453 {
2455 {
2456 list.Add(thing2.
trait as T);
2457 }
2458 }
2459 foreach (T
item in list)
2460 {
2461 foreach (
Point item2
in item.ListPoints(
null, onlyPassable:
false))
2462 {
2464 {
2466 {
2467 continue;
2468 }
2469 if (thing3.
things.Count == 0)
2470 {
2471 if (IsValid(thing3, insideContainer: false))
2472 {
2473 return thing3;
2474 }
2475 continue;
2476 }
2478 if (thing != null)
2479 {
2480 return thing;
2481 }
2482 }
2483 }
2484 }
2485 return null;
2486 bool IsValid(
Thing t,
bool insideContainer)
2487 {
2489 {
2490 return false;
2491 }
2492 return true;
2493 }
2494 }
2495
2497 {
2498 string text = IdProfile;
2499 if (text.IsEmpty())
2500 {
2502 if (base.lv != 0)
2503 {
2504 text = ((base.lv < 0) ? "Underground" : "Sky");
2505 }
2506 else if (region != null)
2507 {
2510 if (bp != null)
2511 {
2512 name =
Lang.
GetList(
"zone_" + text.Split(
'/')[1]).RandomItem();
2514 for (int i = 0; i < 3; i++)
2515 {
2516 for (int j = 0; j < 3; j++)
2517 {
2519 }
2520 }
2521 if (text == "Random/R_Shore")
2522 {
2523 base.isBeach = true;
2524 }
2525 }
2526 }
2527 else
2528 {
2529 text = "Random";
2530 }
2531 idProfile = text;
2532 }
2534 }
2535
2536 public void CreateBP()
2537 {
2539 bp.Create();
2540 bp.genSetting.seed = base.Seed;
2541 OnCreateBP();
2542 }
2543
2544 public virtual void OnCreateBP()
2545 {
2546 }
2547
2548 public void Generate()
2549 {
2550 base.isGenerated = true;
2551 if (bp == null)
2552 {
2553 CreateBP();
2554 }
2555 if (bp.map == null)
2556 {
2557 bp.GenerateMap(this);
2558 }
2559 map.SetZone(this);
2561 bool flag = IdBiome == "Sand" || IdBiome == "Water" || IsUnderwater;
2562 if (flag)
2563 {
2564 int num = 1 +
EClass.
rnd((IdBiome ==
"Water") ? 3 : 2);
2565 for (int i = 0; i < num; i++)
2566 {
2569 {
2570 Thing t =
ThingGen.
Create(
"pearl_oyster",
new string[3] {
"wood_birch",
"poplar",
"coralwood" }.RandomItem(), ContentLv);
2572 }
2573 }
2575 for (int j = 0; j < num; j++)
2576 {
2579 {
2581 }
2582 }
2584 {
2586 if (!randomSurface3.
HasObj)
2587 {
2589 }
2590 }
2591 }
2592 if (IsUnderwater)
2593 {
2594 for (
int l = 0; l < 30 +
EClass.
rnd(30); l++)
2595 {
2597 }
2602 if (IsNefia)
2603 {
2605 if (num3 > 0)
2606 {
2612 }
2613 }
2615 {
2616 int num7 = 137;
2617 foreach (
Point point
in r.points)
2618 {
2620 {
2621 map.
SetObj(point.
x, point.
z, num7);
2625 {
2627 }
2628 }
2629 }
2630 return false;
2631 });
2633 {
2634 int num7 = 136;
2635 foreach (
Point point2
in r.points)
2636 {
2638 {
2640 }
2641 }
2642 return false;
2643 });
2645 {
2646 int idFloor = 121;
2647 foreach (
Point point3
in r.points)
2648 {
2650 }
2651 return false;
2652 });
2653 }
2654 if (zone_Field != null)
2655 {
2657 {
2659 for (int num5 = 0; num5 < num4; num5++)
2660 {
2663 {
2666 }
2667 }
2668 }
2670 {
2671 SpawnAltar();
2672 }
2673 TrySpawnFollower();
2675 {
2678 {
2680 }
2681 }
2682 if (base.Tile.isRoad)
2683 {
2684 for (
int num6 = 0; num6 <
EClass.
rnd(4); num6++)
2685 {
2687 }
2688 }
2689 }
2690 map.plDay = CreatePlaylist(ref map._plDay,
EClass.
Sound.GetPlaylist(IDPlayList) ??
EClass.
Sound.GetPlaylist(
"Day"));
2691 }
2692
2693 public void TrySpawnFollower()
2694 {
2697 {
2698 return;
2699 }
2702 {
2703 return;
2704 }
2710 {
2712 if (row != null)
2713 {
2715 }
2716 }
2718 for (
int num = 0; num < 3 +
EClass.
rnd(4); num++)
2719 {
2724 }
2725 }
2726
2727 public void SpawnAltar()
2728 {
2730 {
2731 if (r.points.Count <= 4)
2732 {
2733 return false;
2734 }
2735 map.poiMap.OccyupyPOI(r.points[0]);
2736 List<Point> points = r.points;
2738 "altarPoint".lang(randomReligion.NameDomain.lang());
2743 for (
int i = 0; i < 2 +
EClass.
rnd(2); i++)
2744 {
2747 }
2749 {
2751 }
2753 {
2754 if (
item.x % 3 == 0 &&
item.z % 2 == 0 &&
item != points[0] && !
item.Equals(points[0].Front) &&
item.Installed ==
null)
2755 {
2756 thing = ThingGen.Create("pillar1");
2757 EClass._zone.AddCard(thing, item).Install();
2758 }
2760 item.SetFloor(3, 6);
2761 }
2762 return true;
2763 });
2764 }
2765
2766 public virtual void OnGenerateMap()
2767 {
2768 if (MakeEnemiesNeutral)
2769 {
2771 {
2773 {
2775 chara.hostility = hostility;
2776 }
2777 }
2778 }
2779 if (PrespawnRate != 0f && !IsSkyLevel)
2780 {
2781 for (int i = 0; i < (int)((float)MaxSpawn * PrespawnRate); i++)
2782 {
2783 SpawnMob();
2784 }
2785 }
2786 TryGenerateOre();
2787 TryGenerateBigDaddy();
2788 TryGenerateEvolved();
2789 TryGenerateShrine();
2790 }
2791
2792 public void TryGenerateOre()
2793 {
2794 if (OreChance <= 0f)
2795 {
2796 return;
2797 }
2799 {
2800 int num = 18;
2801 string text = "ore";
2802 if (EClass.rnd(5) == 0)
2803 {
2804 num++;
2805 text = "gem";
2806 }
2808 foreach (
Point point in r.points)
2809 {
2810 if (point.sourceBlock.ContainsTag("ore"))
2811 {
2812 map.SetObj(point.x, point.z, randomMaterial.id, num, 1, 0);
2813 }
2814 }
2815 return false;
2816 });
2817 }
2818
2819 public Chara TryGenerateEvolved(
bool force =
false,
Point p =
null)
2820 {
2823 {
2824 return null;
2825 }
2827 for (
int i = 0; i < 2 +
EClass.
rnd(2); i++)
2828 {
2830 }
2833 {
2835 }
2836 return chara;
2837 }
2838
2839 public void TryGenerateBigDaddy()
2840 {
2842 {
2844 List<string> list = new List<string> { "big_daddy", "big_daddy2" };
2845 list.Shuffle();
2846 Spawn(list[0], spawnPos);
2848 {
2849 Spawn(list[1], spawnPos.
GetNearestPoint(allowBlock:
false, allowChara:
false));
2850 }
2851 Msg.
Say(
"sign_bigdaddy");
2852 }
2853 void Spawn(
string id,
Point pos)
2854 {
2855 int num = (int)((long)DangerLv * 125L / 100);
2856 if (num >= 30)
2857 {
2859 {
2860 lv = num
2861 });
2862 }
2865 {
2867 }
2869 {
2871 }
2873 }
2874 }
2875
2876 public void TryGenerateShrine()
2877 {
2879 for (int i = 0; i < 3; i++)
2880 {
2883 {
2884 continue;
2885 }
2887 if (randomSpace == null)
2888 {
2889 continue;
2890 }
2894 {
2895 continue;
2896 }
2901 {
2904 }
2905 else
2906 {
2908 }
2909 }
2911 }
2912
2913 public void ResetHostility()
2914 {
2916 {
2918 {
2919 chara.c_originalHostility = (
Hostility)0;
2920 }
2923 {
2925 }
2926 }
2927 }
2928
2929 public virtual void OnGenerateRooms(
BaseMapGen gen)
2930 {
2931 }
2932
2934 {
2936 for (int i = 0; i < tries; i++)
2937 {
2940 {
2941 continue;
2942 }
2943 switch (type)
2944 {
2946 {
2948 if (list.Count > 0)
2949 {
2950 list.Shuffle();
2952 {
2953 List<Point> list2 =
item.ListPoints(
null, onlyPassable:
true, allowChara:
false);
2954 if (list2.Count > 0)
2955 {
2956 return list2.RandomItem();
2957 }
2958 }
2959 }
2962 {
2963 continue;
2964 }
2965 break;
2966 }
2969 {
2970 continue;
2971 }
2972 break;
2973 }
2974 return point;
2975 }
2976 return null;
2977 }
2978
2979 public Chara SpawnMob(
string id,
Point pos =
null)
2980 {
2982 {
2983 id = id
2984 });
2985 }
2986
2988 {
2989 if (setting == null)
2990 {
2992 }
2993 if (pos == null)
2994 {
2995 pos = GetSpawnPos(setting.position, setting.tries);
2996 if (pos == null)
2997 {
2999 if (pos == null)
3000 {
3001 return null;
3002 }
3003 }
3004 }
3006 if (IsUnderwater &&
EClass.
rnd(15) != 0)
3007 {
3009 }
3011 if (setting.idSpawnList != null)
3012 {
3014 }
3016 {
3018 }
3020 {
3021 spawnList =
SpawnListChara.
Get(
"dungeon_dragon", (
SourceChara.
Row r) => (r.race ==
"dragon" || r.race ==
"drake" || r.race ==
"wyvern" || r.race ==
"lizardman" || r.race ==
"dinosaur") && r.quality == 0);
3022 }
3024 {
3026 }
3028 {
3029 spawnList =
SpawnList.
Get(IsInstance ?
"c_neutral_war" :
"c_neutral");
3030 }
3032 {
3035 {
3036 ShouldPass = (
SourceChara.Row s) => (!(s.hostility !=
"") || (!s.tag.Contains(
"cat") && !s.race_row.tag.Contains(
"cat"))) ? true :
false
3037 }));
3038 }
3039 else
3040 {
3042 {
3044 {
3045 if (s.hostility != "")
3046 {
3047 return false;
3048 }
3049 return s.biome == biome.name || s.biome.IsEmpty();
3050 }
3051 });
3052 }
3053 int num = ((setting.dangerLv == -1) ? DangerLv : setting.dangerLv);
3055 {
3057 idEle = setting.idEle
3058 };
3059 int num2 = ((setting.filterLv == -1) ? num : setting.filterLv);
3061 {
3062 num2 = ((num - 1) % 50 + 5) * 150 / 100;
3063 if (num2 >= 20 &&
EClass.
rnd(100) < num2)
3064 {
3065 num2 = num;
3066 }
3067 }
3070 {
3073 }
3074 if (cardRow == null)
3075 {
3076 Debug.LogError(
"SpawnMob: no spawn row list/" + spawnList?.
id +
"/biome/" + biome.name +
"/zone/" + Name);
3077 return null;
3078 }
3079 long num3 = ((setting.fixedLv == -1) ? cardRow.
LV : setting.fixedLv);
3080 bool flag = setting.fixedLv != -1 || setting.addLv > 0 || DangerLvBoost > 0;
3081 num3 += setting.addLv;
3083 {
3084 num3 = (50L + (long)cardRow.
LV) * Mathf.Max(1, (num - 1) / 50);
3085 flag = true;
3086 }
3087 num3 += DangerLvBoost;
3088 if (flag && num3 <= Mathf.Max(50, cardRow.
LV))
3089 {
3090 flag = false;
3091 }
3092 if (setting.rarity ==
Rarity.Random && cardRow.
quality == 0)
3093 {
3095 {
3096 cardBlueprint.rarity =
Rarity.Legendary;
3097 num3 = num3 * 125 / 100;
3098 }
3099 }
3100 else
3101 {
3102 cardBlueprint.rarity = setting.rarity;
3103 }
3104 if (setting.isBoss)
3105 {
3106 num3 = num3 * 150 / 100;
3107 }
3108 if (setting.isEvolved)
3109 {
3110 num3 = num3 * 2 + 20;
3111 }
3112 if (num3 != cardRow.
LV)
3113 {
3114 cardBlueprint.lv = (int)Mathf.Min(num3, 100000000f);
3115 }
3118 if (!flag)
3119 {
3120 chara.isScaled = false;
3121 }
3122 AddCard(chara, pos);
3123 if (setting.forcedHostility.HasValue)
3124 {
3125 Hostility c_originalHostility = (chara.hostility = setting.forcedHostility.Value);
3126 chara.c_originalHostility = c_originalHostility;
3127 }
3128 else
3129 {
3131 {
3132 case "unicorn":
3134 {
3136 }
3137 break;
3138 case "santa":
3139 case "silverwolf":
3140 case "twintail":
3141 case "test17":
3143 {
3145 }
3147 {
3149 }
3150 break;
3151 }
3152 }
3153 if (setting.isBoss)
3154 {
3156 }
3157 if (setting.isEvolved)
3158 {
3159 chara.c_bossType =
BossType.Evolved;
3160 }
3161 if (DangerLv >= 20 && !IsPCFaction && !IsTown &&
EClass.
rnd(200) == 0)
3162 {
3164 }
3165 return chara;
3166 }
3167
3168 public bool HasField(int idEle)
3169 {
3170 return fieldElements.Has(idEle);
3171 }
3172
3173 public void SetFieldEffect(int idEle, int a, int duration = 0)
3174 {
3175 fieldElements.SetBase(idEle, a, duration);
3176 }
3177
3178 public void RemoveFieldEffect(int idEle)
3179 {
3180 fieldElements.Remove(idEle);
3181 }
3182
3183 public void RefreshElectricity()
3184 {
3185 dirtyElectricity = false;
3186 bool flag = GetSoilCost() > MaxSoil;
3187 base.electricity = elements.Value(2201) * 10 + BaseElectricity;
3189 {
3191 {
3193 }
3194 }
3195 if (!flag)
3196 {
3198 {
3200 {
3201 base.electricity += 20;
3202 }
3203 });
3204 }
3206 {
3208 {
3210 }
3211 }
3212 }
3213
3214 public int GetElectricity(bool cost = false)
3215 {
3216 bool flag = GetSoilCost() > MaxSoil;
3217 int sum = 0;
3219 {
3221 {
3222 continue;
3223 }
3224 if (cost)
3225 {
3227 {
3229 }
3230 }
3232 {
3234 }
3235 }
3236 if (!cost)
3237 {
3238 sum += elements.Value(2201) * 10 + BaseElectricity;
3239 if (!flag)
3240 {
3242 {
3244 {
3245 sum += 20;
3246 }
3247 });
3248 }
3249 }
3250 return sum;
3251 }
3252
3253 public void SetBGM(List<int> ids, bool refresh = true, float fadeDuration = 0f)
3254 {
3255 map._plDay.Clear();
3256 if (ids.Count > 0)
3257 {
3258 foreach (int id in ids)
3259 {
3260 if (id != -1)
3261 {
3262 map._plDay.Add(id);
3263 }
3264 }
3265 }
3266 UnityEngine.Object.DestroyImmediate(map.plDay);
3267 map.plDay = null;
3268 RefreshPlaylist();
3269 if (!refresh)
3270 {
3271 return;
3272 }
3273 if (fadeDuration > 0f)
3274 {
3275 EClass.
Sound.StopBGM(fadeDuration, playLastBGM:
false, delegate
3276 {
3278 {
3279 RefreshBGM();
3280 }
3281 });
3282 }
3283 else
3284 {
3286 RefreshBGM();
3287 }
3288 }
3289
3290 public void SetBGM(int id = -1, bool refresh = true, float fadeDuration = 0f)
3291 {
3292 SetBGM(new List<int> { id }, refresh, fadeDuration);
3293 }
3294
3295 public void RefreshPlaylist()
3296 {
3297 if (map.plDay == null)
3298 {
3299 map.plDay = CreatePlaylist(ref map._plDay,
EClass.
Sound.GetPlaylist(IDPlayList));
3300 }
3301 }
3302
3303 public void ResetPlaylist()
3304 {
3305 map._plDay.Clear();
3306 UnityEngine.Object.DestroyImmediate(map.plDay);
3307 map.plDay = null;
3308 RefreshPlaylist();
3309 }
3310
3311 public void RefreshBGM()
3312 {
3314 {
3315 return;
3316 }
3317 RefreshPlaylist();
3318 Playlist playlist = map.plDay;
3320 {
3321 if (
item.playlist !=
null)
3322 {
3323 playlist =
item.playlist;
3324 }
3325 }
3326 if (IDPlaylistOverwrite != null)
3327 {
3328 playlist =
EClass.
Sound.GetPlaylist(IDPlaylistOverwrite);
3329 }
3331 {
3333 if (room !=
null && room.
lot !=
null && room.
lot.
idBGM != 0)
3334 {
3336 if (playlist.list[0].data?.id != room.
lot.
idBGM)
3337 {
3339 playlist.Reset();
3341 {
3343 }
3344 }
3345 }
3346 }
3349 }
3350
3351 public Playlist CreatePlaylist(ref List<int> list, Playlist mold = null)
3352 {
3353 return ModUtil.CreatePlaylist(ref list, mold);
3354 }
3355
3356 public Chara FindChara(
string id)
3357 {
3358 return map.charas.Find((
Chara c) => c.
id ==
id);
3359 }
3360
3361 public Chara FindChara(
int uid)
3362 {
3363 return map.charas.Find((
Chara c) => c.
uid == uid);
3364 }
3365
3366 public Chara FindDeadChara(
string id)
3367 {
3368 return map.deadCharas.Find((
Chara c) => c.
id ==
id);
3369 }
3370
3371 public int GetDeepestLv()
3372 {
3373 int max = base.lv;
3374 return GetDeepestLv(ref max);
3375 }
3376
3377 public int GetDeepestLv(ref int max)
3378 {
3379 if (Mathf.Abs(base.lv) > Mathf.Abs(max))
3380 {
3381 max = base.lv;
3382 }
3383 foreach (
Spatial child
in children)
3384 {
3385 (child as
Zone).GetDeepestLv(ref max);
3386 }
3387 return max;
3388 }
3389
3390 public int GetCostSkyTravel()
3391 {
3392 if (base.source.costSkyTravel > 0)
3393 {
3394 return base.source.costSkyTravel;
3395 }
3397 {
3398 return Mathf.Clamp(10 +
EClass.
curve(DangerLv, 50, 10), 1, 200);
3399 }
3400 return 0;
3401 }
3402
3403 public List<Element> ListLandFeats()
3404 {
3405 if (landFeats == null)
3406 {
3407 landFeats = new List<int>();
3409 string[] listBase = IDBaseLandFeat.Split(',');
3410 string[] array = listBase;
3411 foreach (string text in array)
3412 {
3413 if (!text.IsEmpty())
3414 {
3416 }
3417 }
3418 if (listBase.Length == 1)
3419 {
3421 {
3422 if (e.category != "landfeat" || e.chance == 0)
3423 {
3424 return false;
3425 }
3426 bool flag = true;
3427 string[] tag = e.tag;
3428 foreach (string text2 in tag)
3429 {
3430 if (text2.StartsWith("bf"))
3431 {
3432 flag = false;
3433 if (listBase[0] == text2)
3434 {
3435 flag = true;
3436 break;
3437 }
3438 }
3439 }
3440 return flag ? true : false;
3441 }).ToList();
3443 landFeats.Add(row.
id);
3444 list.Remove(row);
3446 landFeats.Add(row.
id);
3447 }
3449 }
3450 List<Element> list2 = new List<Element>();
3451 foreach (int landFeat in landFeats)
3452 {
3454 }
3455 return list2;
3456 }
3457
3459 {
3460 ZipFile zipFile = ZipFile.Read(path);
3461 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3462 zipFile.ExtractAll(pathTemp);
3463 zipFile.Dispose();
3465 }
3466
3467 public void Export(
string path,
PartialMap partial =
null,
bool usermap =
false)
3468 {
3469 if (subset != null)
3470 {
3471 SE.Beep();
3472 return;
3473 }
3474 try
3475 {
3477 {
3478 name = name,
3479 usermap = usermap
3480 };
3482 if (!map.config.retainDecal)
3483 {
3484 map.ClearRainAndDecal();
3485 }
3486 map.Save(
IO.
TempPath +
"/", zoneExportData, partial);
3487 map.ExportMetaData(
IO.
TempPath +
"/", Path.GetFileNameWithoutExtension(path), partial);
3488 if (partial == null)
3489 {
3491 }
3493 using (ZipFile zipFile = new ZipFile())
3494 {
3495 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3497 zipFile.Save(path);
3498 zipFile.Dispose();
3499 }
3501 }
3502 catch (Exception ex)
3503 {
3504 EClass.
ui.Say(ex.Message +
":" + path);
3505 }
3506 }
3507
3508 public void ExportDialog(string dir = null)
3509 {
3511 {
3513 if (!
string.IsNullOrEmpty(text))
3514 {
3515 Export(text);
3517 }
3518 });
3519 }
3520
3521 public void ImportDialog(string dir = null)
3522 {
3524 {
3526 if (array.Length != 0)
3527 {
3528 Zone_User zone_User = SpatialGen.Create("user", EClass.world.region, register: true) as Zone_User;
3529 zone_User.path = array[0];
3530 Thing thing = ThingGen.Create("teleporter");
3531 thing.c_uidZone = zone_User.uid;
3532 EClass._zone.AddCard(thing, EClass.pc.pos);
3533 }
3534 });
3535 }
3536
3537 public static bool IsImportValid(string path)
3538 {
3539 try
3540 {
3542 }
3543 catch (Exception ex)
3544 {
3546 return false;
3547 }
3548 }
3549
3550 public void Export()
3551 {
3553 string text = pathExport;
3555 Export(text);
3556 Msg.
Say(
"Exported Map:" + text);
3557 }
3558
3560 {
3561 }
3562
3563 public void OnInspect()
3564 {
3565 }
3566
3567 public int GetSortVal()
3568 {
3569 if (IsPCFaction)
3570 {
3571 return -10000000 + base.uid;
3572 }
3574 {
3575 return -8000000 + base.uid;
3576 }
3578 {
3579 return -9000000 + base.uid;
3580 }
3582 {
3583 return -7000000 + base.uid;
3584 }
3586 {
3587 return 1000000 + base.uid;
3588 }
3589 return base.uid;
3590 }
3591
3592 public Chara AddRandomVisitor(
bool guest =
false)
3593 {
3595 if (random == null)
3596 {
3597 return null;
3598 }
3602 {
3605 if (chara != null)
3606 {
3607 AddCard(chara, point);
3608 Msg.
Say(
"guestArrive", chara);
3610 }
3611 }
3612 else
3613 {
3615 AddCard(chara, point);
3617 }
3618 return chara;
3619 }
3620
3622 {
3623 if (base.IsPlayerFaction)
3624 {
3626 }
3627 events.OnSimulateHour();
3629 {
3631 {
3633 {
3635 }
3636 }
3638 }
3640 {
3642 });
3643 foreach (
Thing sucker
in Suckers)
3644 {
3646 }
3647 Suckers.Clear();
3648 if (RespawnRate != 0f)
3649 {
3650 int num = 0;
3651 foreach (
Chara chara
in map.charas)
3652 {
3654 {
3655 num++;
3656 }
3657 }
3658 if (num < MaxRespawn)
3659 {
3660 for (int num2 = 0; num2 < RespawnPerHour; num2++)
3661 {
3662 SpawnMob();
3663 }
3664 }
3665 }
3667 {
3668 RainWater();
3669 }
3671 {
3672 GrowPlants(date);
3673 }
3674 }
3675
3677 {
3678 if (base.IsPlayerFaction)
3679 {
3680 branch.OnSimulateDay(date);
3681 }
3682 }
3683
3685 {
3686 if (base.IsPlayerFaction)
3687 {
3688 branch.OnSimulateMonth(date);
3689 }
3691 {
3693 }
3694 }
3695
3696 public void RainWater()
3697 {
3699 {
3700 return;
3701 }
3703 {
3705 {
3706 c.isWatered = true;
3707 }
3708 });
3709 }
3710
3712 {
3714 int weedChance = 1;
3716 {
3718 }
3720 {
3722 }
3723 if (num)
3724 {
3725 HashSet<int> hashSet = new HashSet<int>();
3727 {
3729 {
3730 continue;
3731 }
3732 foreach (
Point item in traitSpotFarm.ListPoints(
null, onlyPassable:
false))
3733 {
3734 hashSet.Add(
item.index);
3735 }
3736 }
3737 Perform(hashSet);
3738 EClass.player.isAutoFarming = false;
3739 Perform(hashSet);
3740 }
3741 else
3742 {
3743 Perform(null);
3744 }
3745 void Perform(HashSet<int> farmMap)
3746 {
3749 {
3750 if (farmMap != null)
3751 {
3753 {
3754 if (!farmMap.Contains(c.index))
3755 {
3756 return;
3757 }
3758 }
3759 else if (farmMap.Contains(c.
index))
3760 {
3761 return;
3762 }
3763 }
3765 {
3766 c.decal = 0;
3767 }
3769 {
3771 {
3772 bool flag = false;
3773 if (!EClass.player.isAutoFarming && c.growth.HaltGrowth() && (c.IsFarmField || c.IsTopWater) && (!isWinter || !date.IsRealTime))
3774 {
3775 flag = true;
3776 }
3777 PlantData plantData = map.TryGetPlant(c);
3778 if (!flag && (plantData ==
null || plantData.fert >= 0))
3779 {
3780 c.TryGrow(date);
3781 }
3783 {
3784 if (date.sunMap == null)
3785 {
3786 date.BuildSunMap();
3787 }
3789 {
3790 c.growth.Perish();
3791 }
3792 }
3793 }
3794 else if (c.
detail !=
null)
3795 {
3796 c.Things.ForeachReverse(delegate(Thing t)
3797 {
3798 if (t.IsInstalled && t.trait is TraitSeed && !t.isSale)
3799 {
3800 (t.trait as TraitSeed).TrySprout(force: false, sucker: false, date);
3801 }
3802 });
3803 }
3805 {
3808 {
3810 }
3811 }
3812 }
3813 c.isWatered = false;
3814 });
3815 }
3816 }
3817
3818 public Zone GetZoneAt(
int _x,
int _y)
3819 {
3820 if (IsRegion)
3821 {
3822 foreach (
Spatial child
in children)
3823 {
3824 if (!(child is
Zone_Field) && _x == child.
x && _y == child.
y)
3825 {
3826 return child as
Zone;
3827 }
3828 }
3829 }
3830 foreach (
Spatial child2
in children)
3831 {
3832 if (_x == child2.
x && _y == child2.
y)
3833 {
3834 return child2 as
Zone;
3835 }
3836 }
3837 return null;
3838 }
3839
3840 public bool IsCrime(
Chara c,
Act act)
3841 {
3843 {
3844 return true;
3845 }
3846 return false;
3847 }
3848
3849 public void RefreshCriminal()
3850 {
3851 bool flag = EClass.player.IsCriminal && HasLaw && !AllowCriminal && !IsPCFaction;
3854 {
3856 {
3857 chara.hostility = hostility;
3859 {
3861 }
3862 }
3863 }
3864 }
3865
3866 public void RefreshListCitizen()
3867 {
3868 if (base.lv != 0)
3869 {
3870 return;
3871 }
3872 dictCitizen.Clear();
3873 foreach (
Chara item in map.charas.Concat(map.deadCharas))
3874 {
3875 if (
item.trait.IsCitizen && !
item.IsGlobal && !
item.isSubsetCard)
3876 {
3878 }
3879 }
3880 }
3881
3882 public virtual void SetAlarm(bool enable)
3883 {
3884 base.isAlarmSet = enable;
3885 if (enable)
3886 {
3888 {
3890 {
3892 }
3893 }
3896 SE.Play("alarm");
3897 return;
3898 }
3900 {
3902 {
3904 }
3905 }
3906 }
3907
3908 public void ModInfluence(int a)
3909 {
3910 base.influence += a;
3911 if (a > 0)
3912 {
3913 Msg.
Say(
"gainInfluence", Name, a.ToString() ??
"");
3914 }
3916 }
3917
3918 public void ModDevelopment(int a)
3919 {
3920 base.development += a;
3921 if (a > 0)
3922 {
3923 Msg.
Say(
"gainDevelopment", Name, a.ToString() ??
"");
3924 }
3925 }
3926
3927 public void UpdateQuests(bool force = false)
3928 {
3929 if (!IsPCFaction && (!(
this is
Zone_Town) || base.lv != 0))
3930 {
3931 return;
3932 }
3933 Debug.Log(
"Updating Quest:" + force);
3935 int num = 0;
3936 foreach (
Chara item in map.charas.Concat(map.deadCharas))
3937 {
3939 {
3940 if (
item.quest.IsExpired || completedQuests.Contains(
item.quest.uid) || force)
3941 {
3942 item.quest = null;
3943 }
3944 else
3945 {
3946 num++;
3947 }
3948 }
3949 }
3951 {
3952 return;
3953 }
3955 int maxQuest = 3;
3957 {
3958 maxQuest = 4 + EClass.rnd(4);
3959 });
3960 completedQuests.Clear();
3962 List<Tuple<string, int>> listTag = new List<Tuple<string, int>>();
3965 {
3966 array = new string[9] { "supply/8", "deliver/7", "food/8", "escort/4", "deliver/4", "monster/0", "war/0", "farm/0", "music/0" };
3967 }
3968 string[] array2 = array;
3969 for (int num2 = 0; num2 < array2.Length; num2++)
3970 {
3971 string[] array3 = array2[num2].Split('/');
3972 listTag.Add(new Tuple<string, int>(array3[0], array3[1].ToInt()));
3973 }
3974 for (int num3 = 0; num3 < map.charas.Count * 2; num3++)
3975 {
3976 if (num > maxQuest)
3977 {
3978 break;
3979 }
3980 if (num > 15)
3981 {
3982 break;
3983 }
3984 Chara chara = map.charas.RandomItem();
3986 {
3987 continue;
3988 }
3990 {
3991 int num4 = 1;
3992 foreach (Tuple<string, int> item2 in listTag)
3993 {
3994 if (a.tags.Contains(item2.Item1))
3995 {
3996 num4 = item2.Item2;
3997 break;
3998 }
3999 }
4001 {
4002 num4 = 0;
4003 }
4004 return a.chance * num4;
4005 });
4007 {
4009 num++;
4010 }
4011 }
4012 }
4013
4014 public List<Chara> ListMinions(
Chara c)
4015 {
4016 List<Chara> list = new List<Chara>();
4018 {
4020 {
4021 list.Add(chara);
4022 }
4023 }
4024 return list;
4025 }
4026
4027 public int CountMinions(
Chara c)
4028 {
4029 int num = 0;
4031 {
4033 {
4034 num++;
4035 }
4036 }
4037 return num;
4038 }
4039
4040 public int GetSoilCost()
4041 {
4042 int n = 0;
4044 {
4046 });
4047 return n / 10;
4048 }
4049
4050 public void SpawnLostItems()
4051 {
4052 for (
int i = 0; i < 2 +
EClass.
rnd(4); i++)
4053 {
4054 Point point = GetPos();
4055 if (point == null)
4056 {
4057 continue;
4058 }
4060 {
4062 thing.isLostProperty = true;
4064 int num = (thing.c_lockLv =
EClass.
rndHalf(Mathf.Min(base.development / 10 + 10, 50)));
4067 {
4069 }
4070 else
4071 {
4073 }
4075 }
4076 else
4077 {
4079 }
4080 }
4081 static Point GetPos()
4082 {
4083 for (int j = 0; j < 10; j++)
4084 {
4087 {
4088 return randomPoint;
4089 }
4090 }
4091 return null;
4092 }
4093 }
4094
4095 public void ApplyBackerPet(bool draw)
4096 {
4097 bool flag =
this is
Zone_Yowyn && base.lv == -1;
4099 list.Shuffle();
4101 {
4103 {
4104 if (EClass.player.doneBackers.Contains(a.id))
4105 {
4106 list.Remove(a);
4107 }
4108 });
4109 }
4111 {
4113 {
4114 continue;
4115 }
4117 {
4119 {
4120 continue;
4121 }
4122 if (chara.
id !=
"follower")
4123 {
4125 }
4126 }
4128 {
4129 continue;
4130 }
4132 {
4133 if (
item.chara == chara.
id)
4134 {
4137 break;
4138 }
4139 }
4140 }
4141 }
4142
4143 public FortuneRollData GetOrCreateFortuneRollData(
bool refresh =
true)
4144 {
4145 if (fortuneRoll == null)
4146 {
4149 }
4150 if (refresh || fortuneRoll.count == 0)
4151 {
4152 fortuneRoll.Refresh();
4153 }
4154 return fortuneRoll;
4155 }
4156}
virtual void OnSimulatePosition()
void SimulateZone(int days)
virtual bool IsHostileAct
BaseArea.AccessType accessType
void WaitForEndOfFrame(Action action)
List< SpawnListChara > chara
string GetRandomCharaId()
void Populate(Point point, bool interior=false, float mtpDensity=1f)
static void Set(CardBlueprint _bp=null)
GlobalCharaList globalCharas
List< Chara > ListGlobalChara(Zone z)
override void OnLeaveScreen()
virtual void OnSimulateHour(VirtualDate date)
void SetPlaceState(PlaceState newState, bool byPlayer=false)
SourceBacker.Row sourceBacker
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Thing AddThing(string id, int lv=-1)
void DecayNatural(int hour=1)
virtual void HealHP(long a, HealSource origin=HealSource.None)
Window.SaveData GetWindowSaveData()
bool TryStackTo(Thing to)
void ApplyBacker(int bid)
Thing Add(string id, int num=1, int lv=1)
SourceCategory.Row category
bool HasElement(int ele, bool includeNagative=false)
void Say(string lang, string ref1=null, string ref2=null)
static Chara CreateFromFilter(string id, int lv=-1, int levelRange=-1)
static Chara Create(string id, int lv=-1)
BaseCondition GetCondition(string idCon)
Hostility OriginalHostility
Condition AddCondition(string id, int p=100, bool force=false)
bool HasCondition(string alias)
override bool IsPCFaction
void TryRestock(bool onCreate)
void Revive(Point p=null, bool msg=false)
Thing MakeGene(DNA.Type? type=null)
override void SetDir(int d)
Chara SetEnemy(Chara c=null)
void Cure(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Chara SetHostility(Hostility h)
void MoveZone(string alias)
bool ignoreBackerDestoryFlag
Dictionary< int, BGMData > dictBGM
static Crawler Create(string id)
bool CrawlUntil(Map map, Func< Point > onStart, int tries, Func< Result, bool > canComplete, Action onFail=null)
int GetRaw(int offsetHours=0)
static int curve(long _a, int start, int step, int rate=75)
static SourceManager sources
static float rndf(float a)
static FactionBranch Branch
static int rndHalf(int a)
static SoundManager Sound
static GameSetting setting
static Effect Get(Effect original)
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
static Element Create(int id, int v=0)
void Initialize(EloMap _elomap)
void SetZone(int gx, int gy, Zone z, bool updateMesh=false)
TileInfo GetTileInfo(int gx, int gy)
string Log(string idLang, string ref1=null, string ref2=null, string ref3=null, string ref4=null)
List< GodStatueData > godStatues
ReligionManager religions
ZoneTransition transition
void SetStage(int idx, bool renewHarvest=false)
virtual bool NeedSunlight
bool CanGrow(VirtualDate date)
static void CreateTempDirectory(string path=null)
static void DeleteDirectory(string path)
static void Copy(string fromPath, string toPath)
static void SaveFile(string path, object obj, bool compress=false, JsonSerializerSettings setting=null)
static void DeleteTempDirectory(string path=null)
static void CopyDir(string sourceDirectory, string targetDirectory, Func< string, bool > funcExclude=null)
static string[] GetList(string id)
static SourceMaterial.Row GetRandomMaterial(int lv, string group=null, bool tryLevelMatTier=false)
void ForeachCell(Action< Cell > action)
Point GetRandomSurface(int x, int z, int radius, bool walkable=true, bool allowWater=false)
Point GetRandomSpace(int width, int height, int tries=100)
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
PlantData AddPlant(Point pos, Thing seed)
static MapMetaData GetMetaData(string pathZip)
void RevealAll(bool reveal=true)
static string SayRaw(string text)
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
static PathManager Instance
bool IsPathClear(Point origin, Point dest, IPathfindWalker walker, int radius)
List< Chara > listCarryoverMap
HashSet< int > doneBackers
void SetObj(int id=0, int value=1, int dir=0)
Point Set(int _x, int _z)
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
void SetFloor(int idMat=0, int idFloor=0)
bool Equals(int _x, int _z)
bool ForeachNearestPoint(Func< Point, bool > endFunc, bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int maxRange=30)
Point Clamp(bool useBounds=false)
Thing FindThing(Func< Thing, bool > func)
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
bool IsActive(int id, int days=-1)
static List< Zone > ListDeliver()
static Quest Create(string _id, string _idPerson=null, Chara c=null, bool assignQuest=true)
static int Range(int min, int max)
static void UseSeed(int seed, Action action)
static void SetSeed(int a=-1)
Dictionary< string, Religion > dictAll
Religion GetRandomReligion(bool onlyJoinable=true, bool includeMinor=false)
static string[] OpenFilePanel(string title, string directory, string extension, bool multiselect)
static string SaveFilePanel(string title, string directory, string defaultName, string extension)
void RemoveActorEx(Card c)
Dictionary< string, CardRow > map
static SpawnList Get(string id, Func< SourceChara.Row, bool > func)
static SpawnList Get(string id, string parent=null, CardFilter filter=null)
CardRow Select(int lv=-1, int levelRange=-1)
static SpawnSetting Default
static SpawnSetting Fish()
static SpawnSetting HomeGuest(int lv)
static SpawnSetting Evolved(int fixedLv=-1)
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
void DestroyAll(Func< Thing, bool > funcExclude=null)
Thing CanStack(Thing target, int destInvX=-1, int destInvY=-1)
static Thing CreateFromCategory(string idCat, int lv=-1)
static Thing Create(string id, int idMat=-1, int lv=-1)
override string GetName(NameStyle style, int _num=-1)
virtual bool CanGiveRandomQuest
virtual bool CanAutoRevive
virtual bool IsFor(Zone z)
static bool CanTagSale(Card t, bool insideContainer=false)
static Thing MakeSeed(string idSource)
static void LevelSeed(Thing t, SourceObj.Row obj, int num)
Point GetRandomPoint(Func< Point, bool > func=null, Chara accessChara=null)
virtual ShopType ShopType
string GetParam(int i, string def=null)
virtual List< Point > ListPoints(Point center=null, bool onlyPassable=true, bool allowChara=true)
static void Reserve(string idStep, Action onBeforePlay=null)
FilterResult IsFilterPass(string text)
static ZoneProfile Load(string id)
Card AddThing(string id, int x, int z)
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
void ClearZones(Zone current=null)
Chara SpawnMob(string id, Point pos=null)
Card AddCard(Card t, Point point)
bool IsBelow(int _major, int _minor, int _batch)