1138{
1140 {
1141 idHat = null;
1142 base.dateHat = 0;
1143 }
1145 }
1146
1147 public void OnVisit()
1148 {
1150 {
1151 ResetHostility();
1153 List<Chara> list = new List<Chara>();
1155 {
1158 {
1159 chara.c_fur = 0;
1160 }
1162 {
1163 list.Add(chara);
1164 }
1165 }
1167 {
1169 }
1170 }
1172 {
1173 RefreshDeathSentense();
1174 }
1175 RefreshCriminal();
1177 events.OnVisit();
1178 OnActivate();
1179 UpdateQuests();
1180 OnBeforeSimulate();
1181 isSimulating = true;
1182 try
1183 {
1184 Simulate();
1185 }
1186 catch (Exception exception)
1187 {
1188 Debug.LogException(exception);
1189 }
1190 finally
1191 {
1192 isSimulating = false;
1193 }
1194 OnAfterSimulate();
1198 {
1199 base.visitCount++;
1200 }
1202 if (HasField(10000))
1203 {
1205 }
1206 }
1207
1208 public void RefreshDeathSentense()
1209 {
1211 {
1213 {
1215 }
1216 }
1217 }
1218
1220 {
1222 if (ShouldAutoRevive)
1223 {
1224 foreach (
Chara deadChara
in map.deadCharas)
1225 {
1227 {
1230 {
1232 }
1234 }
1235 }
1236 }
1238 {
1240 {
1242 Point point = GetSpawnPos(value);
1244 {
1246 }
1248 }
1249 }
1250 map.deadCharas.Clear();
1251 }
1252
1253 public virtual void OnRegenerate()
1254 {
1255 }
1256
1257 public virtual void OnActivate()
1258 {
1259 if (!(id == "startVillage2"))
1260 {
1261 return;
1262 }
1264 {
1265 SetBGM(121, refresh: false);
1266 }
1267 int num = 0;
1269 {
1271 {
1272 num++;
1273 }
1274 }
1275 if (num > 0)
1276 {
1277 Msg.
Say(
"num_silvercat", num.ToString() ??
"");
1278 }
1279 }
1280
1281 public virtual void OnBeforeDeactivate()
1282 {
1283 }
1284
1285 public virtual void OnDeactivate()
1286 {
1287 }
1288
1289 public virtual void OnBeforeSimulate()
1290 {
1291 }
1292
1293 public virtual void OnVisitNewMapOrRegenerate()
1294 {
1295 }
1296
1297 public virtual void OnAfterSimulate()
1298 {
1299 }
1300
1301 public virtual void OnAdvanceHour()
1302 {
1303 }
1304
1305 public void Simulate()
1306 {
1308 {
1309 if (
Boss !=
null && IsNefia)
1310 {
1314 }
1315 int num = Mathf.Clamp(MinsSinceLastActive, 1, 10000);
1317 {
1319 {
1320 chara2.hp = 0;
1321 }
1323 {
1325 {
1326 chara2.mana.value = 0;
1327 }
1329 {
1330 chara2.stamina.value = 0;
1331 }
1332 }
1333 if (num > 60)
1334 {
1335 chara2.resistCon = null;
1336 }
1338 {
1339 Msg.ignoreAll = true;
1341 chara2.
HealHP((
int)((
long)Mathf.Max(1, chara2.
MaxHP) * (
long)Mathf.Min(num, 20) / 20));
1342 chara2.
mana.
Mod(Mathf.Max(1, chara2.
mana.
max) * Mathf.Min(num, 20) / 20);
1344 Msg.ignoreAll = false;
1345 }
1346 }
1347 }
1348 Debug.Log(
"Last Active:" + base.lastActive);
1349 if (base.lastActive == 0 || IsRegion)
1350 {
1351 return;
1352 }
1353 if (pendingSimHours < 0)
1354 {
1355 pendingSimHours = 0;
1356 }
1357 int num2 = GetInt(3);
1358 if (num2 == 0)
1359 {
1361 }
1363 int hourSinceLastActive = HourSinceLastActive;
1364 if (hourSinceLastActive <= 1 && pendingSimHours == 0)
1365 {
1366 return;
1367 }
1368 int num3 = hourSinceLastActive + pendingSimHours;
1369 int num4 = ((num2 > 0 && num3 > num2) ? (num3 - num2) : 0);
1370 num3 -= num4;
1371 int num5 = ((EClass.player.simulatingZone && num3 > maxSleepSimHours) ? maxSleepSimHours : num3);
1372 pendingSimHours = num3 - num5;
1373 Debug.Log(
$"{Name} Simulate/{num5}/{pendingSimHours}/skipped {num4}");
1374 try
1375 {
1378 int passed = num5 + num4;
1379 int num6 = passed / 24;
1380 if (num6 > 0)
1381 {
1383 {
1384 if (!
item.IsPCParty)
1385 {
1386 item.OnSleep(200, num6);
1387 if (
item.conSleep !=
null)
1388 {
1389 item.conSleep.Kill();
1390 }
1392 {
1394 }
1395 if (
item.things.Count > 20)
1396 {
1398 }
1399 }
1400 }
1401 }
1402 VirtualDate.current = virtualDate;
1403 int num7 = 0;
1404 for (int i = 0; i < num5; i++)
1405 {
1406 try
1407 {
1409 }
1410 catch (Exception exception)
1411 {
1412 if (num7++ == 0)
1413 {
1414 Debug.LogException(exception);
1415 }
1416 }
1417 }
1419 {
1421 });
1422 VirtualDate.current = null;
1423 if (!IsPCFaction)
1424 {
1425 return;
1426 }
1427 int num8 = 0;
1428 foreach (
Chara item2
in list)
1429 {
1431 {
1432 continue;
1433 }
1435 {
1436 if (item2.
id ==
"bee")
1437 {
1438 num8++;
1439 }
1440 if (num6 > 0 && item2.
IsGuest())
1441 {
1445 }
1446 continue;
1447 }
1448 if (num6 > 0)
1449 {
1451 item2.
SetAI(goalWork);
1453 {
1454 (goalWork as
GoalWork).FindWork(item2);
1455 }
1458 item2.
SetAI(goalWork);
1460 {
1461 (goalWork as
GoalWork).FindWork(item2);
1462 }
1464 }
1467 {
1469 }
1470 }
1471 List<Thing> list2 = new List<Thing>();
1473 {
1475 {
1476 list2.Add(thing);
1477 }
1478 }
1479 if (num8 >= list2.Count)
1480 {
1481 return;
1482 }
1483 for (int num9 = num8; num9 < list2.Count; num9++)
1484 {
1486 {
1488 AddCard(chara, list2.RandomItem().pos);
1490 chara.c_originalHostility = c_originalHostility;
1491 }
1492 }
1493 }
1494 finally
1495 {
1496 VirtualDate.current = null;
1497 }
1498 }
1499
1501 {
1505 bool flag = zone ==
null || zone.lv > base.
lv;
1506 if (IsRegion)
1507 {
1509 {
1511 if (GetZoneAt(topZone.
x, topZone.
y) !=
null)
1512 {
1514 }
1515 }
1516 }
1518 {
1520 }
1522 {
1523 enterState = RegionEnterState;
1524 }
1526 {
1528 }
1529 float rate = zoneTransition?.
ratePos ?? (-1f);
1530 if (IsPCFaction)
1531 {
1533 {
1535 if (spot != null)
1536 {
1538 if (nearestPoint !=
null && nearestPoint.
IsValid)
1539 {
1540 return nearestPoint;
1541 }
1542 }
1543 }
1544 }
1545 while (true)
1546 {
1547 switch (enterState)
1548 {
1550 return new Point(zoneTransition.
x, zoneTransition.
z);
1552 {
1554 {
1556 {
1558 if (traitTeleporter != null)
1559 {
1561 }
1562 if (traitTeleporter !=
null && !zoneTransition.
idTele.IsEmpty() && zoneTransition.
idTele == traitTeleporter.
id.IsEmpty(traitTeleporter.
GetParam(3)))
1563 {
1565 }
1566 }
1567 }
1569 {
1571 {
1573 }
1574 }
1576 if (randomThing2 != null)
1577 {
1579 }
1581 }
1585 {
1587 {
1589 {
1591 {
1593 }
1594 }
1596 if (randomThing != null)
1597 {
1599 }
1600 }
1603 {
1605 if (thing != null)
1606 {
1608 }
1609 }
1611 if (thing != null)
1612 {
1614 }
1616 if (thing != null)
1617 {
1619 }
1620 if (base.lv == 0)
1621 {
1622 goto IL_04da;
1623 }
1624 flag = base.lv <= 0;
1625 break;
1626 }
1629 if (map.config.embarkX != 0)
1630 {
1631 return new Point(map.config.embarkX, map.config.embarkY);
1632 }
1633 return map.GetCenterPos().GetNearestPoint(allowBlock: false, allowChara: false);
1635 return map.bounds.GetTopPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1637 return map.bounds.GetRightPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1639 return map.bounds.GetBottomPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1641 return map.bounds.GetLeftPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1647 {
1648 return new Point(map.config.embarkX, map.config.embarkY);
1649 }
1650 return new Point(zoneTransition.
x, zoneTransition.
z);
1652 return GetRandomVisitPos(c);
1654 flag = true;
1655 break;
1657 flag = false;
1658 break;
1659 }
1660 break;
1661 IL_04da:
1663 }
1665 {
1667 {
1669 {
1670 c.
SetDir(traitNewZone.owner.dir);
1671 }
1672 return traitNewZone.GetExitPos();
1673 }
1674 }
1676 {
1677 if (thing6.
trait is
TraitNewZone traitNewZone2 && ((flag && traitNewZone2.IsUpstairs) || (!flag && traitNewZone2.IsDownstairs)))
1678 {
1680 {
1681 c.
SetDir(traitNewZone2.owner.dir);
1682 }
1683 return traitNewZone2.GetExitPos();
1684 }
1685 }
1686 return GetRandomVisitPos(c);
1687 }
1688
1690 {
1692 if (
EClass.
rnd(3) == 0 && map.rooms.listRoom.Count > 0)
1693 {
1694 point = map.rooms.listRoom.RandomItem().points.RandomItem();
1695 }
1696 if (point ==
null &&
EClass.
rnd(4) != 0)
1697 {
1699 if (ie.Count() > 0)
1700 {
1702 }
1703 }
1704 if (point == null)
1705 {
1706 point = map.bounds.GetRandomSurface(centered:
false, walkable:
true, !IsPCFaction && !(
this is
Zone_Civilized)) ?? map.bounds.
GetRandomPoint();
1707 }
1709 }
1710
1711 public void AddGlobalCharasOnActivate()
1712 {
1713 Point spawnPosPC =
null;
1715 {
1716 spawnPosPC = GetSpawnPos(
EClass.
pc);
1717 }
1718 if (spawnPosPC == null)
1719 {
1720 spawnPosPC = map.GetCenterPos();
1721 }
1723 {
1725 }
1728 {
1730 {
1731 continue;
1732 }
1734 {
1737 }
1738 else
1739 {
1741 {
1742 continue;
1743 }
1745 {
1746 c.isRestrained = false;
1747 }
1749 {
1750 Point pos = (c.IsPC ? spawnPosPC : (c.IsPCParty ? spawnPosPC.
GetNearestPoint(allowBlock:
false, allowChara:
false, allowInstalled:
true, ignoreCenter:
true) : GetSpawnPos(c)));
1752 {
1754 {
1755 pos.
Set(spawnPosPC);
1756 }
1758 {
1761 {
1763 {
1765 return true;
1766 }
1767 return false;
1768 }, allowBlock: false, EClass.pc.party.members.Count >= 12, allowInstalled: true, ignoreCenter: true, EClass._zone.IsRegion ? 2 : 6))
1769 {
1770 pos.
Set(spawnPosPC);
1771 }
1772 }
1773 }
1775 c.global.transition = null;
1776 }
1777 map.charas.Add(c);
1778 map.AddCardOnActivate(c);
1779 }
1780 }
1782 {
1783 Point nearestPoint = spawnPosPC.
GetNearestPoint(allowBlock:
false, allowChara:
false, allowInstalled:
true, ignoreCenter:
true);
1784 item.enemy = null;
1785 item.pos.Set(nearestPoint);
1786 map.charas.Add(
item);
1787 map.AddCardOnActivate(
item);
1788 }
1790 }
1791
1792 public void Deactivate()
1793 {
1794 if (!IsUserZone && !IsPCFaction && map != null)
1795 {
1796 List<Thing> list = new List<Thing>();
1798 {
1800 {
1801 list.Add(thing);
1802 }
1803 }
1805 {
1806 foreach (
Thing item in map.props.stocked.Things.Concat(map.props.roaming.Things))
1807 {
1808 if (
item.IsContainer)
1809 {
1811 {
1813 {
1814 list.Add(thing2);
1815 }
1816 }
1817 }
1819 {
1821 }
1822 }
1823 }
1824 if (list.Count > 0)
1825 {
1826 Msg.
Say(
"pick_valuable");
1827 foreach (
Thing item2
in list)
1828 {
1829 Msg.
Say(
"pick_valuable2", item2);
1831 }
1832 }
1833 }
1835 {
1836 base.isPeace = false;
1837 }
1838 OnBeforeDeactivate();
1839 if (IsPCFaction)
1840 {
1841 foreach (
Chara member
in branch.members)
1842 {
1844 }
1845 }
1848 map.OnDeactivate();
1850 EClass.game.activeZone = null;
1851 if (IsInstance)
1852 {
1853 UnloadMap();
1854 base.isGenerated = false;
1855 }
1856 if (forceRegenerate)
1857 {
1858 UnloadMap();
1859 }
1860 OnDeactivate();
1861 }
1862
1863 public void OnKillGame()
1864 {
1866 {
1868 {
1870 }
1871 }
1872 }
1873
1874 public void UnloadMap()
1875 {
1876 map = null;
1877 if (bp != null)
1878 {
1879 bp.map = null;
1880 }
1881 if (branch != null)
1882 {
1883 branch.OnUnloadMap();
1884 }
1885 Debug.Log(
"Unloaded Map:" +
this);
1886 }
1887
1888 public void ClaimZone(
bool debug =
false,
Point pos =
null)
1889 {
1893 branch.OnCreate(this);
1894 if (base.icon == 0)
1895 {
1896 base.icon = 332;
1897 }
1898 instance = null;
1899 base.dateExpire = 0;
1901 Register();
1903 {
1904 thing.isNPCProperty = false;
1905 }
1908 if (debug)
1909 {
1910 for (int i = 0; i < 7; i++)
1911 {
1914 branch.AddMemeber(chara);
1915 }
1916 }
1917 else
1918 {
1923 if (pos == null)
1924 {
1926 }
1929 }
1930 base.idPrefix = 0;
1932 {
1934 }
1936 {
1939 }
1940 }
1941
1942 public void AbandonZone()
1943 {
1946 {
1949 {
1951 }
1952 });
1954 SetMainFaction(null);
1956 }
1957
1958 public bool CanDestroy()
1959 {
1961 {
1962 return false;
1963 }
1964 if (IsInstance)
1965 {
1966 return true;
1967 }
1968 bool flag = false;
1969 switch (id)
1970 {
1971 case "cave_dragon":
1973 {
1974 flag = true;
1975 }
1976 break;
1977 case "cave_yeek":
1979 {
1980 flag = true;
1981 }
1982 break;
1983 case "cave_mino":
1985 {
1986 flag = true;
1987 }
1988 break;
1989 case "cave_dead":
1991 {
1992 flag = true;
1993 }
1994 break;
1995 case "oldkeep":
1997 {
1998 flag = true;
1999 }
2000 break;
2001 }
2002 Zone topZone = GetTopZone();
2003 if (!flag)
2004 {
2006 {
2007 return false;
2008 }
2009 if (!base.isRandomSite && !(
this is
Zone_Field) && (topZone ==
null || topZone ==
this || topZone.
FindDeepestZone() ==
this))
2010 {
2011 return false;
2012 }
2013 }
2015 {
2016 return false;
2017 }
2019 {
2021 if (zone !=
null && zone.
GetTopZone() ==
this)
2022 {
2023 return false;
2024 }
2025 }
2026 return true;
2027 }
2028
2029 public override void _OnBeforeSave()
2030 {
2031 if (CanDestroy())
2032 {
2033 Debug.Log(
"Deleting Zone:" +
this);
2034 if (!destryoed)
2035 {
2036 Destroy();
2037 }
2038 }
2039 else if (map != null)
2040 {
2041 Debug.Log(
"Saving Zone:" +
this);
2042 map.Save(base.pathSave);
2043 if (!base.isMapSaved)
2044 {
2045 base.isMapSaved = true;
2047 IO.
CopyDir(pathTemp +
"Texture Replace", base.pathSave +
"/Texture Replace");
2048 }
2049 if (!IsActiveZone)
2050 {
2051 UnloadMap();
2052 }
2053 }
2054 }
2055
2056 public override void OnLoad()
2057 {
2058 if (branch != null)
2059 {
2060 branch.SetOwner(this);
2061 }
2062 events.OnLoad(this);
2063 }
2064
2065 public override void Destroy()
2066 {
2067 children.ForeachReverse(delegate(
Spatial z)
2068 {
2070 });
2071 if (map != null)
2072 {
2073 UnloadMap();
2074 }
2075 if (parent != null && parent.IsRegion && instance == null)
2076 {
2078 }
2080 destryoed = true;
2081 base.isGenerated = false;
2082 }
2083
2084 public void ClearZones(
Zone current =
null)
2085 {
2086 if (map != null)
2087 {
2088 UnloadMap();
2089 }
2090 base.isGenerated = false;
2091 Zone topZone = GetTopZone();
2092 if (topZone != this)
2093 {
2095 return;
2096 }
2097 children.ForeachReverse(delegate(
Spatial c)
2098 {
2099 if (c != current)
2100 {
2102 }
2103 });
2104 }
2105
2106 public void OnChildNumChange(
Card c)
2107 {
2108 }
2109
2111 {
2112 return this;
2113 }
2114
2115 public Zone GetTopZone()
2116 {
2117 if (parent == null || parent.IsRegion)
2118 {
2119 return this;
2120 }
2121 return parent as
Zone;
2122 }
2123
2124 public Card AddCardSplinkle(
Card t,
Point center,
int radius = 4)
2125 {
2127 for (int i = 0; i < 1000; i++)
2128 {
2132 {
2133 return AddCard(t, point);
2134 }
2135 }
2136 return AddCard(t, center);
2137 }
2138
2139 public Chara AddChara(
string id,
int x,
int z)
2140 {
2142 }
2143
2145 {
2146 return AddChara(
id, p.
x, p.
z);
2147 }
2148
2149 public Card AddThing(
string id,
int x,
int z)
2150 {
2152 }
2153
2154 public Card AddThing(
string id,
Point p)
2155 {
2156 return AddThing(
id, p.
x, p.
z);
2157 }
2158
2160 {
2161 return AddCard(t, point.
x, point.
z);
2162 }
2163
2165 {
2166 return AddCard(t, 0, 0);
2167 }
2168
2169 public Card AddCard(
Card t,
int x,
int z)
2170 {
2172 {
2174 }
2175 t.parent = this;
2177 if (chara != null)
2178 {
2179 chara.currentZone = this;
2181 }
2182 if (IsActiveZone)
2183 {
2184 map.OnCardAddedToZone(t, x, z);
2186 {
2188 }
2189 ignoreSpawnAnime = false;
2190 }
2192 {
2194 chara.hasSpawned = true;
2195 }
2196 return t;
2197 }
2198
2199 public void RemoveCard(
Card t)
2200 {
2201 if (IsActiveZone)
2202 {
2203 map.OnCardRemovedFromZone(t);
2204 }
2205 t.parent = null;
2207 {
2208 t.Chara.currentZone = null;
2209 }
2211 {
2213 }
2215 {
2217 }
2218 }
2219
2220 public T GetRandomSpot<T>() where T :
Trait
2221 {
2223 }
2224
2225 public bool TryAddThingInSpot<T>(
Thing t,
bool useContainer =
true) where T :
Trait
2226 {
2228 if (randomThing == null)
2229 {
2231 {
2233 }
2234 else
2235 {
2237 }
2238 return false;
2239 }
2241 {
2242 List<Thing> list = new List<Thing>();
2244 {
2245 foreach (
Card item2
in item.ListCards())
2246 {
2248 {
2249 list.Add(item2.
Thing);
2250 }
2251 }
2252 }
2253 if (TryAddThingInSharedContainer(t, list, add: true, msg: false, null, sharedOnly: false))
2254 {
2255 return true;
2256 }
2257 }
2259 {
2261 }
2262 else
2263 {
2265 }
2266 return true;
2267 }
2268
2269 public List<Thing> TryListThingsInSpot<T>(Func<Thing, bool> func =
null) where T :
TraitSpot
2270 {
2271 List<T> list = new List<T>();
2272 List<Thing> list2 = new List<Thing>();
2274 {
2276 {
2277 list.Add(thing.
trait as T);
2278 }
2279 }
2280 foreach (T
item in list)
2281 {
2282 foreach (
Point item2
in item.ListPoints(
null, onlyPassable:
false))
2283 {
2285 {
2287 {
2288 continue;
2289 }
2290 if (thing2.
things.Count == 0)
2291 {
2292 if (IsValid(thing2))
2293 {
2294 list2.Add(thing2);
2295 }
2296 continue;
2297 }
2299 {
2300 list2.Add(item3);
2301 }
2302 }
2303 }
2304 }
2305 return list2;
2306 bool IsValid(
Thing t)
2307 {
2308 if (func != null && !func(t))
2309 {
2310 return false;
2311 }
2312 return true;
2313 }
2314 }
2315
2316 public bool TryAddThingInSharedContainer(
Thing t, List<Thing> containers =
null,
bool add =
true,
bool msg =
false,
Chara chara =
null,
bool sharedOnly =
true)
2317 {
2318 Thing thing = FindSharedContainer(t, containers, sharedOnly);
2319 if (thing == null)
2320 {
2321 return false;
2322 }
2323 if (add)
2324 {
2325 if (msg)
2326 {
2328 }
2330 }
2331 return true;
2332 }
2333
2334 public Thing FindSharedContainer(
Thing t, List<Thing> containers =
null,
bool sharedOnly =
true)
2335 {
2337 int priority = -1;
2340 {
2342 }
2343 if (containers == null)
2344 {
2346 }
2347 SearchDest();
2348 return dest;
2350 {
2351 foreach (
Thing container
in containers)
2352 {
2353 Thing thing = container;
2355 {
2357 }
2359 {
2361 if (windowSaveData != null)
2362 {
2364 {
2365 continue;
2366 }
2369 {
2372 {
2373 continue;
2374 }
2375 }
2377 {
2379 {
2380 bool flag2 = false;
2381 foreach (
int cat
in windowSaveData.
cats)
2382 {
2384 {
2385 flag2 = true;
2386 break;
2387 }
2388 }
2389 if (!flag2)
2390 {
2391 continue;
2392 }
2393 }
2394 else if (windowSaveData.
flag.HasFlag(flag))
2395 {
2396 continue;
2397 }
2398 }
2399 priority = windowSaveData.
priority;
2400 }
2401 else
2402 {
2403 if (priority != -1)
2404 {
2405 continue;
2406 }
2407 priority = 0;
2408 }
2409 dest = thing;
2410 }
2411 }
2412 return null;
2413 }
2414 }
2415
2416 public bool TryAddThing(
Thing target,
Point p,
bool destroyIfFail =
false)
2417 {
2418 int num = 0;
2420 {
2422 {
2424 {
2426 {
2427 return true;
2428 }
2429 num++;
2430 }
2431 }
2432 }
2433 if (num == 0 || !destroyIfFail)
2434 {
2436 return true;
2437 }
2439 return false;
2440 }
2441
2442 public Thing TryGetThingFromSharedContainer(Func<Thing, bool> func)
2443 {
2445 {
2447 {
2449 if (thing != null)
2450 {
2451 return thing;
2452 }
2453 }
2454 }
2455 return null;
2456 }
2457
2459 {
2460 List<T> list = new List<T>();
2462 {
2464 {
2465 list.Add(thing2.
trait as T);
2466 }
2467 }
2468 foreach (T
item in list)
2469 {
2470 foreach (
Point item2
in item.ListPoints(
null, onlyPassable:
false))
2471 {
2473 {
2475 {
2476 continue;
2477 }
2478 if (thing3.
things.Count == 0)
2479 {
2480 if (IsValid(thing3, insideContainer: false))
2481 {
2482 return thing3;
2483 }
2484 continue;
2485 }
2487 if (thing != null)
2488 {
2489 return thing;
2490 }
2491 }
2492 }
2493 }
2494 return null;
2495 bool IsValid(
Thing t,
bool insideContainer)
2496 {
2498 {
2499 return false;
2500 }
2501 return true;
2502 }
2503 }
2504
2506 {
2507 string text = IdProfile;
2508 if (text.IsEmpty())
2509 {
2511 if (base.lv != 0)
2512 {
2513 text = ((base.lv < 0) ? "Underground" : "Sky");
2514 }
2515 else if (region != null)
2516 {
2519 if (bp != null)
2520 {
2521 name =
Lang.
GetList(
"zone_" + text.Split(
'/')[1]).RandomItem();
2523 for (int i = 0; i < 3; i++)
2524 {
2525 for (int j = 0; j < 3; j++)
2526 {
2528 }
2529 }
2530 if (text == "Random/R_Shore")
2531 {
2532 base.isBeach = true;
2533 }
2534 }
2535 }
2536 else
2537 {
2538 text = "Random";
2539 }
2540 idProfile = text;
2541 }
2543 }
2544
2545 public void CreateBP()
2546 {
2548 bp.Create();
2549 bp.genSetting.seed = base.Seed;
2550 OnCreateBP();
2551 }
2552
2553 public virtual void OnCreateBP()
2554 {
2555 }
2556
2557 public void Generate()
2558 {
2559 base.isGenerated = true;
2560 if (bp == null)
2561 {
2562 CreateBP();
2563 }
2564 if (bp.map == null)
2565 {
2566 bp.GenerateMap(this);
2567 }
2568 map.SetZone(this);
2570 bool flag = IdBiome == "Sand" || IdBiome == "Water" || IsUnderwater;
2571 if (flag)
2572 {
2573 int num = 1 +
EClass.
rnd((IdBiome ==
"Water") ? 3 : 2);
2574 for (int i = 0; i < num; i++)
2575 {
2578 {
2579 Thing t =
ThingGen.
Create(
"pearl_oyster",
new string[3] {
"wood_birch",
"poplar",
"coralwood" }.RandomItem(), ContentLv);
2581 }
2582 }
2584 for (int j = 0; j < num; j++)
2585 {
2588 {
2590 }
2591 }
2593 {
2595 if (!randomSurface3.
HasObj)
2596 {
2598 }
2599 }
2600 }
2601 if (IsUnderwater)
2602 {
2603 for (
int l = 0; l < 30 +
EClass.
rnd(30); l++)
2604 {
2606 }
2611 if (IsNefia)
2612 {
2614 if (num3 > 0)
2615 {
2621 }
2622 }
2624 {
2625 int num7 = 137;
2626 foreach (
Point point
in r.points)
2627 {
2629 {
2630 map.
SetObj(point.
x, point.
z, num7);
2634 {
2636 }
2637 }
2638 }
2639 return false;
2640 });
2642 {
2643 int num7 = 136;
2644 foreach (
Point point2
in r.points)
2645 {
2647 {
2649 }
2650 }
2651 return false;
2652 });
2654 {
2655 int idFloor = 121;
2656 foreach (
Point point3
in r.points)
2657 {
2659 }
2660 return false;
2661 });
2662 }
2663 if (zone_Field != null)
2664 {
2666 {
2668 for (int num5 = 0; num5 < num4; num5++)
2669 {
2672 {
2675 }
2676 }
2677 }
2679 {
2680 SpawnAltar();
2681 }
2682 TrySpawnFollower();
2684 {
2687 {
2689 }
2690 }
2691 if (base.Tile.isRoad)
2692 {
2693 for (
int num6 = 0; num6 <
EClass.
rnd(4); num6++)
2694 {
2696 }
2697 }
2698 }
2699 map.plDay = CreatePlaylist(ref map._plDay,
EClass.
Sound.GetPlaylist(IDPlayList) ??
EClass.
Sound.GetPlaylist(
"Day"));
2700 }
2701
2702 public void TrySpawnFollower()
2703 {
2706 {
2707 return;
2708 }
2711 {
2712 return;
2713 }
2719 {
2721 if (row != null)
2722 {
2724 }
2725 }
2727 for (
int num = 0; num < 3 +
EClass.
rnd(4); num++)
2728 {
2733 }
2734 }
2735
2736 public void SpawnAltar()
2737 {
2739 {
2740 if (r.points.Count <= 4)
2741 {
2742 return false;
2743 }
2744 map.poiMap.OccyupyPOI(r.points[0]);
2745 List<Point> points = r.points;
2747 "altarPoint".lang(randomReligion.NameDomain.lang());
2752 for (
int i = 0; i < 2 +
EClass.
rnd(2); i++)
2753 {
2756 }
2758 {
2760 }
2762 {
2763 if (
item.x % 3 == 0 &&
item.z % 2 == 0 &&
item != points[0] && !
item.Equals(points[0].Front) &&
item.Installed ==
null)
2764 {
2765 thing = ThingGen.Create("pillar1");
2766 EClass._zone.AddCard(thing, item).Install();
2767 }
2769 item.SetFloor(3, 6);
2770 }
2771 return true;
2772 });
2773 }
2774
2775 public virtual void OnGenerateMap()
2776 {
2777 if (MakeEnemiesNeutral)
2778 {
2780 {
2782 {
2784 chara.hostility = hostility;
2785 }
2786 }
2787 }
2788 if (PrespawnRate != 0f && !IsSkyLevel)
2789 {
2790 for (int i = 0; i < (int)((float)MaxSpawn * PrespawnRate); i++)
2791 {
2792 SpawnMob();
2793 }
2794 }
2795 TryGenerateOre();
2796 TryGenerateBigDaddy();
2797 TryGenerateEvolved();
2798 TryGenerateShrine();
2799 }
2800
2801 public void TryGenerateOre()
2802 {
2803 if (OreChance <= 0f)
2804 {
2805 return;
2806 }
2808 {
2809 int num = 18;
2810 string text = "ore";
2811 if (EClass.rnd(5) == 0)
2812 {
2813 num++;
2814 text = "gem";
2815 }
2817 foreach (
Point point in r.points)
2818 {
2819 if (point.sourceBlock.ContainsTag("ore"))
2820 {
2821 map.SetObj(point.x, point.z, randomMaterial.id, num, 1, 0);
2822 }
2823 }
2824 return false;
2825 });
2826 }
2827
2828 public Chara TryGenerateEvolved(
bool force =
false,
Point p =
null)
2829 {
2832 {
2833 return null;
2834 }
2836 for (
int i = 0; i < 2 +
EClass.
rnd(2); i++)
2837 {
2839 }
2842 {
2844 }
2845 return chara;
2846 }
2847
2848 public void TryGenerateBigDaddy()
2849 {
2851 {
2853 List<string> list = new List<string> { "big_daddy", "big_daddy2" };
2854 list.Shuffle();
2855 Spawn(list[0], spawnPos);
2857 {
2858 Spawn(list[1], spawnPos.
GetNearestPoint(allowBlock:
false, allowChara:
false));
2859 }
2860 Msg.
Say(
"sign_bigdaddy");
2861 }
2862 void Spawn(
string id,
Point pos)
2863 {
2864 int num = (int)((long)DangerLv * 125L / 100);
2865 if (num >= 30)
2866 {
2868 {
2869 lv = num
2870 });
2871 }
2874 {
2876 }
2878 {
2880 }
2882 }
2883 }
2884
2885 public void TryGenerateShrine()
2886 {
2888 for (int i = 0; i < 3; i++)
2889 {
2892 {
2893 continue;
2894 }
2896 if (randomSpace == null)
2897 {
2898 continue;
2899 }
2903 {
2904 continue;
2905 }
2910 {
2913 }
2914 else
2915 {
2917 }
2918 }
2920 }
2921
2922 public void ResetHostility()
2923 {
2925 {
2927 {
2928 chara.c_originalHostility = (
Hostility)0;
2929 }
2932 {
2934 }
2935 }
2936 }
2937
2938 public virtual void OnGenerateRooms(
BaseMapGen gen)
2939 {
2940 }
2941
2943 {
2945 for (int i = 0; i < tries; i++)
2946 {
2949 {
2950 continue;
2951 }
2952 switch (type)
2953 {
2955 {
2957 if (list.Count > 0)
2958 {
2959 list.Shuffle();
2961 {
2962 List<Point> list2 =
item.ListPoints(
null, onlyPassable:
true, allowChara:
false);
2963 if (list2.Count > 0)
2964 {
2965 return list2.RandomItem();
2966 }
2967 }
2968 }
2971 {
2972 continue;
2973 }
2974 break;
2975 }
2978 {
2979 continue;
2980 }
2981 break;
2982 }
2983 return point;
2984 }
2985 return null;
2986 }
2987
2988 public Chara SpawnMob(
string id,
Point pos =
null)
2989 {
2991 {
2992 id = id
2993 });
2994 }
2995
2997 {
2998 if (setting == null)
2999 {
3001 }
3002 if (pos == null)
3003 {
3004 pos = GetSpawnPos(setting.position, setting.tries);
3005 if (pos == null)
3006 {
3008 if (pos == null)
3009 {
3010 return null;
3011 }
3012 }
3013 }
3015 if (IsUnderwater &&
EClass.
rnd(15) != 0)
3016 {
3018 }
3020 if (setting.idSpawnList != null)
3021 {
3023 }
3025 {
3027 }
3029 {
3030 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);
3031 }
3033 {
3035 }
3037 {
3038 spawnList =
SpawnList.
Get(IsInstance ?
"c_neutral_war" :
"c_neutral");
3039 }
3041 {
3044 {
3045 ShouldPass = (
SourceChara.Row s) => (!(s.hostility !=
"") || (!s.tag.Contains(
"cat") && !s.race_row.tag.Contains(
"cat"))) ? true :
false
3046 }));
3047 }
3048 else
3049 {
3051 {
3053 {
3054 if (s.hostility != "")
3055 {
3056 return false;
3057 }
3058 return s.biome == biome.name || s.biome.IsEmpty();
3059 }
3060 });
3061 }
3062 int num = ((setting.dangerLv == -1) ? DangerLv : setting.dangerLv);
3064 {
3066 idEle = setting.idEle
3067 };
3068 int num2 = ((setting.filterLv == -1) ? num : setting.filterLv);
3070 {
3071 num2 = ((num - 1) % 50 + 5) * 150 / 100;
3072 if (num2 >= 20 &&
EClass.
rnd(100) < num2)
3073 {
3074 num2 = num;
3075 }
3076 }
3079 {
3082 }
3083 if (cardRow == null)
3084 {
3085 Debug.LogError(
"SpawnMob: no spawn row list/" + spawnList?.
id +
"/biome/" + biome.name +
"/zone/" + Name);
3086 return null;
3087 }
3088 long num3 = ((setting.fixedLv == -1) ? cardRow.
LV : setting.fixedLv);
3089 bool flag = setting.fixedLv != -1 || setting.addLv > 0 || DangerLvBoost > 0;
3090 num3 += setting.addLv;
3092 {
3093 num3 = (50L + (long)cardRow.
LV) * Mathf.Max(1, (num - 1) / 50);
3094 flag = true;
3095 }
3096 num3 += DangerLvBoost;
3097 if (flag && num3 <= Mathf.Max(50, cardRow.
LV))
3098 {
3099 flag = false;
3100 }
3101 if (setting.rarity ==
Rarity.Random && cardRow.
quality == 0)
3102 {
3104 {
3105 cardBlueprint.rarity =
Rarity.Legendary;
3106 num3 = num3 * 125 / 100;
3107 }
3108 }
3109 else
3110 {
3111 cardBlueprint.rarity = setting.rarity;
3112 }
3113 if (setting.isBoss)
3114 {
3115 num3 = num3 * 150 / 100;
3116 }
3117 if (setting.isEvolved)
3118 {
3119 num3 = num3 * 2 + 20;
3120 }
3121 if (num3 != cardRow.
LV)
3122 {
3123 cardBlueprint.lv = (int)Mathf.Min(num3, 100000000f);
3124 }
3127 if (!flag)
3128 {
3129 chara.isScaled = false;
3130 }
3131 AddCard(chara, pos);
3132 if (setting.forcedHostility.HasValue)
3133 {
3134 Hostility c_originalHostility = (chara.hostility = setting.forcedHostility.Value);
3135 chara.c_originalHostility = c_originalHostility;
3136 }
3137 else
3138 {
3140 {
3141 case "unicorn":
3143 {
3145 }
3146 break;
3147 case "santa":
3148 case "silverwolf":
3149 case "twintail":
3150 case "test17":
3152 {
3154 }
3156 {
3158 }
3159 break;
3160 }
3161 }
3162 if (setting.isBoss)
3163 {
3165 }
3166 if (setting.isEvolved)
3167 {
3168 chara.c_bossType =
BossType.Evolved;
3169 }
3170 if (DangerLv >= 20 && !IsPCFaction && !IsTown &&
EClass.
rnd(200) == 0)
3171 {
3173 }
3174 return chara;
3175 }
3176
3177 public bool HasField(int idEle)
3178 {
3179 return fieldElements.Has(idEle);
3180 }
3181
3182 public void SetFieldEffect(int idEle, int a, int duration = 0)
3183 {
3184 fieldElements.SetBase(idEle, a, duration);
3185 }
3186
3187 public void RemoveFieldEffect(int idEle)
3188 {
3189 fieldElements.Remove(idEle);
3190 }
3191
3192 public void RefreshElectricity()
3193 {
3194 dirtyElectricity = false;
3195 bool flag = GetSoilCost() > MaxSoil;
3196 base.electricity = elements.Value(2201) * 10 + BaseElectricity;
3198 {
3200 {
3202 }
3203 }
3204 if (!flag)
3205 {
3207 {
3209 {
3210 base.electricity += 20;
3211 }
3212 });
3213 }
3215 {
3217 {
3219 }
3220 }
3221 }
3222
3223 public int GetElectricity(bool cost = false)
3224 {
3225 bool flag = GetSoilCost() > MaxSoil;
3226 int sum = 0;
3228 {
3230 {
3231 continue;
3232 }
3233 if (cost)
3234 {
3236 {
3238 }
3239 }
3241 {
3243 }
3244 }
3245 if (!cost)
3246 {
3247 sum += elements.Value(2201) * 10 + BaseElectricity;
3248 if (!flag)
3249 {
3251 {
3253 {
3254 sum += 20;
3255 }
3256 });
3257 }
3258 }
3259 return sum;
3260 }
3261
3262 public void SetBGM(List<int> ids, bool refresh = true, float fadeDuration = 0f)
3263 {
3264 map._plDay.Clear();
3265 if (ids.Count > 0)
3266 {
3267 foreach (int id in ids)
3268 {
3269 if (id != -1)
3270 {
3271 map._plDay.Add(id);
3272 }
3273 }
3274 }
3275 UnityEngine.Object.DestroyImmediate(map.plDay);
3276 map.plDay = null;
3277 RefreshPlaylist();
3278 if (!refresh)
3279 {
3280 return;
3281 }
3282 if (fadeDuration > 0f)
3283 {
3284 EClass.
Sound.StopBGM(fadeDuration, playLastBGM:
false, delegate
3285 {
3287 {
3288 RefreshBGM();
3289 }
3290 });
3291 }
3292 else
3293 {
3295 RefreshBGM();
3296 }
3297 }
3298
3299 public void SetBGM(int id = -1, bool refresh = true, float fadeDuration = 0f)
3300 {
3301 SetBGM(new List<int> { id }, refresh, fadeDuration);
3302 }
3303
3304 public void RefreshPlaylist()
3305 {
3306 if (map.plDay == null)
3307 {
3308 map.plDay = CreatePlaylist(ref map._plDay,
EClass.
Sound.GetPlaylist(IDPlayList));
3309 }
3311 }
3312
3313 public void ResetPlaylist()
3314 {
3315 map._plDay.Clear();
3316 UnityEngine.Object.DestroyImmediate(map.plDay);
3317 map.plDay = null;
3318 RefreshPlaylist();
3319 }
3320
3321 public void RefreshBGM()
3322 {
3324 {
3325 return;
3326 }
3327 RefreshPlaylist();
3328 Playlist playlist = map.plDay;
3330 {
3331 if (
item.playlist !=
null)
3332 {
3333 playlist =
item.playlist;
3334 }
3335 }
3336 if (IDPlaylistOverwrite != null)
3337 {
3338 playlist =
EClass.
Sound.GetPlaylist(IDPlaylistOverwrite);
3339 }
3341 {
3343 if (room !=
null && room.
lot !=
null && room.
lot.
idBGM != 0)
3344 {
3346 if (playlist.list[0].data?.id != room.
lot.
idBGM)
3347 {
3349 playlist.Reset();
3351 {
3353 }
3354 }
3355 }
3356 }
3359 }
3360
3361 public Playlist CreatePlaylist(ref List<int> list, Playlist mold = null)
3362 {
3363 return ModUtil.CreatePlaylist(ref list, mold);
3364 }
3365
3366 public Chara FindChara(
string id)
3367 {
3368 return map.charas.Find((
Chara c) => c.
id ==
id);
3369 }
3370
3371 public Chara FindChara(
int uid)
3372 {
3373 return map.charas.Find((
Chara c) => c.
uid == uid);
3374 }
3375
3376 public Chara FindDeadChara(
string id)
3377 {
3378 return map.deadCharas.Find((
Chara c) => c.
id ==
id);
3379 }
3380
3381 public int GetDeepestLv()
3382 {
3383 int max = base.lv;
3384 return GetDeepestLv(ref max);
3385 }
3386
3387 public int GetDeepestLv(ref int max)
3388 {
3389 if (Mathf.Abs(base.lv) > Mathf.Abs(max))
3390 {
3391 max = base.lv;
3392 }
3393 foreach (
Spatial child
in children)
3394 {
3395 (child as
Zone).GetDeepestLv(ref max);
3396 }
3397 return max;
3398 }
3399
3400 public int GetCostSkyTravel()
3401 {
3402 if (base.source.costSkyTravel > 0)
3403 {
3404 return base.source.costSkyTravel;
3405 }
3407 {
3408 return Mathf.Clamp(10 +
EClass.
curve(DangerLv, 50, 10), 1, 200);
3409 }
3410 return 0;
3411 }
3412
3413 public List<Element> ListLandFeats()
3414 {
3415 if (landFeats == null)
3416 {
3417 landFeats = new List<int>();
3419 string[] listBase = IDBaseLandFeat.Split(',');
3420 string[] array = listBase;
3421 foreach (string text in array)
3422 {
3423 if (!text.IsEmpty())
3424 {
3426 }
3427 }
3428 if (listBase.Length == 1)
3429 {
3431 {
3432 if (e.category != "landfeat" || e.chance == 0)
3433 {
3434 return false;
3435 }
3436 bool flag = true;
3437 string[] tag = e.tag;
3438 foreach (string text2 in tag)
3439 {
3440 if (text2.StartsWith("bf"))
3441 {
3442 flag = false;
3443 if (listBase[0] == text2)
3444 {
3445 flag = true;
3446 break;
3447 }
3448 }
3449 }
3450 return flag ? true : false;
3451 }).ToList();
3453 landFeats.Add(row.
id);
3454 list.Remove(row);
3456 landFeats.Add(row.
id);
3457 }
3459 }
3460 List<Element> list2 = new List<Element>();
3461 foreach (int landFeat in landFeats)
3462 {
3464 }
3465 return list2;
3466 }
3467
3469 {
3470 ZipFile zipFile = ZipFile.Read(path);
3471 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3472 zipFile.ExtractAll(pathTemp);
3473 zipFile.Dispose();
3475 }
3476
3477 public void Export(
string path,
PartialMap partial =
null,
bool usermap =
false)
3478 {
3479 if (subset != null)
3480 {
3481 SE.Beep();
3482 return;
3483 }
3484 try
3485 {
3487 {
3488 name = name,
3489 usermap = usermap
3490 };
3492 if (!map.config.retainDecal)
3493 {
3494 map.ClearRainAndDecal();
3495 }
3496 map.Save(
IO.
TempPath +
"/", zoneExportData, partial);
3497 map.ExportMetaData(
IO.
TempPath +
"/", Path.GetFileNameWithoutExtension(path), partial);
3498 if (partial == null)
3499 {
3501 }
3503 using (ZipFile zipFile = new ZipFile())
3504 {
3505 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3507 zipFile.Save(path);
3508 zipFile.Dispose();
3509 }
3511 }
3512 catch (Exception ex)
3513 {
3514 EClass.
ui.Say(ex.Message +
":" + path);
3515 }
3516 }
3517
3518 public void ExportDialog(string dir = null)
3519 {
3521 {
3523 if (!
string.IsNullOrEmpty(text))
3524 {
3525 Export(text);
3527 }
3528 });
3529 }
3530
3531 public void ImportDialog(string dir = null)
3532 {
3534 {
3536 if (array.Length != 0)
3537 {
3538 Zone_User zone_User = SpatialGen.Create("user", EClass.world.region, register: true) as Zone_User;
3539 zone_User.path = array[0];
3540 Thing thing = ThingGen.Create("teleporter");
3541 thing.c_uidZone = zone_User.uid;
3542 EClass._zone.AddCard(thing, EClass.pc.pos);
3543 }
3544 });
3545 }
3546
3547 public static bool IsImportValid(string path)
3548 {
3549 try
3550 {
3552 }
3553 catch (Exception ex)
3554 {
3556 return false;
3557 }
3558 }
3559
3560 public void Export()
3561 {
3563 string text = pathExport;
3565 Export(text);
3566 Msg.
Say(
"Exported Map:" + text);
3567 }
3568
3570 {
3571 }
3572
3573 public void OnInspect()
3574 {
3575 }
3576
3577 public int GetSortVal()
3578 {
3579 if (IsPCFaction)
3580 {
3581 return -10000000 + base.uid;
3582 }
3584 {
3585 return -8000000 + base.uid;
3586 }
3588 {
3589 return -9000000 + base.uid;
3590 }
3592 {
3593 return -7000000 + base.uid;
3594 }
3596 {
3597 return 1000000 + base.uid;
3598 }
3599 return base.uid;
3600 }
3601
3602 public Chara AddRandomVisitor(
bool guest =
false)
3603 {
3605 if (random == null)
3606 {
3607 return null;
3608 }
3612 {
3615 if (chara != null)
3616 {
3617 AddCard(chara, point);
3618 Msg.
Say(
"guestArrive", chara);
3620 }
3621 }
3622 else
3623 {
3625 AddCard(chara, point);
3627 }
3628 return chara;
3629 }
3630
3632 {
3633 if (base.IsPlayerFaction)
3634 {
3636 }
3637 events.OnSimulateHour();
3639 {
3641 {
3643 {
3645 }
3646 }
3648 }
3650 {
3652 });
3653 foreach (
Thing sucker
in Suckers)
3654 {
3656 }
3657 Suckers.Clear();
3658 if (RespawnRate != 0f)
3659 {
3660 int num = 0;
3661 foreach (
Chara chara
in map.charas)
3662 {
3664 {
3665 num++;
3666 }
3667 }
3668 if (num < MaxRespawn)
3669 {
3670 for (int num2 = 0; num2 < RespawnPerHour; num2++)
3671 {
3672 SpawnMob();
3673 }
3674 }
3675 }
3677 {
3678 RainWater();
3679 }
3681 {
3682 GrowPlants(date);
3683 }
3684 }
3685
3687 {
3688 if (base.IsPlayerFaction)
3689 {
3690 branch.OnSimulateDay(date);
3691 }
3692 }
3693
3695 {
3696 if (base.IsPlayerFaction)
3697 {
3698 branch.OnSimulateMonth(date);
3699 }
3701 {
3703 }
3704 }
3705
3706 public void RainWater()
3707 {
3709 {
3710 return;
3711 }
3713 {
3715 {
3716 c.isWatered = true;
3717 }
3718 });
3719 }
3720
3722 {
3724 int weedChance = 1;
3726 {
3728 }
3730 {
3732 }
3733 if (num)
3734 {
3735 HashSet<int> hashSet = new HashSet<int>();
3737 {
3739 {
3740 continue;
3741 }
3742 foreach (
Point item in traitSpotFarm.ListPoints(
null, onlyPassable:
false))
3743 {
3744 hashSet.Add(
item.index);
3745 }
3746 }
3747 Perform(hashSet);
3748 EClass.player.isAutoFarming = false;
3749 Perform(hashSet);
3750 }
3751 else
3752 {
3753 Perform(null);
3754 }
3755 void Perform(HashSet<int> farmMap)
3756 {
3759 {
3760 if (farmMap != null)
3761 {
3763 {
3764 if (!farmMap.Contains(c.index))
3765 {
3766 return;
3767 }
3768 }
3769 else if (farmMap.Contains(c.
index))
3770 {
3771 return;
3772 }
3773 }
3775 {
3776 c.decal = 0;
3777 }
3779 {
3781 {
3782 bool flag = false;
3783 if (!EClass.player.isAutoFarming && c.growth.HaltGrowth() && (c.IsFarmField || c.IsTopWater) && (!isWinter || !date.IsRealTime))
3784 {
3785 flag = true;
3786 }
3787 PlantData plantData = map.TryGetPlant(c);
3788 if (!flag && (plantData ==
null || plantData.fert >= 0))
3789 {
3790 c.TryGrow(date);
3791 }
3793 {
3794 if (date.sunMap == null)
3795 {
3796 date.BuildSunMap();
3797 }
3799 {
3800 c.growth.Perish();
3801 }
3802 }
3803 }
3804 else if (c.
detail !=
null)
3805 {
3806 c.Things.ForeachReverse(delegate(Thing t)
3807 {
3808 if (t.IsInstalled && t.trait is TraitSeed && !t.isSale)
3809 {
3810 (t.trait as TraitSeed).TrySprout(force: false, sucker: false, date);
3811 }
3812 });
3813 }
3815 {
3818 {
3820 }
3821 }
3822 }
3823 c.isWatered = false;
3824 });
3825 }
3826 }
3827
3828 public Zone GetZoneAt(
int _x,
int _y)
3829 {
3830 if (IsRegion)
3831 {
3832 foreach (
Spatial child
in children)
3833 {
3834 if (!(child is
Zone_Field) && _x == child.
x && _y == child.
y)
3835 {
3836 return child as
Zone;
3837 }
3838 }
3839 }
3840 foreach (
Spatial child2
in children)
3841 {
3842 if (_x == child2.
x && _y == child2.
y)
3843 {
3844 return child2 as
Zone;
3845 }
3846 }
3847 return null;
3848 }
3849
3850 public bool IsCrime(
Chara c,
Act act)
3851 {
3853 {
3854 return true;
3855 }
3856 return false;
3857 }
3858
3859 public void RefreshCriminal()
3860 {
3861 bool flag = EClass.player.IsCriminal && HasLaw && !AllowCriminal && !IsPCFaction;
3864 {
3866 {
3867 chara.hostility = hostility;
3869 {
3871 }
3872 }
3873 }
3874 }
3875
3876 public void RefreshListCitizen()
3877 {
3878 if (base.lv != 0)
3879 {
3880 return;
3881 }
3882 dictCitizen.Clear();
3883 foreach (
Chara item in map.charas.Concat(map.deadCharas))
3884 {
3885 if (
item.trait.IsCitizen && !
item.IsGlobal && !
item.isSubsetCard)
3886 {
3888 }
3889 }
3890 }
3891
3892 public virtual void SetAlarm(bool enable)
3893 {
3894 base.isAlarmSet = enable;
3895 if (enable)
3896 {
3898 {
3900 {
3902 }
3903 }
3906 SE.Play("alarm");
3907 return;
3908 }
3910 {
3912 {
3914 }
3915 }
3916 }
3917
3918 public void ModInfluence(int a)
3919 {
3920 base.influence += a;
3921 if (a > 0)
3922 {
3923 Msg.
Say(
"gainInfluence", Name, a.ToString() ??
"");
3924 }
3926 }
3927
3928 public void ModDevelopment(int a)
3929 {
3930 base.development += a;
3931 if (a > 0)
3932 {
3933 Msg.
Say(
"gainDevelopment", Name, a.ToString() ??
"");
3934 }
3935 }
3936
3937 public void UpdateQuests(bool force = false)
3938 {
3939 if (!IsPCFaction && (!(
this is
Zone_Town) || base.lv != 0))
3940 {
3941 return;
3942 }
3943 Debug.Log(
"Updating Quest:" + force);
3945 int num = 0;
3946 foreach (
Chara item in map.charas.Concat(map.deadCharas))
3947 {
3949 {
3950 if (
item.quest.IsExpired || completedQuests.Contains(
item.quest.uid) || force)
3951 {
3952 item.quest = null;
3953 }
3954 else
3955 {
3956 num++;
3957 }
3958 }
3959 }
3961 {
3962 return;
3963 }
3965 int maxQuest = 3;
3967 {
3968 maxQuest = 4 + EClass.rnd(4);
3969 });
3970 completedQuests.Clear();
3972 List<Tuple<string, int>> listTag = new List<Tuple<string, int>>();
3975 {
3976 array = new string[9] { "supply/8", "deliver/7", "food/8", "escort/4", "deliver/4", "monster/0", "war/0", "farm/0", "music/0" };
3977 }
3978 string[] array2 = array;
3979 for (int num2 = 0; num2 < array2.Length; num2++)
3980 {
3981 string[] array3 = array2[num2].Split('/');
3982 listTag.Add(new Tuple<string, int>(array3[0], array3[1].ToInt()));
3983 }
3984 for (int num3 = 0; num3 < map.charas.Count * 2; num3++)
3985 {
3986 if (num > maxQuest)
3987 {
3988 break;
3989 }
3990 if (num > 15)
3991 {
3992 break;
3993 }
3994 Chara chara = map.charas.RandomItem();
3996 {
3997 continue;
3998 }
4000 {
4001 int num4 = 1;
4002 foreach (Tuple<string, int> item2 in listTag)
4003 {
4004 if (a.tags.Contains(item2.Item1))
4005 {
4006 num4 = item2.Item2;
4007 break;
4008 }
4009 }
4011 {
4012 num4 = 0;
4013 }
4014 return a.chance * num4;
4015 });
4017 {
4019 num++;
4020 }
4021 }
4022 }
4023
4024 public List<Chara> ListMinions(
Chara c)
4025 {
4026 List<Chara> list = new List<Chara>();
4028 {
4030 {
4031 list.Add(chara);
4032 }
4033 }
4034 return list;
4035 }
4036
4037 public int CountMinions(
Chara c)
4038 {
4039 int num = 0;
4041 {
4043 {
4044 num++;
4045 }
4046 }
4047 return num;
4048 }
4049
4050 public int GetSoilCost()
4051 {
4052 int n = 0;
4054 {
4056 });
4057 return n / 10;
4058 }
4059
4060 public void SpawnLostItems()
4061 {
4062 for (
int i = 0; i < 2 +
EClass.
rnd(4); i++)
4063 {
4064 Point point = GetPos();
4065 if (point == null)
4066 {
4067 continue;
4068 }
4070 {
4072 thing.isLostProperty = true;
4074 int num = (thing.c_lockLv =
EClass.
rndHalf(Mathf.Min(base.development / 10 + 10, 50)));
4077 {
4079 }
4080 else
4081 {
4083 }
4085 }
4086 else
4087 {
4089 }
4090 }
4091 static Point GetPos()
4092 {
4093 for (int j = 0; j < 10; j++)
4094 {
4097 {
4098 return randomPoint;
4099 }
4100 }
4101 return null;
4102 }
4103 }
4104
4105 public void ApplyBackerPet(bool draw)
4106 {
4107 bool flag =
this is
Zone_Yowyn && base.lv == -1;
4109 list.Shuffle();
4111 {
4113 {
4114 if (EClass.player.doneBackers.Contains(a.id))
4115 {
4116 list.Remove(a);
4117 }
4118 });
4119 }
4121 {
4123 {
4124 continue;
4125 }
4127 {
4129 {
4130 continue;
4131 }
4132 if (chara.
id !=
"follower")
4133 {
4135 }
4136 }
4138 {
4139 continue;
4140 }
4142 {
4143 if (
item.chara == chara.
id)
4144 {
4147 break;
4148 }
4149 }
4150 }
4151 }
4152
4153 public FortuneRollData GetOrCreateFortuneRollData(
bool refresh =
true)
4154 {
4155 if (fortuneRoll == null)
4156 {
4159 }
4160 if (refresh || fortuneRoll.count == 0)
4161 {
4162 fortuneRoll.Refresh();
4163 }
4164 return fortuneRoll;
4165 }
4166}
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)