1125{
1127 {
1128 idHat = null;
1129 base.dateHat = 0;
1130 }
1132 }
1133
1134 public void OnVisit()
1135 {
1137 {
1138 ResetHostility();
1140 List<Chara> list = new List<Chara>();
1142 {
1145 {
1146 chara.c_fur = 0;
1147 }
1149 {
1150 list.Add(chara);
1151 }
1152 }
1154 {
1156 }
1157 }
1159 {
1160 RefreshDeathSentense();
1161 }
1162 RefreshCriminal();
1164 events.OnVisit();
1165 OnActivate();
1166 UpdateQuests();
1167 OnBeforeSimulate();
1168 isSimulating = true;
1169 Simulate();
1170 isSimulating = false;
1171 OnAfterSimulate();
1173 {
1175 }
1178 {
1179 base.visitCount++;
1180 }
1182 if (HasField(10000))
1183 {
1185 }
1186 }
1187
1188 public void RefreshDeathSentense()
1189 {
1191 {
1193 {
1195 }
1196 }
1197 }
1198
1200 {
1202 if (ShouldAutoRevive)
1203 {
1204 foreach (
Chara deadChara
in map.deadCharas)
1205 {
1207 {
1210 {
1212 }
1214 }
1215 }
1216 }
1218 {
1220 {
1222 Point point = GetSpawnPos(value);
1224 {
1226 }
1228 }
1229 }
1230 map.deadCharas.Clear();
1231 }
1232
1233 public virtual void OnRegenerate()
1234 {
1235 }
1236
1237 public virtual void OnActivate()
1238 {
1239 if (!(id == "startVillage2"))
1240 {
1241 return;
1242 }
1244 {
1245 SetBGM(121, refresh: false);
1246 }
1247 int num = 0;
1249 {
1251 {
1252 num++;
1253 }
1254 }
1255 if (num > 0)
1256 {
1257 Msg.
Say(
"num_silvercat", num.ToString() ??
"");
1258 }
1259 }
1260
1261 public virtual void OnBeforeDeactivate()
1262 {
1263 }
1264
1265 public virtual void OnDeactivate()
1266 {
1267 }
1268
1269 public virtual void OnBeforeSimulate()
1270 {
1271 }
1272
1273 public virtual void OnVisitNewMapOrRegenerate()
1274 {
1275 }
1276
1277 public virtual void OnAfterSimulate()
1278 {
1279 }
1280
1281 public virtual void OnAdvanceHour()
1282 {
1283 }
1284
1285 public void Simulate()
1286 {
1288 {
1289 if (
Boss !=
null && IsNefia)
1290 {
1294 }
1295 int num = Mathf.Clamp(MinsSinceLastActive, 1, 10000);
1297 {
1299 {
1300 chara2.hp = 0;
1301 }
1303 {
1305 {
1306 chara2.mana.value = 0;
1307 }
1309 {
1310 chara2.stamina.value = 0;
1311 }
1312 }
1313 if (num > 60)
1314 {
1315 chara2.resistCon = null;
1316 }
1318 {
1319 Msg.ignoreAll = true;
1321 chara2.
HealHP((
int)((
long)Mathf.Max(1, chara2.
MaxHP) * (
long)Mathf.Min(num, 20) / 20));
1322 chara2.
mana.
Mod(Mathf.Max(1, chara2.
mana.
max) * Mathf.Min(num, 20) / 20);
1324 Msg.ignoreAll = false;
1325 }
1326 }
1327 }
1328 Debug.Log(
"Last Active:" + base.lastActive);
1329 if (base.lastActive == 0 || HourSinceLastActive <= 1 || IsRegion)
1330 {
1331 return;
1332 }
1333 Debug.Log(Name +
" Simulate:" + HourSinceLastActive +
" hours");
1336 int num2 = HourSinceLastActive / 24;
1337 int num3 = 0;
1338 if (num2 > 0)
1339 {
1341 {
1342 if (!
item.IsPCParty)
1343 {
1344 item.OnSleep(200, num2);
1345 if (
item.conSleep !=
null)
1346 {
1347 item.conSleep.Kill();
1348 }
1350 {
1352 }
1353 if (
item.things.Count > 20)
1354 {
1356 }
1357 }
1358 }
1359 }
1360 VirtualDate.current = virtualDate;
1361 for (int i = 0; i < HourSinceLastActive; i++)
1362 {
1365 {
1366 num3++;
1367 }
1368 }
1370 {
1372 });
1373 VirtualDate.current = null;
1374 if (!IsPCFaction)
1375 {
1376 return;
1377 }
1378 int num4 = 0;
1379 foreach (
Chara item2
in list)
1380 {
1382 {
1383 continue;
1384 }
1386 {
1387 if (item2.
id ==
"bee")
1388 {
1389 num4++;
1390 }
1391 if (num2 > 0 && item2.
IsGuest())
1392 {
1395 }
1396 continue;
1397 }
1398 if (num2 > 0)
1399 {
1401 item2.
SetAI(goalWork);
1403 {
1404 (goalWork as
GoalWork).FindWork(item2);
1405 }
1408 item2.
SetAI(goalWork);
1410 {
1411 (goalWork as
GoalWork).FindWork(item2);
1412 }
1414 }
1417 {
1419 }
1420 }
1421 List<Thing> list2 = new List<Thing>();
1423 {
1425 {
1426 list2.Add(thing);
1427 }
1428 }
1429 if (num4 >= list2.Count)
1430 {
1431 return;
1432 }
1433 for (int j = num4; j < list2.Count; j++)
1434 {
1435 if (
EClass.
rnd(200) <= HourSinceLastActive)
1436 {
1438 AddCard(chara, list2.RandomItem().pos);
1440 chara.c_originalHostility = c_originalHostility;
1441 }
1442 }
1443 }
1444
1446 {
1450 bool flag = zone ==
null || zone.lv > base.
lv;
1451 if (IsRegion)
1452 {
1454 {
1456 if (GetZoneAt(topZone.
x, topZone.
y) !=
null)
1457 {
1459 }
1460 }
1461 }
1463 {
1465 }
1467 {
1468 enterState = RegionEnterState;
1469 }
1471 {
1473 }
1474 float rate = zoneTransition?.
ratePos ?? (-1f);
1475 if (IsPCFaction)
1476 {
1478 {
1480 if (spot != null)
1481 {
1483 if (nearestPoint !=
null && nearestPoint.
IsValid)
1484 {
1485 return nearestPoint;
1486 }
1487 }
1488 }
1489 }
1490 while (true)
1491 {
1492 switch (enterState)
1493 {
1495 return new Point(zoneTransition.
x, zoneTransition.
z);
1497 {
1499 {
1501 {
1503 if (traitTeleporter != null)
1504 {
1506 }
1507 if (traitTeleporter !=
null && !zoneTransition.
idTele.IsEmpty() && zoneTransition.
idTele == traitTeleporter.
id.IsEmpty(traitTeleporter.
GetParam(3)))
1508 {
1510 }
1511 }
1512 }
1514 {
1516 {
1518 }
1519 }
1521 if (randomThing2 != null)
1522 {
1524 }
1526 }
1530 {
1532 {
1534 {
1536 {
1538 }
1539 }
1541 if (randomThing != null)
1542 {
1544 }
1545 }
1548 {
1550 if (thing != null)
1551 {
1553 }
1554 }
1556 if (thing != null)
1557 {
1559 }
1561 if (thing != null)
1562 {
1564 }
1565 if (base.lv == 0)
1566 {
1567 goto IL_04da;
1568 }
1569 flag = base.lv <= 0;
1570 break;
1571 }
1574 if (map.config.embarkX != 0)
1575 {
1576 return new Point(map.config.embarkX, map.config.embarkY);
1577 }
1578 return map.GetCenterPos().GetNearestPoint(allowBlock: false, allowChara: false);
1580 return map.bounds.GetTopPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1582 return map.bounds.GetRightPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1584 return map.bounds.GetBottomPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1586 return map.bounds.GetLeftPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1592 {
1593 return new Point(map.config.embarkX, map.config.embarkY);
1594 }
1595 return new Point(zoneTransition.
x, zoneTransition.
z);
1597 return GetRandomVisitPos(c);
1599 flag = true;
1600 break;
1602 flag = false;
1603 break;
1604 }
1605 break;
1606 IL_04da:
1608 }
1610 {
1612 {
1613 if (c != null && enterState != 0)
1614 {
1615 c.
SetDir(traitNewZone.owner.dir);
1616 }
1617 return traitNewZone.GetExitPos();
1618 }
1619 }
1621 {
1622 if (thing6.
trait is
TraitNewZone traitNewZone2 && ((flag && traitNewZone2.IsUpstairs) || (!flag && traitNewZone2.IsDownstairs)))
1623 {
1624 if (c != null && enterState != 0)
1625 {
1626 c.
SetDir(traitNewZone2.owner.dir);
1627 }
1628 return traitNewZone2.GetExitPos();
1629 }
1630 }
1631 return GetRandomVisitPos(c);
1632 }
1633
1635 {
1637 if (
EClass.
rnd(3) == 0 && map.rooms.listRoom.Count > 0)
1638 {
1639 point = map.rooms.listRoom.RandomItem().points.RandomItem();
1640 }
1641 if (point ==
null &&
EClass.
rnd(4) != 0)
1642 {
1644 if (ie.Count() > 0)
1645 {
1647 }
1648 }
1649 if (point == null)
1650 {
1651 point = map.bounds.GetRandomSurface(centered:
false, walkable:
true, !IsPCFaction && !(
this is
Zone_Civilized)) ?? map.bounds.
GetRandomPoint();
1652 }
1654 }
1655
1656 public void AddGlobalCharasOnActivate()
1657 {
1658 Point spawnPosPC =
null;
1660 {
1661 spawnPosPC = GetSpawnPos(
EClass.
pc);
1662 }
1663 if (spawnPosPC == null)
1664 {
1665 spawnPosPC = map.GetCenterPos();
1666 }
1668 {
1670 }
1673 {
1675 {
1676 continue;
1677 }
1679 {
1682 }
1683 else
1684 {
1686 {
1687 continue;
1688 }
1690 {
1691 c.isRestrained = false;
1692 }
1694 {
1695 Point pos = (c.IsPC ? spawnPosPC : (c.IsPCParty ? spawnPosPC.
GetNearestPoint(allowBlock:
false, allowChara:
false, allowInstalled:
true, ignoreCenter:
true) : GetSpawnPos(c)));
1697 {
1699 {
1700 pos.
Set(spawnPosPC);
1701 }
1703 {
1706 {
1708 {
1710 return true;
1711 }
1712 return false;
1713 }, allowBlock: false, EClass.pc.party.members.Count >= 12, allowInstalled: true, ignoreCenter: true, EClass._zone.IsRegion ? 2 : 6))
1714 {
1715 pos.
Set(spawnPosPC);
1716 }
1717 }
1718 }
1720 c.global.transition = null;
1721 }
1722 map.charas.Add(c);
1723 map.AddCardOnActivate(c);
1724 }
1725 }
1727 {
1728 Point nearestPoint = spawnPosPC.
GetNearestPoint(allowBlock:
false, allowChara:
false, allowInstalled:
true, ignoreCenter:
true);
1729 item.enemy = null;
1730 item.pos.Set(nearestPoint);
1731 map.charas.Add(
item);
1732 map.AddCardOnActivate(
item);
1733 }
1735 }
1736
1737 public void Deactivate()
1738 {
1739 if (!IsUserZone && !IsPCFaction && map != null)
1740 {
1741 List<Thing> list = new List<Thing>();
1743 {
1745 {
1746 list.Add(thing);
1747 }
1748 }
1750 {
1751 foreach (
Thing item in map.props.stocked.Things.Concat(map.props.roaming.Things))
1752 {
1753 if (
item.IsContainer)
1754 {
1756 {
1758 {
1759 list.Add(thing2);
1760 }
1761 }
1762 }
1764 {
1766 }
1767 }
1768 }
1769 if (list.Count > 0)
1770 {
1771 Msg.
Say(
"pick_valuable");
1772 foreach (
Thing item2
in list)
1773 {
1774 Msg.
Say(
"pick_valuable2", item2);
1776 }
1777 }
1778 }
1780 {
1781 base.isPeace = false;
1782 }
1783 OnBeforeDeactivate();
1784 if (IsPCFaction)
1785 {
1786 foreach (
Chara member
in branch.members)
1787 {
1789 }
1790 }
1793 map.OnDeactivate();
1795 EClass.game.activeZone = null;
1796 if (IsInstance)
1797 {
1798 UnloadMap();
1799 base.isGenerated = false;
1800 }
1801 if (forceRegenerate)
1802 {
1803 UnloadMap();
1804 }
1805 OnDeactivate();
1806 }
1807
1808 public void OnKillGame()
1809 {
1811 {
1813 {
1815 }
1816 }
1817 }
1818
1819 public void UnloadMap()
1820 {
1821 map = null;
1822 if (bp != null)
1823 {
1824 bp.map = null;
1825 }
1826 if (branch != null)
1827 {
1828 branch.OnUnloadMap();
1829 }
1830 Debug.Log(
"Unloaded Map:" +
this);
1831 }
1832
1833 public void ClaimZone(
bool debug =
false,
Point pos =
null)
1834 {
1838 branch.OnCreate(this);
1839 if (base.icon == 0)
1840 {
1841 base.icon = 332;
1842 }
1843 instance = null;
1844 base.dateExpire = 0;
1846 Register();
1848 {
1849 thing.isNPCProperty = false;
1850 }
1853 if (debug)
1854 {
1855 for (int i = 0; i < 7; i++)
1856 {
1859 branch.AddMemeber(chara);
1860 }
1861 }
1862 else
1863 {
1868 if (pos == null)
1869 {
1871 }
1874 }
1875 base.idPrefix = 0;
1877 {
1879 }
1881 {
1884 }
1885 }
1886
1887 public void AbandonZone()
1888 {
1891 {
1894 {
1896 }
1897 });
1899 SetMainFaction(null);
1901 }
1902
1903 public bool CanDestroy()
1904 {
1906 {
1907 return false;
1908 }
1909 if (IsInstance)
1910 {
1911 return true;
1912 }
1913 bool flag = false;
1914 switch (id)
1915 {
1916 case "cave_dragon":
1918 {
1919 flag = true;
1920 }
1921 break;
1922 case "cave_yeek":
1924 {
1925 flag = true;
1926 }
1927 break;
1928 case "cave_mino":
1930 {
1931 flag = true;
1932 }
1933 break;
1934 case "cave_dead":
1936 {
1937 flag = true;
1938 }
1939 break;
1940 }
1941 Zone topZone = GetTopZone();
1942 if (!flag)
1943 {
1945 {
1946 return false;
1947 }
1948 if (!base.isRandomSite && !(
this is
Zone_Field) && (topZone ==
null || topZone ==
this || topZone.
FindDeepestZone() ==
this))
1949 {
1950 return false;
1951 }
1952 }
1954 {
1955 return false;
1956 }
1958 {
1960 if (zone !=
null && zone.
GetTopZone() ==
this)
1961 {
1962 return false;
1963 }
1964 }
1965 return true;
1966 }
1967
1968 public override void _OnBeforeSave()
1969 {
1970 if (CanDestroy())
1971 {
1972 Debug.Log(
"Deleting Zone:" +
this);
1973 if (!destryoed)
1974 {
1975 Destroy();
1976 }
1977 }
1978 else if (map != null)
1979 {
1980 Debug.Log(
"Saving Zone:" +
this);
1981 map.Save(base.pathSave);
1982 if (!base.isMapSaved)
1983 {
1984 base.isMapSaved = true;
1986 IO.
CopyDir(pathTemp +
"Texture Replace", base.pathSave +
"/Texture Replace");
1987 }
1988 if (!IsActiveZone)
1989 {
1990 UnloadMap();
1991 }
1992 }
1993 }
1994
1995 public override void OnLoad()
1996 {
1997 if (branch != null)
1998 {
1999 branch.SetOwner(this);
2000 }
2001 events.OnLoad(this);
2002 }
2003
2004 public override void Destroy()
2005 {
2006 children.ForeachReverse(delegate(
Spatial z)
2007 {
2009 });
2010 if (map != null)
2011 {
2012 UnloadMap();
2013 }
2014 if (parent != null && parent.IsRegion && instance == null)
2015 {
2017 }
2019 destryoed = true;
2020 base.isGenerated = false;
2021 }
2022
2023 public void ClearZones(
Zone current =
null)
2024 {
2025 if (map != null)
2026 {
2027 UnloadMap();
2028 }
2029 base.isGenerated = false;
2030 Zone topZone = GetTopZone();
2031 if (topZone != this)
2032 {
2034 return;
2035 }
2036 children.ForeachReverse(delegate(
Spatial c)
2037 {
2038 if (c != current)
2039 {
2041 }
2042 });
2043 }
2044
2045 public void OnChildNumChange(
Card c)
2046 {
2047 }
2048
2050 {
2051 return this;
2052 }
2053
2054 public Zone GetTopZone()
2055 {
2056 if (parent == null || parent.IsRegion)
2057 {
2058 return this;
2059 }
2060 return parent as
Zone;
2061 }
2062
2063 public Card AddCardSplinkle(
Card t,
Point center,
int radius = 4)
2064 {
2066 for (int i = 0; i < 1000; i++)
2067 {
2071 {
2072 return AddCard(t, point);
2073 }
2074 }
2075 return AddCard(t, center);
2076 }
2077
2078 public Chara AddChara(
string id,
int x,
int z)
2079 {
2081 }
2082
2084 {
2085 return AddChara(
id, p.
x, p.
z);
2086 }
2087
2088 public Card AddThing(
string id,
int x,
int z)
2089 {
2091 }
2092
2093 public Card AddThing(
string id,
Point p)
2094 {
2095 return AddThing(
id, p.
x, p.
z);
2096 }
2097
2099 {
2100 return AddCard(t, point.
x, point.
z);
2101 }
2102
2104 {
2105 return AddCard(t, 0, 0);
2106 }
2107
2108 public Card AddCard(
Card t,
int x,
int z)
2109 {
2111 {
2113 }
2114 t.parent = this;
2116 if (chara != null)
2117 {
2118 chara.currentZone = this;
2120 }
2121 if (IsActiveZone)
2122 {
2123 map.OnCardAddedToZone(t, x, z);
2125 {
2127 }
2128 ignoreSpawnAnime = false;
2129 }
2131 {
2133 chara.hasSpawned = true;
2134 }
2135 return t;
2136 }
2137
2138 public void RemoveCard(
Card t)
2139 {
2140 if (IsActiveZone)
2141 {
2142 map.OnCardRemovedFromZone(t);
2143 }
2144 t.parent = null;
2146 {
2147 t.Chara.currentZone = null;
2148 }
2150 {
2152 }
2154 {
2156 }
2157 }
2158
2159 public T GetRandomSpot<T>() where T :
Trait
2160 {
2162 }
2163
2164 public bool TryAddThingInSpot<T>(
Thing t,
bool useContainer =
true) where T :
Trait
2165 {
2167 if (randomThing == null)
2168 {
2170 return false;
2171 }
2173 {
2174 List<Thing> list = new List<Thing>();
2176 {
2177 foreach (
Card item2
in item.ListCards())
2178 {
2180 {
2181 list.Add(item2.
Thing);
2182 }
2183 }
2184 }
2185 if (TryAddThingInSharedContainer(t, list, add: true, msg: false, null, sharedOnly: false))
2186 {
2187 return true;
2188 }
2189 }
2191 return true;
2192 }
2193
2194 public List<Thing> TryListThingsInSpot<T>(Func<Thing, bool> func =
null) where T :
TraitSpot
2195 {
2196 List<T> list = new List<T>();
2197 List<Thing> list2 = new List<Thing>();
2199 {
2201 {
2202 list.Add(thing.
trait as T);
2203 }
2204 }
2205 foreach (T
item in list)
2206 {
2207 foreach (
Point item2
in item.ListPoints(
null, onlyPassable:
false))
2208 {
2210 {
2212 {
2213 continue;
2214 }
2215 if (thing2.
things.Count == 0)
2216 {
2217 if (IsValid(thing2))
2218 {
2219 list2.Add(thing2);
2220 }
2221 continue;
2222 }
2224 {
2225 list2.Add(item3);
2226 }
2227 }
2228 }
2229 }
2230 return list2;
2231 bool IsValid(
Thing t)
2232 {
2233 if (func != null && !func(t))
2234 {
2235 return false;
2236 }
2237 return true;
2238 }
2239 }
2240
2241 public bool TryAddThingInSharedContainer(
Thing t, List<Thing> containers =
null,
bool add =
true,
bool msg =
false,
Chara chara =
null,
bool sharedOnly =
true)
2242 {
2244 int priority = -1;
2247 {
2249 }
2250 if (containers == null)
2251 {
2253 }
2254 if (SearchDest() != null)
2255 {
2256 return true;
2257 }
2258 if (dest == null)
2259 {
2260 return false;
2261 }
2262 if (add)
2263 {
2264 if (msg)
2265 {
2267 }
2269 }
2270 return true;
2272 {
2273 foreach (
Thing container
in containers)
2274 {
2275 Thing thing = container;
2277 {
2279 }
2281 {
2283 if (windowSaveData != null)
2284 {
2286 {
2287 continue;
2288 }
2291 {
2294 {
2295 continue;
2296 }
2297 }
2299 {
2301 {
2302 bool flag2 = false;
2303 foreach (
int cat
in windowSaveData.
cats)
2304 {
2306 {
2307 flag2 = true;
2308 break;
2309 }
2310 }
2311 if (!flag2)
2312 {
2313 continue;
2314 }
2315 }
2316 else if (windowSaveData.
flag.HasFlag(flag))
2317 {
2318 continue;
2319 }
2320 }
2321 priority = windowSaveData.
priority;
2322 }
2323 else
2324 {
2325 if (priority != -1)
2326 {
2327 continue;
2328 }
2329 priority = 0;
2330 }
2331 dest = thing;
2332 }
2333 }
2334 return null;
2335 }
2336 }
2337
2338 public bool TryAddThing(
Thing target,
Point p,
bool destroyIfFail =
false)
2339 {
2340 int num = 0;
2342 {
2344 {
2346 {
2348 {
2349 return true;
2350 }
2351 num++;
2352 }
2353 }
2354 }
2355 if (num == 0 || !destroyIfFail)
2356 {
2358 return true;
2359 }
2361 return false;
2362 }
2363
2364 public Thing TryGetThingFromSharedContainer(Func<Thing, bool> func)
2365 {
2367 {
2369 {
2371 if (thing != null)
2372 {
2373 return thing;
2374 }
2375 }
2376 }
2377 return null;
2378 }
2379
2381 {
2382 List<T> list = new List<T>();
2384 {
2386 {
2387 list.Add(thing2.
trait as T);
2388 }
2389 }
2390 foreach (T
item in list)
2391 {
2392 foreach (
Point item2
in item.ListPoints(
null, onlyPassable:
false))
2393 {
2395 {
2397 {
2398 continue;
2399 }
2400 if (thing3.
things.Count == 0)
2401 {
2402 if (IsValid(thing3, insideContainer: false))
2403 {
2404 return thing3;
2405 }
2406 continue;
2407 }
2409 if (thing != null)
2410 {
2411 return thing;
2412 }
2413 }
2414 }
2415 }
2416 return null;
2417 bool IsValid(
Thing t,
bool insideContainer)
2418 {
2420 {
2421 return false;
2422 }
2423 return true;
2424 }
2425 }
2426
2428 {
2429 string text = IdProfile;
2430 if (text.IsEmpty())
2431 {
2433 if (base.lv != 0)
2434 {
2435 text = ((base.lv < 0) ? "Underground" : "Sky");
2436 }
2437 else if (region != null)
2438 {
2441 if (bp != null)
2442 {
2443 name =
Lang.
GetList(
"zone_" + text.Split(
'/')[1]).RandomItem();
2445 for (int i = 0; i < 3; i++)
2446 {
2447 for (int j = 0; j < 3; j++)
2448 {
2450 }
2451 }
2452 if (text == "Random/R_Shore")
2453 {
2454 base.isBeach = true;
2455 }
2456 }
2457 }
2458 else
2459 {
2460 text = "Random";
2461 }
2462 idProfile = text;
2463 }
2465 }
2466
2467 public void CreateBP()
2468 {
2470 bp.Create();
2471 bp.genSetting.seed = base.Seed;
2472 OnCreateBP();
2473 }
2474
2475 public virtual void OnCreateBP()
2476 {
2477 }
2478
2479 public void Generate()
2480 {
2481 base.isGenerated = true;
2482 if (bp == null)
2483 {
2484 CreateBP();
2485 }
2486 if (bp.map == null)
2487 {
2488 bp.GenerateMap(this);
2489 }
2490 map.SetZone(this);
2492 bool flag = IdBiome == "Sand" || IdBiome == "Water" || IsUnderwater;
2493 if (flag)
2494 {
2495 int num = 1 +
EClass.
rnd((IdBiome ==
"Water") ? 3 : 2);
2496 for (int i = 0; i < num; i++)
2497 {
2500 {
2501 Thing t =
ThingGen.
Create(
"pearl_oyster",
new string[3] {
"wood_birch",
"poplar",
"coralwood" }.RandomItem(), ContentLv);
2503 }
2504 }
2506 for (int j = 0; j < num; j++)
2507 {
2510 {
2512 }
2513 }
2515 {
2517 if (!randomSurface3.
HasObj)
2518 {
2520 }
2521 }
2522 }
2523 if (IsUnderwater)
2524 {
2525 for (
int l = 0; l < 30 +
EClass.
rnd(30); l++)
2526 {
2528 }
2533 if (IsNefia)
2534 {
2536 if (num3 > 0)
2537 {
2543 }
2544 }
2546 {
2547 int num6 = 137;
2548 foreach (
Point point
in r.points)
2549 {
2551 {
2552 map.
SetObj(point.
x, point.
z, num6);
2556 {
2558 }
2559 }
2560 }
2561 return false;
2562 });
2564 {
2565 int num5 = 136;
2566 foreach (
Point point2
in r.points)
2567 {
2569 {
2571 }
2572 }
2573 return false;
2574 });
2576 {
2577 int idFloor = 121;
2578 foreach (
Point point3
in r.points)
2579 {
2581 }
2582 return false;
2583 });
2584 }
2585 if (zone_Field != null)
2586 {
2588 {
2590 for (int m = 0; m < num4; m++)
2591 {
2594 {
2597 }
2598 }
2599 }
2601 {
2602 SpawnAltar();
2603 }
2604 TrySpawnFollower();
2606 {
2609 {
2611 }
2612 }
2613 if (base.Tile.isRoad)
2614 {
2616 {
2618 }
2619 }
2620 }
2621 map.plDay = CreatePlaylist(ref map._plDay,
EClass.
Sound.GetPlaylist(IDPlayList) ??
EClass.
Sound.GetPlaylist(
"Day"));
2622 }
2623
2624 public void TrySpawnFollower()
2625 {
2628 {
2629 return;
2630 }
2633 {
2634 return;
2635 }
2641 {
2643 if (row != null)
2644 {
2646 }
2647 }
2649 for (
int i = 0; i < 3 +
EClass.
rnd(4); i++)
2650 {
2655 }
2656 }
2657
2658 public void SpawnAltar()
2659 {
2661 {
2662 if (r.points.Count <= 4)
2663 {
2664 return false;
2665 }
2666 map.poiMap.OccyupyPOI(r.points[0]);
2667 List<Point> points = r.points;
2669 "altarPoint".lang(randomReligion.NameDomain.lang());
2674 for (
int i = 0; i < 2 +
EClass.
rnd(2); i++)
2675 {
2678 }
2680 {
2682 }
2684 {
2685 if (
item.x % 3 == 0 &&
item.z % 2 == 0 &&
item != points[0] && !
item.Equals(points[0].Front) &&
item.Installed ==
null)
2686 {
2687 thing = ThingGen.Create("pillar1");
2688 EClass._zone.AddCard(thing, item).Install();
2689 }
2691 item.SetFloor(3, 6);
2692 }
2693 return true;
2694 });
2695 }
2696
2697 public virtual void OnGenerateMap()
2698 {
2699 if (MakeEnemiesNeutral)
2700 {
2702 {
2704 {
2706 chara.hostility = hostility2;
2707 }
2708 }
2709 }
2710 if (PrespawnRate != 0f && !IsSkyLevel)
2711 {
2712 for (int i = 0; i < (int)((float)MaxSpawn * PrespawnRate); i++)
2713 {
2714 SpawnMob();
2715 }
2716 }
2717 TryGenerateOre();
2718 TryGenerateBigDaddy();
2719 TryGenerateEvolved();
2720 TryGenerateShrine();
2721 }
2722
2723 public void TryGenerateOre()
2724 {
2725 if (OreChance <= 0f)
2726 {
2727 return;
2728 }
2730 {
2731 byte b = 18;
2732 string group = "ore";
2733 if (EClass.rnd(5) == 0)
2734 {
2735 b++;
2736 group = "gem";
2737 }
2739 foreach (
Point point in r.points)
2740 {
2741 if (point.sourceBlock.ContainsTag("ore"))
2742 {
2743 map.SetObj(point.x, point.z, randomMaterial.id, b, 1, 0);
2744 }
2745 }
2746 return false;
2747 });
2748 }
2749
2750 public Chara TryGenerateEvolved(
bool force =
false,
Point p =
null)
2751 {
2754 {
2755 return null;
2756 }
2758 for (
int i = 0; i < 2 +
EClass.
rnd(2); i++)
2759 {
2761 }
2764 {
2766 }
2767 return chara;
2768 }
2769
2770 public void TryGenerateBigDaddy()
2771 {
2773 {
2775 List<string> list = new List<string> { "big_daddy", "big_daddy2" };
2776 list.Shuffle();
2777 Spawn(list[0], spawnPos);
2779 {
2780 Spawn(list[1], spawnPos.
GetNearestPoint(allowBlock:
false, allowChara:
false));
2781 }
2782 Msg.
Say(
"sign_bigdaddy");
2783 }
2784 void Spawn(
string id,
Point pos)
2785 {
2786 int num = (int)((long)DangerLv * 125L / 100);
2787 if (num >= 30)
2788 {
2790 {
2791 lv = num
2792 });
2793 }
2796 {
2798 }
2800 {
2802 }
2804 }
2805 }
2806
2807 public void TryGenerateShrine()
2808 {
2810 for (int i = 0; i < 3; i++)
2811 {
2814 {
2815 continue;
2816 }
2818 if (randomSpace == null)
2819 {
2820 continue;
2821 }
2825 {
2826 continue;
2827 }
2832 {
2835 }
2836 else
2837 {
2839 }
2840 }
2842 }
2843
2844 public void ResetHostility()
2845 {
2847 {
2849 {
2850 chara.c_originalHostility = (
Hostility)0;
2851 }
2854 {
2856 }
2857 }
2858 }
2859
2860 public virtual void OnGenerateRooms(
BaseMapGen gen)
2861 {
2862 }
2863
2865 {
2867 for (int i = 0; i < tries; i++)
2868 {
2871 {
2872 continue;
2873 }
2874 switch (type)
2875 {
2877 {
2879 if (list.Count > 0)
2880 {
2881 list.Shuffle();
2883 {
2884 List<Point> list2 =
item.ListPoints(
null, onlyPassable:
true, allowChara:
false);
2885 if (list2.Count > 0)
2886 {
2887 return list2.RandomItem();
2888 }
2889 }
2890 }
2893 {
2894 continue;
2895 }
2896 break;
2897 }
2900 {
2901 continue;
2902 }
2903 break;
2904 }
2905 return point;
2906 }
2907 return null;
2908 }
2909
2910 public Chara SpawnMob(
string id,
Point pos =
null)
2911 {
2913 {
2914 id = id
2915 });
2916 }
2917
2919 {
2920 if (setting == null)
2921 {
2923 }
2924 if (pos == null)
2925 {
2926 pos = GetSpawnPos(setting.position, setting.tries);
2927 if (pos == null)
2928 {
2930 if (pos == null)
2931 {
2932 return null;
2933 }
2934 }
2935 }
2937 if (IsUnderwater &&
EClass.
rnd(15) != 0)
2938 {
2940 }
2942 if (setting.idSpawnList != null)
2943 {
2945 }
2947 {
2949 }
2951 {
2952 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);
2953 }
2955 {
2957 }
2959 {
2960 spawnList =
SpawnList.
Get(IsInstance ?
"c_neutral_war" :
"c_neutral");
2961 }
2963 {
2966 {
2967 ShouldPass = (
SourceChara.Row s) => (!(s.hostility !=
"") || (!s.tag.Contains(
"cat") && !s.race_row.tag.Contains(
"cat"))) ? true :
false
2968 }));
2969 }
2970 else
2971 {
2973 {
2975 {
2976 if (s.hostility != "")
2977 {
2978 return false;
2979 }
2980 return s.biome == biome.name || s.biome.IsEmpty();
2981 }
2982 });
2983 }
2984 int num = ((setting.dangerLv == -1) ? DangerLv : setting.dangerLv);
2986 {
2988 idEle = setting.idEle
2989 };
2990 int num2 = ((setting.filterLv == -1) ? num : setting.filterLv);
2992 {
2993 num2 = ((num - 1) % 50 + 5) * 150 / 100;
2994 if (num2 >= 20 &&
EClass.
rnd(100) < num2)
2995 {
2996 num2 = num;
2997 }
2998 }
3001 {
3004 }
3005 long num3 = ((setting.fixedLv == -1) ? cardRow.
LV : setting.fixedLv);
3006 bool flag = setting.fixedLv != -1 || DangerLvBoost > 0;
3007 num3 += setting.addLv;
3009 {
3010 num3 = (50L + (long)cardRow.
LV) * Mathf.Max(1, (num - 1) / 50);
3011 flag = true;
3012 }
3013 num3 += DangerLvBoost;
3014 if (setting.rarity ==
Rarity.Random && cardRow.
quality == 0)
3015 {
3017 {
3018 cardBlueprint.rarity =
Rarity.Legendary;
3019 num3 = num3 * 125 / 100;
3020 }
3021 }
3022 else
3023 {
3024 cardBlueprint.rarity = setting.rarity;
3025 }
3026 if (setting.isBoss)
3027 {
3028 num3 = num3 * 150 / 100;
3029 }
3030 if (setting.isEvolved)
3031 {
3032 num3 = num3 * 2 + 20;
3033 }
3034 if (num3 != cardRow.
LV)
3035 {
3036 cardBlueprint.lv = (int)Mathf.Min(num3, 100000000f);
3037 }
3040 if (!flag)
3041 {
3042 chara.isScaled = false;
3043 }
3044 AddCard(chara, pos);
3045 if (setting.forcedHostility.HasValue)
3046 {
3047 Hostility c_originalHostility = (chara.hostility = setting.forcedHostility.Value);
3048 chara.c_originalHostility = c_originalHostility;
3049 }
3050 else
3051 {
3053 {
3054 case "unicorn":
3056 {
3058 }
3059 break;
3060 case "santa":
3061 case "silverwolf":
3062 case "twintail":
3063 case "test17":
3065 {
3067 }
3069 {
3071 }
3072 break;
3073 }
3074 }
3075 if (setting.isBoss)
3076 {
3078 }
3079 if (setting.isEvolved)
3080 {
3081 chara.c_bossType =
BossType.Evolved;
3082 }
3083 if (DangerLv >= 20 && !IsPCFaction && !IsTown &&
EClass.
rnd(200) == 0)
3084 {
3086 }
3087 return chara;
3088 }
3089
3090 public bool HasField(int idEle)
3091 {
3092 return fieldElements.Has(idEle);
3093 }
3094
3095 public void SetFieldEffect(int idEle, int a, int duration = 0)
3096 {
3097 fieldElements.SetBase(idEle, a, duration);
3098 }
3099
3100 public void RemoveFieldEffect(int idEle)
3101 {
3102 fieldElements.Remove(idEle);
3103 }
3104
3105 public void RefreshElectricity()
3106 {
3107 dirtyElectricity = false;
3108 bool flag = GetSoilCost() > MaxSoil;
3109 base.electricity = elements.Value(2201) * 10 + BaseElectricity;
3111 {
3113 {
3115 }
3116 }
3117 if (!flag)
3118 {
3120 {
3122 {
3123 base.electricity += 20;
3124 }
3125 });
3126 }
3128 {
3130 {
3132 }
3133 }
3134 }
3135
3136 public int GetElectricity(bool cost = false)
3137 {
3138 bool flag = GetSoilCost() > MaxSoil;
3139 int sum = 0;
3141 {
3143 {
3144 continue;
3145 }
3146 if (cost)
3147 {
3149 {
3151 }
3152 }
3154 {
3156 }
3157 }
3158 if (!cost)
3159 {
3160 sum += elements.Value(2201) * 10 + BaseElectricity;
3161 if (!flag)
3162 {
3164 {
3166 {
3167 sum += 20;
3168 }
3169 });
3170 }
3171 }
3172 return sum;
3173 }
3174
3175 public void SetBGM(List<int> ids, bool refresh = true, float fadeDuration = 0f)
3176 {
3177 map._plDay.Clear();
3178 if (ids.Count > 0)
3179 {
3180 foreach (int id in ids)
3181 {
3182 if (id != -1)
3183 {
3184 map._plDay.Add(id);
3185 }
3186 }
3187 }
3188 UnityEngine.Object.DestroyImmediate(map.plDay);
3189 map.plDay = null;
3190 RefreshPlaylist();
3191 if (!refresh)
3192 {
3193 return;
3194 }
3195 if (fadeDuration > 0f)
3196 {
3197 EClass.
Sound.StopBGM(fadeDuration, playLastBGM:
false, delegate
3198 {
3200 {
3201 RefreshBGM();
3202 }
3203 });
3204 }
3205 else
3206 {
3208 RefreshBGM();
3209 }
3210 }
3211
3212 public void SetBGM(int id = -1, bool refresh = true, float fadeDuration = 0f)
3213 {
3214 SetBGM(new List<int> { id }, refresh, fadeDuration);
3215 }
3216
3217 public void RefreshPlaylist()
3218 {
3219 if (map.plDay == null)
3220 {
3221 map.plDay = CreatePlaylist(ref map._plDay,
EClass.
Sound.GetPlaylist(IDPlayList));
3222 }
3223 }
3224
3225 public void ResetPlaylist()
3226 {
3227 map._plDay.Clear();
3228 UnityEngine.Object.DestroyImmediate(map.plDay);
3229 map.plDay = null;
3230 RefreshPlaylist();
3231 }
3232
3233 public void RefreshBGM()
3234 {
3236 {
3237 return;
3238 }
3239 RefreshPlaylist();
3240 Playlist playlist = map.plDay;
3242 {
3243 if (
item.playlist !=
null)
3244 {
3245 playlist =
item.playlist;
3246 }
3247 }
3248 if (IDPlaylistOverwrite != null)
3249 {
3250 playlist =
EClass.
Sound.GetPlaylist(IDPlaylistOverwrite);
3251 }
3253 {
3255 if (room !=
null && room.
lot !=
null && room.
lot.
idBGM != 0)
3256 {
3258 if (playlist.list[0].data?.id != room.
lot.
idBGM)
3259 {
3261 playlist.Reset();
3263 {
3265 }
3266 }
3267 }
3268 }
3271 }
3272
3273 public Playlist CreatePlaylist(ref List<int> list, Playlist mold = null)
3274 {
3275 return ModUtil.CreatePlaylist(ref list, mold);
3276 }
3277
3278 public Chara FindChara(
string id)
3279 {
3280 return map.charas.Find((
Chara c) => c.
id ==
id);
3281 }
3282
3283 public Chara FindChara(
int uid)
3284 {
3285 return map.charas.Find((
Chara c) => c.
uid == uid);
3286 }
3287
3288 public Chara FindDeadChara(
string id)
3289 {
3290 return map.deadCharas.Find((
Chara c) => c.
id ==
id);
3291 }
3292
3293 public int GetDeepestLv()
3294 {
3295 int max = base.lv;
3296 return GetDeepestLv(ref max);
3297 }
3298
3299 public int GetDeepestLv(ref int max)
3300 {
3301 if (Mathf.Abs(base.lv) > Mathf.Abs(max))
3302 {
3303 max = base.lv;
3304 }
3305 foreach (
Spatial child
in children)
3306 {
3307 (child as
Zone).GetDeepestLv(ref max);
3308 }
3309 return max;
3310 }
3311
3312 public List<Element> ListLandFeats()
3313 {
3314 if (landFeats == null)
3315 {
3316 landFeats = new List<int>();
3318 string[] listBase = IDBaseLandFeat.Split(',');
3319 string[] array = listBase;
3320 foreach (string text in array)
3321 {
3322 if (!text.IsEmpty())
3323 {
3325 }
3326 }
3327 if (listBase.Length == 1)
3328 {
3330 {
3331 if (e.category != "landfeat" || e.chance == 0)
3332 {
3333 return false;
3334 }
3335 bool flag = true;
3336 string[] tag = e.tag;
3337 foreach (string text2 in tag)
3338 {
3339 if (text2.StartsWith("bf"))
3340 {
3341 flag = false;
3342 if (listBase[0] == text2)
3343 {
3344 flag = true;
3345 break;
3346 }
3347 }
3348 }
3349 return flag ? true : false;
3350 }).ToList();
3352 landFeats.Add(row.
id);
3353 list.Remove(row);
3355 landFeats.Add(row.
id);
3356 }
3358 }
3359 List<Element> list2 = new List<Element>();
3360 foreach (int landFeat in landFeats)
3361 {
3363 }
3364 return list2;
3365 }
3366
3368 {
3369 ZipFile zipFile = ZipFile.Read(path);
3370 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3371 zipFile.ExtractAll(pathTemp);
3372 zipFile.Dispose();
3374 }
3375
3376 public void Export(
string path,
PartialMap partial =
null,
bool usermap =
false)
3377 {
3378 if (subset != null)
3379 {
3380 SE.Beep();
3381 return;
3382 }
3383 try
3384 {
3386 {
3387 name = name,
3388 usermap = usermap
3389 };
3391 if (!map.config.retainDecal)
3392 {
3393 map.ClearRainAndDecal();
3394 }
3395 map.Save(
IO.
TempPath +
"/", zoneExportData, partial);
3396 map.ExportMetaData(
IO.
TempPath +
"/", Path.GetFileNameWithoutExtension(path), partial);
3397 if (partial == null)
3398 {
3400 }
3402 using (ZipFile zipFile = new ZipFile())
3403 {
3404 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3406 zipFile.Save(path);
3407 zipFile.Dispose();
3408 }
3410 }
3411 catch (Exception ex)
3412 {
3413 EClass.
ui.Say(ex.Message +
":" + path);
3414 }
3415 }
3416
3417 public void ExportDialog(string dir = null)
3418 {
3420 {
3422 if (!
string.IsNullOrEmpty(text))
3423 {
3424 Export(text);
3426 }
3427 });
3428 }
3429
3430 public void ImportDialog(string dir = null)
3431 {
3433 {
3435 if (array.Length != 0)
3436 {
3437 Zone_User zone_User = SpatialGen.Create("user", EClass.world.region, register: true) as Zone_User;
3438 zone_User.path = array[0];
3439 Thing thing = ThingGen.Create("teleporter");
3440 thing.c_uidZone = zone_User.uid;
3441 EClass._zone.AddCard(thing, EClass.pc.pos);
3442 }
3443 });
3444 }
3445
3446 public static bool IsImportValid(string path)
3447 {
3448 try
3449 {
3451 }
3452 catch (Exception ex)
3453 {
3455 return false;
3456 }
3457 }
3458
3459 public void Export()
3460 {
3462 string text = pathExport;
3464 Export(text);
3465 Msg.
Say(
"Exported Map:" + text);
3466 }
3467
3469 {
3470 }
3471
3472 public void OnInspect()
3473 {
3474 }
3475
3476 public int GetSortVal()
3477 {
3478 if (IsPCFaction)
3479 {
3480 return -10000000 + base.uid;
3481 }
3483 {
3484 return -8000000 + base.uid;
3485 }
3487 {
3488 return -9000000 + base.uid;
3489 }
3491 {
3492 return -7000000 + base.uid;
3493 }
3495 {
3496 return 1000000 + base.uid;
3497 }
3498 return base.uid;
3499 }
3500
3501 public Chara AddRandomVisitor(
bool guest =
false)
3502 {
3504 if (random == null)
3505 {
3506 return null;
3507 }
3511 {
3514 if (chara != null)
3515 {
3516 AddCard(chara, point);
3517 Msg.
Say(
"guestArrive", chara);
3519 }
3520 }
3521 else
3522 {
3524 AddCard(chara, point);
3526 }
3527 return chara;
3528 }
3529
3531 {
3532 if (base.IsPlayerFaction)
3533 {
3535 }
3536 events.OnSimulateHour();
3538 {
3540 {
3542 {
3544 }
3545 }
3547 }
3549 {
3551 });
3552 foreach (
Thing sucker
in Suckers)
3553 {
3555 }
3556 Suckers.Clear();
3557 if (RespawnRate != 0f)
3558 {
3559 int num = 0;
3560 foreach (
Chara chara
in map.charas)
3561 {
3563 {
3564 num++;
3565 }
3566 }
3567 if (num < MaxRespawn)
3568 {
3569 for (int i = 0; i < RespawnPerHour; i++)
3570 {
3571 SpawnMob();
3572 }
3573 }
3574 }
3576 {
3577 RainWater();
3578 }
3580 {
3581 GrowPlants(date);
3582 }
3583 }
3584
3586 {
3587 if (base.IsPlayerFaction)
3588 {
3589 branch.OnSimulateDay(date);
3590 }
3591 }
3592
3594 {
3595 if (base.IsPlayerFaction)
3596 {
3597 branch.OnSimulateMonth(date);
3598 }
3600 {
3602 }
3603 }
3604
3605 public void RainWater()
3606 {
3608 {
3609 return;
3610 }
3612 {
3614 {
3615 c.isWatered = true;
3616 }
3617 });
3618 }
3619
3621 {
3623 int weedChance = 1;
3625 {
3627 }
3629 {
3631 }
3632 if (num)
3633 {
3634 HashSet<int> hashSet = new HashSet<int>();
3636 {
3638 {
3639 continue;
3640 }
3641 foreach (
Point item in traitSpotFarm.ListPoints(
null, onlyPassable:
false))
3642 {
3643 hashSet.Add(
item.index);
3644 }
3645 }
3646 Perform(hashSet);
3647 EClass.player.isAutoFarming = false;
3648 Perform(hashSet);
3649 }
3650 else
3651 {
3652 Perform(null);
3653 }
3654 void Perform(HashSet<int> farmMap)
3655 {
3658 {
3659 if (farmMap != null)
3660 {
3662 {
3663 if (!farmMap.Contains(c.index))
3664 {
3665 return;
3666 }
3667 }
3668 else if (farmMap.Contains(c.
index))
3669 {
3670 return;
3671 }
3672 }
3674 {
3675 c.decal = 0;
3676 }
3678 {
3680 {
3681 bool flag = false;
3682 if (!EClass.player.isAutoFarming && c.growth.HaltGrowth() && (c.IsFarmField || c.IsTopWater) && (!isWinter || !date.IsRealTime))
3683 {
3684 flag = true;
3685 }
3686 PlantData plantData = map.TryGetPlant(c);
3687 if (!flag && (plantData ==
null || plantData.fert >= 0))
3688 {
3689 c.TryGrow(date);
3690 }
3692 {
3693 if (date.sunMap == null)
3694 {
3695 date.BuildSunMap();
3696 }
3698 {
3699 c.growth.Perish();
3700 }
3701 }
3702 }
3703 else if (c.
detail !=
null)
3704 {
3705 c.Things.ForeachReverse(delegate(Thing t)
3706 {
3707 if (t.IsInstalled && t.trait is TraitSeed && !t.isSale)
3708 {
3709 (t.trait as TraitSeed).TrySprout(force: false, sucker: false, date);
3710 }
3711 });
3712 }
3714 {
3717 {
3719 }
3720 }
3721 }
3722 c.isWatered = false;
3723 });
3724 }
3725 }
3726
3727 public Zone GetZoneAt(
int _x,
int _y)
3728 {
3729 if (IsRegion)
3730 {
3731 foreach (
Spatial child
in children)
3732 {
3733 if (!(child is
Zone_Field) && _x == child.
x && _y == child.
y)
3734 {
3735 return child as
Zone;
3736 }
3737 }
3738 }
3739 foreach (
Spatial child2
in children)
3740 {
3741 if (_x == child2.
x && _y == child2.
y)
3742 {
3743 return child2 as
Zone;
3744 }
3745 }
3746 return null;
3747 }
3748
3749 public bool IsCrime(
Chara c,
Act act)
3750 {
3752 {
3753 return true;
3754 }
3755 return false;
3756 }
3757
3758 public void RefreshCriminal()
3759 {
3760 bool flag = EClass.player.IsCriminal && HasLaw && !AllowCriminal && !IsPCFaction;
3763 {
3765 {
3766 chara.hostility = hostility;
3768 {
3770 }
3771 }
3772 }
3773 }
3774
3775 public void RefreshListCitizen()
3776 {
3777 if (base.lv != 0)
3778 {
3779 return;
3780 }
3781 dictCitizen.Clear();
3782 foreach (
Chara item in map.charas.Concat(map.deadCharas))
3783 {
3784 if (
item.trait.IsCitizen && !
item.IsGlobal && !
item.isSubsetCard)
3785 {
3787 }
3788 }
3789 }
3790
3791 public virtual void SetAlarm(bool enable)
3792 {
3793 base.isAlarmSet = enable;
3794 if (enable)
3795 {
3797 {
3799 {
3801 }
3802 }
3805 SE.Play("alarm");
3806 return;
3807 }
3809 {
3811 {
3813 }
3814 }
3815 }
3816
3817 public void ModInfluence(int a)
3818 {
3819 base.influence += a;
3820 if (a > 0)
3821 {
3822 Msg.
Say(
"gainInfluence", Name, a.ToString() ??
"");
3823 }
3825 }
3826
3827 public void ModDevelopment(int a)
3828 {
3829 base.development += a;
3830 if (a > 0)
3831 {
3832 Msg.
Say(
"gainDevelopment", Name, a.ToString() ??
"");
3833 }
3834 }
3835
3836 public void UpdateQuests(bool force = false)
3837 {
3838 if (!IsPCFaction && (!(
this is
Zone_Town) || base.lv != 0))
3839 {
3840 return;
3841 }
3842 Debug.Log(
"Updating Quest:" + force);
3844 int num = 0;
3845 foreach (
Chara item in map.charas.Concat(map.deadCharas))
3846 {
3848 {
3849 if (
item.quest.IsExpired || completedQuests.Contains(
item.quest.uid) || force)
3850 {
3851 item.quest = null;
3852 }
3853 else
3854 {
3855 num++;
3856 }
3857 }
3858 }
3860 {
3861 return;
3862 }
3864 int maxQuest = 3;
3866 {
3867 maxQuest = 4 + EClass.rnd(4);
3868 });
3869 completedQuests.Clear();
3871 List<Tuple<string, int>> listTag = new List<Tuple<string, int>>();
3874 {
3875 array = new string[9] { "supply/8", "deliver/7", "food/8", "escort/4", "deliver/4", "monster/0", "war/0", "farm/0", "music/0" };
3876 }
3877 string[] array2 = array;
3878 for (int i = 0; i < array2.Length; i++)
3879 {
3880 string[] array3 = array2[i].Split('/');
3881 listTag.Add(new Tuple<string, int>(array3[0], array3[1].ToInt()));
3882 }
3883 for (int j = 0; j < map.charas.Count * 2; j++)
3884 {
3885 if (num > maxQuest)
3886 {
3887 break;
3888 }
3889 if (num > 15)
3890 {
3891 break;
3892 }
3893 Chara chara = map.charas.RandomItem();
3895 {
3896 continue;
3897 }
3899 {
3900 int num2 = 1;
3901 foreach (Tuple<string, int> item2 in listTag)
3902 {
3903 if (a.tags.Contains(item2.Item1))
3904 {
3905 num2 = item2.Item2;
3906 break;
3907 }
3908 }
3910 {
3911 num2 = 0;
3912 }
3913 return a.chance * num2;
3914 });
3916 {
3918 num++;
3919 }
3920 }
3921 }
3922
3923 public List<Chara> ListMinions(
Chara c)
3924 {
3925 List<Chara> list = new List<Chara>();
3927 {
3929 {
3930 list.Add(chara);
3931 }
3932 }
3933 return list;
3934 }
3935
3936 public int CountMinions(
Chara c)
3937 {
3938 int num = 0;
3940 {
3942 {
3943 num++;
3944 }
3945 }
3946 return num;
3947 }
3948
3949 public int GetSoilCost()
3950 {
3951 int i = 0;
3953 {
3955 });
3956 return i / 10;
3957 }
3958
3959 public void SpawnLostItems()
3960 {
3961 for (
int i = 0; i < 2 +
EClass.
rnd(4); i++)
3962 {
3963 Point point = GetPos();
3964 if (point == null)
3965 {
3966 continue;
3967 }
3969 {
3971 thing.isLostProperty = true;
3973 int num2 = (thing.c_lockLv =
EClass.
rndHalf(Mathf.Min(base.development / 10 + 10, 50)));
3976 {
3978 }
3979 else
3980 {
3982 }
3984 }
3985 else
3986 {
3988 }
3989 }
3990 static Point GetPos()
3991 {
3992 for (int j = 0; j < 10; j++)
3993 {
3996 {
3997 return randomPoint;
3998 }
3999 }
4000 return null;
4001 }
4002 }
4003
4004 public void ApplyBackerPet(bool draw)
4005 {
4006 bool flag =
this is
Zone_Yowyn && base.lv == -1;
4008 list.Shuffle();
4010 {
4012 {
4013 if (EClass.player.doneBackers.Contains(a.id))
4014 {
4015 list.Remove(a);
4016 }
4017 });
4018 }
4020 {
4022 {
4023 continue;
4024 }
4026 {
4028 {
4029 continue;
4030 }
4031 if (chara.
id !=
"follower")
4032 {
4034 }
4035 }
4037 {
4038 continue;
4039 }
4041 {
4042 if (
item.chara == chara.
id)
4043 {
4046 break;
4047 }
4048 }
4049 }
4050 }
4051
4052 public FortuneRollData GetOrCreateFortuneRollData(
bool refresh =
true)
4053 {
4054 if (fortuneRoll == null)
4055 {
4058 }
4059 if (refresh || fortuneRoll.count == 0)
4060 {
4061 fortuneRoll.Refresh();
4062 }
4063 return fortuneRoll;
4064 }
4065}
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)