Elin Decompiled Documentation EA 23.333 Myaightly Patch 1
Loading...
Searching...
No Matches
Zone.cs File Reference

Go to the source code of this file.

Classes

class  Zone
 
class  Zone.PortalReturnData
 

Functions

 [instance initializer]
 

Variables

$ Can tloadmap
 

Function Documentation

◆ [instance initializer]()

RefreshHat.[instance initializer]

Variable Documentation

◆ tloadmap

$ Can tloadmap

Definition at line 1124 of file Zone.cs.

1125{
1126 if (idHat != null && EClass.world.date.IsExpired(base.dateHat))
1127 {
1128 idHat = null;
1129 base.dateHat = 0;
1130 }
1131 sourceHat = ((idHat != null) ? EClass.sources.cards.map[idHat] : ((IDHat != null) ? EClass.sources.cards.map[IDHat] : null));
1132 }
1133
1134 public void OnVisit()
1135 {
1136 if (EClass.world.date.IsExpired(base.dateRevive))
1137 {
1138 ResetHostility();
1139 Revive();
1140 List<Chara> list = new List<Chara>();
1141 foreach (Chara chara in EClass._map.charas)
1142 {
1143 chara.TryRestock(onCreate: false);
1144 if (!chara.IsPCFaction)
1145 {
1146 chara.c_fur = 0;
1147 }
1148 if (chara.IsMinion && chara.master != null && !chara.master.IsPCParty)
1149 {
1150 list.Add(chara);
1151 }
1152 }
1153 foreach (Chara item in list)
1154 {
1155 item.Destroy();
1156 }
1157 }
1158 if (!EClass.game.isLoading)
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();
1172 if (EClass.Branch != null)
1173 {
1175 }
1176 base.lastActive = EClass.world.date.GetRaw();
1177 if (!EClass.game.isLoading)
1178 {
1179 base.visitCount++;
1180 }
1181 base.version = EClass.core.version.GetInt();
1182 if (HasField(10000))
1183 {
1184 Tutorial.Reserve("field");
1185 }
1186 }
1187
1188 public void RefreshDeathSentense()
1189 {
1190 foreach (Chara chara in EClass._map.charas)
1191 {
1192 if (chara.HasCondition<ConDeathSentense>())
1193 {
1194 chara.GetCondition<ConDeathSentense>().TryRemove();
1195 }
1196 }
1197 }
1198
1199 public void Revive()
1200 {
1201 base.dateRevive = EClass.world.date.GetRaw() + 1440 * EClass.setting.balance.dateRevive;
1202 if (ShouldAutoRevive)
1203 {
1204 foreach (Chara deadChara in map.deadCharas)
1205 {
1206 if (deadChara.trait.CanAutoRevive && deadChara.CanRevive())
1207 {
1208 deadChara.Revive();
1210 {
1211 deadChara.RemoveBacker();
1212 }
1213 EClass._zone.AddCard(deadChara, (deadChara.orgPos != null && deadChara.orgPos.IsInBounds) ? deadChara.orgPos : deadChara.pos);
1214 }
1215 }
1216 }
1217 foreach (Chara value in EClass.game.cards.globalCharas.Values)
1218 {
1219 if (value.isDead && value.CanRevive() && value.homeZone == this)
1220 {
1221 value.Revive();
1222 Point point = GetSpawnPos(value);
1223 if (value.orgPos != null && value.orgPos.IsInBounds)
1224 {
1225 point = value.orgPos.GetNearestPoint() ?? point;
1226 }
1227 EClass._zone.AddCard(value, point);
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 }
1243 if (EClass._map.version.IsBelow(0, 23, 226))
1244 {
1245 SetBGM(121, refresh: false);
1246 }
1247 int num = 0;
1248 foreach (Chara chara in EClass._map.charas)
1249 {
1250 if (chara.id == "cat_silver" && !chara.IsPCFaction)
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 {
1287 if (!EClass.game.isLoading && base.visitCount > 0)
1288 {
1289 if (Boss != null && IsNefia)
1290 {
1291 Msg.Say("bossLeave", Boss.Name.ToTitleCase(), EClass._zone.Name);
1294 }
1295 int num = Mathf.Clamp(MinsSinceLastActive, 1, 10000);
1296 foreach (Chara chara2 in EClass._map.charas)
1297 {
1298 if (chara2.hp < 0)
1299 {
1300 chara2.hp = 0;
1301 }
1302 if (!chara2.IsPCParty)
1303 {
1304 if (chara2.mana.value < 0)
1305 {
1306 chara2.mana.value = 0;
1307 }
1308 if (chara2.stamina.value < 0)
1309 {
1310 chara2.stamina.value = 0;
1311 }
1312 }
1313 if (num > 60)
1314 {
1315 chara2.resistCon = null;
1316 }
1317 if (chara2.rarity >= Rarity.Legendary && !chara2.IsPCFaction && num > 0)
1318 {
1319 Msg.ignoreAll = true;
1320 chara2.Cure(CureType.Boss, 20 + num * 10);
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);
1323 chara2.stamina.Mod(Mathf.Max(1, chara2.stamina.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");
1334 VirtualDate virtualDate = new VirtualDate(HourSinceLastActive);
1335 List<Chara> list = EClass._map.charas.ToList();
1336 int num2 = HourSinceLastActive / 24;
1337 int num3 = 0;
1338 if (num2 > 0)
1339 {
1340 foreach (Chara item in list)
1341 {
1342 if (!item.IsPCParty)
1343 {
1344 item.OnSleep(200, num2);
1345 if (item.conSleep != null)
1346 {
1347 item.conSleep.Kill();
1348 }
1349 if (EClass.rnd(EClass.world.date.IsNight ? 20 : 200) == 0 && !item.IsPCFaction)
1350 {
1351 item.AddCondition<ConSleep>(1000 + EClass.rnd(1000), force: true);
1352 }
1353 if (item.things.Count > 20)
1354 {
1355 item.ClearInventory(ClearInventoryType.Purge);
1356 }
1357 }
1358 }
1359 }
1360 VirtualDate.current = virtualDate;
1361 for (int i = 0; i < HourSinceLastActive; i++)
1362 {
1363 virtualDate.SimulateHour();
1364 if (!virtualDate.IsWinter)
1365 {
1366 num3++;
1367 }
1368 }
1369 EClass._map.things.ForeachReverse(delegate(Thing t)
1370 {
1371 t.DecayNatural(HourSinceLastActive);
1372 });
1373 VirtualDate.current = null;
1374 if (!IsPCFaction)
1375 {
1376 return;
1377 }
1378 int num4 = 0;
1379 foreach (Chara item2 in list)
1380 {
1381 if (item2.IsPCParty)
1382 {
1383 continue;
1384 }
1385 if (!item2.IsHomeMember())
1386 {
1387 if (item2.id == "bee")
1388 {
1389 num4++;
1390 }
1391 if (num2 > 0 && item2.IsGuest())
1392 {
1393 item2.ChooseNewGoal();
1394 item2.ai.SimulateZone(num2);
1395 }
1396 continue;
1397 }
1398 if (num2 > 0)
1399 {
1400 Goal goalWork = item2.GetGoalWork();
1401 item2.SetAI(goalWork);
1402 if (goalWork is GoalWork)
1403 {
1404 (goalWork as GoalWork).FindWork(item2);
1405 }
1406 item2.ai.SimulateZone(num2);
1407 goalWork = item2.GetGoalHobby();
1408 item2.SetAI(goalWork);
1409 if (goalWork is GoalWork)
1410 {
1411 (goalWork as GoalWork).FindWork(item2);
1412 }
1413 item2.ai.SimulateZone(num2);
1414 }
1415 item2.ChooseNewGoal();
1416 if (item2.conSuspend == null)
1417 {
1418 item2.ai.OnSimulatePosition();
1419 }
1420 }
1421 List<Thing> list2 = new List<Thing>();
1422 foreach (Thing thing in map.things)
1423 {
1424 if (thing.IsInstalled && thing.trait is TraitBeekeep)
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 {
1437 Chara chara = CharaGen.Create("bee");
1438 AddCard(chara, list2.RandomItem().pos);
1439 Hostility c_originalHostility = (chara.hostility = Hostility.Neutral);
1440 chara.c_originalHostility = c_originalHostility;
1441 }
1442 }
1443 }
1444
1445 public Point GetSpawnPos(Chara c, ZoneTransition.EnterState destState = ZoneTransition.EnterState.Auto)
1446 {
1447 ZoneTransition zoneTransition = c.global?.transition;
1448 Zone zone = zoneTransition?.lastZone;
1449 ZoneTransition.EnterState enterState = zoneTransition?.state ?? destState;
1450 bool flag = zone == null || zone.lv > base.lv;
1451 if (IsRegion)
1452 {
1453 if (zone != null && !EClass.player.simulatingZone)
1454 {
1455 Zone topZone = zone.GetTopZone();
1456 if (GetZoneAt(topZone.x, topZone.y) != null)
1457 {
1458 return new Point(topZone.mapX, topZone.mapY);
1459 }
1460 }
1461 }
1462 else if (c.IsPC && EClass.player.lastZonePos != null && zone != null && zone.IsRegion && (enterState == ZoneTransition.EnterState.Left || enterState == ZoneTransition.EnterState.Right || enterState == ZoneTransition.EnterState.Top || enterState == ZoneTransition.EnterState.Bottom))
1463 {
1464 return EClass.player.lastZonePos;
1465 }
1466 if (enterState == ZoneTransition.EnterState.Region)
1467 {
1468 enterState = RegionEnterState;
1469 }
1470 if (this is Zone_Kapul && enterState == ZoneTransition.EnterState.Left)
1471 {
1472 enterState = ZoneTransition.EnterState.Right;
1473 }
1474 float rate = zoneTransition?.ratePos ?? (-1f);
1475 if (IsPCFaction)
1476 {
1477 if ((uint)(enterState - 3) <= 4u || enterState == ZoneTransition.EnterState.Return)
1478 {
1480 if (spot != null)
1481 {
1482 Point nearestPoint = (spot.trait as TraitSpotGuidePC).GetRandomPoint((Point p) => !p.IsBlocked && !p.Equals(spot.pos)).GetNearestPoint();
1483 if (nearestPoint != null && nearestPoint.IsValid)
1484 {
1485 return nearestPoint;
1486 }
1487 }
1488 }
1489 }
1490 while (true)
1491 {
1492 switch (enterState)
1493 {
1494 case ZoneTransition.EnterState.UndergroundOrSky:
1495 return new Point(zoneTransition.x, zoneTransition.z);
1496 case ZoneTransition.EnterState.Teleport:
1497 {
1498 foreach (Thing thing2 in map.things)
1499 {
1500 if (thing2.IsInstalled)
1501 {
1502 TraitTeleporter traitTeleporter = thing2.trait as TraitTeleporter;
1503 if (traitTeleporter != null)
1504 {
1505 Debug.Log(zoneTransition.idTele + "/" + traitTeleporter.id.IsEmpty(traitTeleporter.GetParam(3)) + "/" + traitTeleporter.GetParam(3));
1506 }
1507 if (traitTeleporter != null && !zoneTransition.idTele.IsEmpty() && zoneTransition.idTele == traitTeleporter.id.IsEmpty(traitTeleporter.GetParam(3)))
1508 {
1509 return thing2.pos.GetNearestPoint();
1510 }
1511 }
1512 }
1513 foreach (Thing thing3 in map.things)
1514 {
1515 if (thing3.IsInstalled && thing3.trait is TraitTeleporter traitTeleporter2 && traitTeleporter2.IsFor(zoneTransition.lastZone))
1516 {
1517 return thing3.pos.GetNearestPoint();
1518 }
1519 }
1520 Thing randomThing2 = EClass._map.props.installed.traits.GetRandomThing<TraitTeleporter>();
1521 if (randomThing2 != null)
1522 {
1523 return randomThing2.pos.GetNearestPoint();
1524 }
1525 goto case ZoneTransition.EnterState.Return;
1526 }
1527 case ZoneTransition.EnterState.Return:
1528 case ZoneTransition.EnterState.Elevator:
1529 case ZoneTransition.EnterState.Moongate:
1530 {
1531 if (enterState == ZoneTransition.EnterState.Elevator)
1532 {
1533 foreach (Thing thing4 in map.things)
1534 {
1535 if (thing4.IsInstalled && thing4.trait is TraitElevator traitElevator && traitElevator.IsFor(zoneTransition.lastZone))
1536 {
1537 return thing4.pos.GetNearestPoint();
1538 }
1539 }
1540 Thing randomThing = EClass._map.props.installed.traits.GetRandomThing<TraitElevator>();
1541 if (randomThing != null)
1542 {
1543 return randomThing.pos.GetNearestPoint();
1544 }
1545 }
1546 Thing thing = null;
1547 if (enterState == ZoneTransition.EnterState.Return && EClass.game.IsSurvival)
1548 {
1549 thing = map.props.installed.traits.GetRandomThing<TraitLandingPortal>();
1550 if (thing != null)
1551 {
1552 return thing.pos;
1553 }
1554 }
1555 thing = map.props.installed.traits.GetRandomThing<TraitWaystone>();
1556 if (thing != null)
1557 {
1558 return thing.pos.GetNearestPoint();
1559 }
1560 thing = map.props.installed.traits.GetRandomThing<TraitCoreZone>();
1561 if (thing != null)
1562 {
1563 return thing.pos.GetNearestPoint();
1564 }
1565 if (base.lv == 0)
1566 {
1567 goto IL_04da;
1568 }
1569 flag = base.lv <= 0;
1570 break;
1571 }
1572 case ZoneTransition.EnterState.Center:
1573 case ZoneTransition.EnterState.Encounter:
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);
1579 case ZoneTransition.EnterState.Top:
1580 return map.bounds.GetTopPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1581 case ZoneTransition.EnterState.Right:
1582 return map.bounds.GetRightPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1583 case ZoneTransition.EnterState.Bottom:
1584 return map.bounds.GetBottomPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1585 case ZoneTransition.EnterState.Left:
1586 return map.bounds.GetLeftPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1587 case ZoneTransition.EnterState.Dead:
1588 case ZoneTransition.EnterState.Exact:
1589 case ZoneTransition.EnterState.PortalReturn:
1590 case ZoneTransition.EnterState.Fall:
1591 if (zoneTransition.x == 0 && EClass._map.bounds.x != 0)
1592 {
1593 return new Point(map.config.embarkX, map.config.embarkY);
1594 }
1595 return new Point(zoneTransition.x, zoneTransition.z);
1596 case ZoneTransition.EnterState.RandomVisit:
1597 return GetRandomVisitPos(c);
1598 case ZoneTransition.EnterState.Down:
1599 flag = true;
1600 break;
1601 case ZoneTransition.EnterState.Up:
1602 flag = false;
1603 break;
1604 }
1605 break;
1606 IL_04da:
1607 enterState = ZoneTransition.EnterState.Center;
1608 }
1609 foreach (Thing thing5 in map.things)
1610 {
1611 if (thing5.trait is TraitNewZone { zone: not null } traitNewZone && zone != null && traitNewZone.zone.uid == zone.uid)
1612 {
1613 if (c != null && enterState != 0)
1614 {
1615 c.SetDir(traitNewZone.owner.dir);
1616 }
1617 return traitNewZone.GetExitPos();
1618 }
1619 }
1620 foreach (Thing thing6 in map.things)
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
1634 public Point GetRandomVisitPos(Chara c)
1635 {
1636 Point point = null;
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 {
1643 IEnumerable<Chara> ie = map.charas.Where((Chara t) => t.trait.ShopType != 0 && t.pos != null && t.pos.IsValid);
1644 if (ie.Count() > 0)
1645 {
1646 point = ie.RandomItem().pos.GetRandomPoint(3);
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 }
1653 return point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false) ?? EClass._map.GetCenterPos().GetNearestPoint();
1654 }
1655
1656 public void AddGlobalCharasOnActivate()
1657 {
1658 Point spawnPosPC = null;
1659 if (EClass.pc.currentZone == this)
1660 {
1661 spawnPosPC = GetSpawnPos(EClass.pc);
1662 }
1663 if (spawnPosPC == null)
1664 {
1665 spawnPosPC = map.GetCenterPos();
1666 }
1667 if (spawnPosPC.IsValid && EClass.pc.global.transition != null && spawnPosPC.HasBlock)
1668 {
1669 spawnPosPC = spawnPosPC.GetNearestPoint();
1670 }
1671 spawnPosPC = spawnPosPC.Clamp(useBounds: true).GetNearestPoint();
1672 foreach (Chara c in EClass.game.cards.globalCharas.Values)
1673 {
1674 if (c.currentZone != this)
1675 {
1676 continue;
1677 }
1678 if (c.parent is Chara)
1679 {
1680 Chara chara = c.parent as Chara;
1681 c.currentZone = chara.currentZone;
1682 }
1683 else
1684 {
1685 if (c.isDead)
1686 {
1687 continue;
1688 }
1689 if (c.isRestrained && c.currentZone == EClass.pc.currentZone && (!c.pos.IsValid || c.pos.FindThing<TraitShackle>() == null))
1690 {
1691 c.isRestrained = false;
1692 }
1693 if (c.global.transition != null)
1694 {
1695 Point pos = (c.IsPC ? spawnPosPC : (c.IsPCParty ? spawnPosPC.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: true, ignoreCenter: true) : GetSpawnPos(c)));
1696 if (c.IsPCParty && !c.IsPC)
1697 {
1698 if (c.host == EClass.pc)
1699 {
1700 pos.Set(spawnPosPC);
1701 }
1702 else if (pos.Equals(spawnPosPC) || !PathManager.Instance.IsPathClear(spawnPosPC, pos, c, 5))
1703 {
1704 c.pos.Set(spawnPosPC);
1705 if (!spawnPosPC.ForeachNearestPoint(delegate(Point p)
1706 {
1707 if (PathManager.Instance.IsPathClear(spawnPosPC, p, c, 10) && !p.Equals(spawnPosPC))
1708 {
1709 pos.Set(p);
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 }
1719 c.pos.Set(pos);
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>();
1742 foreach (Thing thing in map.things)
1743 {
1744 if (thing.rarity >= Rarity.Artifact && thing.HasTag(CTAG.godArtifact))
1745 {
1746 list.Add(thing);
1747 }
1748 }
1749 if (this is Zone_Tent)
1750 {
1751 foreach (Thing item in map.props.stocked.Things.Concat(map.props.roaming.Things))
1752 {
1753 if (item.IsContainer)
1754 {
1755 foreach (Thing thing2 in item.things)
1756 {
1757 if (thing2.trait is TraitTent)
1758 {
1759 list.Add(thing2);
1760 }
1761 }
1762 }
1763 if (item.trait is TraitTent)
1764 {
1765 list.Add(item);
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);
1775 EClass.pc.AddCard(item2);
1776 }
1777 }
1778 }
1780 {
1781 base.isPeace = false;
1782 }
1783 OnBeforeDeactivate();
1784 if (IsPCFaction)
1785 {
1786 foreach (Chara member in branch.members)
1787 {
1788 member.ValidateWorks();
1789 }
1790 }
1791 EClass.game.lastActiveZone = EClass.game.activeZone;
1792 base.lastActive = EClass.world.date.GetRaw();
1793 map.OnDeactivate();
1794 EClass.scene.Clear();
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 {
1810 foreach (Thing thing in map.things)
1811 {
1812 if (thing.renderer.hasActor)
1813 {
1814 thing.renderer.KillActor();
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 {
1836 SetMainFaction(EClass.pc.faction);
1837 branch = new FactionBranch();
1838 branch.OnCreate(this);
1839 if (base.icon == 0)
1840 {
1841 base.icon = 332;
1842 }
1843 instance = null;
1844 base.dateExpire = 0;
1845 SetInt(2, EClass.world.date.GetRaw());
1846 Register();
1847 foreach (Thing thing in map.things)
1848 {
1849 thing.isNPCProperty = false;
1850 }
1853 if (debug)
1854 {
1855 for (int i = 0; i < 7; i++)
1856 {
1857 Chara chara = CharaGen.CreateFromFilter("c_neutral");
1858 EClass._zone.AddCard(chara, EClass._map.bounds.GetRandomPoint().GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false));
1859 branch.AddMemeber(chara);
1860 }
1861 }
1862 else
1863 {
1864 Msg.Say("claimedZone");
1865 EClass.Branch.Log("claimedZone");
1866 EClass.Sound.Play("jingle_embark");
1867 EClass.pc.PlaySound("build");
1868 if (pos == null)
1869 {
1870 pos = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: true, allowInstalled: false);
1871 }
1872 Effect.Get("aura_heaven").Play(pos);
1873 EClass._zone.AddCard(ThingGen.Create("core_zone"), pos).SetPlaceState(PlaceState.installed);
1874 }
1875 base.idPrefix = 0;
1877 {
1878 EClass.player.spawnZone = EClass._zone;
1879 }
1881 {
1882 EClass._zone.SetBGM(new List<int> { 41, 90, 44, 43 });
1884 }
1885 }
1886
1887 public void AbandonZone()
1888 {
1889 FactionBranch destBranch = ((EClass.pc.homeBranch == branch) ? EClass.game.StartZone.branch : EClass.pc.homeBranch);
1890 branch.members.ForeachReverse(delegate(Chara m)
1891 {
1892 destBranch.AddMemeber(m);
1893 if (!m.IsPCParty)
1894 {
1895 m.MoveZone(destBranch.owner);
1896 }
1897 });
1899 SetMainFaction(null);
1900 base.dateExpire = EClass.world.date.GetRaw() + 10080;
1901 }
1902
1903 public bool CanDestroy()
1904 {
1905 if (IsActiveZone || IsPCFaction || EClass.player.simulatingZone)
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":
1917 if (!(this is Zone_DungeonDragon))
1918 {
1919 flag = true;
1920 }
1921 break;
1922 case "cave_yeek":
1923 if (!(this is Zone_DungeonYeek))
1924 {
1925 flag = true;
1926 }
1927 break;
1928 case "cave_mino":
1929 if (!(this is Zone_DungeonMino))
1930 {
1931 flag = true;
1932 }
1933 break;
1934 case "cave_dead":
1935 if (!(this is Zone_DungeonDead))
1936 {
1937 flag = true;
1938 }
1939 break;
1940 }
1941 Zone topZone = GetTopZone();
1942 if (!flag)
1943 {
1944 if (base.dateExpire == 0 || !EClass.world.date.IsExpired(base.dateExpire))
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 }
1953 if (EClass.pc.currentZone == null || EClass.pc.currentZone is Zone_Tent || topZone == EClass.pc.currentZone.GetTopZone() || (EClass.player.nextZone != null && topZone == EClass.player.nextZone.GetTopZone()))
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;
1985 IO.DeleteDirectory(base.pathSave + "Texture Replace");
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 {
2008 z.Destroy();
2009 });
2010 if (map != null)
2011 {
2012 UnloadMap();
2013 }
2014 if (parent != null && parent.IsRegion && instance == null)
2015 {
2016 EClass.scene.elomap.SetZone(base.x, base.y, null, updateMesh: true);
2017 }
2018 EClass.game.spatials.Remove(this);
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 {
2033 topZone.ClearZones(this);
2034 return;
2035 }
2036 children.ForeachReverse(delegate(Spatial c)
2037 {
2038 if (c != current)
2039 {
2040 c.Destroy();
2041 }
2042 });
2043 }
2044
2045 public void OnChildNumChange(Card c)
2046 {
2047 }
2048
2049 public ICardParent GetRoot()
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 {
2065 Point point = new Point(center);
2066 for (int i = 0; i < 1000; i++)
2067 {
2068 point.x = center.x + EClass.rnd(radius) - EClass.rnd(radius);
2069 point.z = center.z + EClass.rnd(radius) - EClass.rnd(radius);
2070 if (point.IsValid && !point.IsBlocked && !point.HasChara)
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 {
2080 return AddCard(CharaGen.Create(id), x, z) as Chara;
2081 }
2082
2083 public Chara AddChara(string id, Point p)
2084 {
2085 return AddChara(id, p.x, p.z);
2086 }
2087
2088 public Card AddThing(string id, int x, int z)
2089 {
2090 return AddCard(ThingGen.Create(id), x, z);
2091 }
2092
2093 public Card AddThing(string id, Point p)
2094 {
2095 return AddThing(id, p.x, p.z);
2096 }
2097
2098 public Card AddCard(Card t, Point point)
2099 {
2100 return AddCard(t, point.x, point.z);
2101 }
2102
2103 public Card AddCard(Card t)
2104 {
2105 return AddCard(t, 0, 0);
2106 }
2107
2108 public Card AddCard(Card t, int x, int z)
2109 {
2110 if (t.parent != null)
2111 {
2112 t.parent.RemoveCard(t);
2113 }
2114 t.parent = this;
2115 Chara chara = t.Chara;
2116 if (chara != null)
2117 {
2118 chara.currentZone = this;
2119 chara.SetAI(new NoGoal());
2120 }
2121 if (IsActiveZone)
2122 {
2123 map.OnCardAddedToZone(t, x, z);
2124 if (isStarted && t.isThing && t.placeState == PlaceState.roaming && !ignoreSpawnAnime)
2125 {
2126 t.PlayAnimeLoot();
2127 }
2128 ignoreSpawnAnime = false;
2129 }
2130 if (chara != null && EClass.player != null && !chara.hasSpawned)
2131 {
2132 EClass.player.codex.AddSpawn(chara.id);
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;
2145 if (t.isChara)
2146 {
2147 t.Chara.currentZone = null;
2148 }
2149 if (t.isThing && !t.trait.IDActorEx.IsEmpty())
2150 {
2152 }
2153 if (t.renderer.hasActor)
2154 {
2156 }
2157 }
2158
2159 public T GetRandomSpot<T>() where T : Trait
2160 {
2161 return EClass._map.props.installed.traits.GetRandomThing<T>() as T;
2162 }
2163
2164 public bool TryAddThingInSpot<T>(Thing t, bool useContainer = true) where T : Trait
2165 {
2166 Thing randomThing = EClass._map.props.installed.traits.GetRandomThing<T>();
2167 if (randomThing == null)
2168 {
2169 AddCard(t, EClass._map.bounds.GetRandomSurface());
2170 return false;
2171 }
2172 if (useContainer && (!t.IsContainer || t.things.Count == 0))
2173 {
2174 List<Thing> list = new List<Thing>();
2175 foreach (Point item in randomThing.trait.ListPoints(null, onlyPassable: false))
2176 {
2177 foreach (Card item2 in item.ListCards())
2178 {
2179 if (item2.IsContainer && !(item2.trait is TraitDeliveryChest))
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 }
2190 AddCard(t, randomThing.trait.GetRandomPoint());
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>();
2198 foreach (Thing thing in EClass._map.things)
2199 {
2200 if (thing.IsInstalled && thing.trait is T)
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 {
2209 foreach (Thing thing2 in item2.Things)
2210 {
2211 if (!thing2.IsInstalled)
2212 {
2213 continue;
2214 }
2215 if (thing2.things.Count == 0)
2216 {
2217 if (IsValid(thing2))
2218 {
2219 list2.Add(thing2);
2220 }
2221 continue;
2222 }
2223 foreach (Thing item3 in thing2.things.List((Thing _t) => IsValid(_t)))
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 {
2243 Thing dest = null;
2244 int priority = -1;
2245 ContainerFlag flag = t.category.GetRoot().id.ToEnum<ContainerFlag>();
2246 if (flag == ContainerFlag.none)
2247 {
2248 flag = ContainerFlag.other;
2249 }
2250 if (containers == null)
2251 {
2252 containers = EClass._map.props.installed.containers;
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 {
2266 chara.Say("putSharedItem", chara, t, dest.GetName(NameStyle.Full));
2267 }
2268 dest.AddThing(t);
2269 }
2270 return true;
2271 Thing SearchDest()
2272 {
2273 foreach (Thing container in containers)
2274 {
2275 Thing thing = container;
2276 if (thing.trait is TraitShippingChest)
2277 {
2279 }
2280 if ((!sharedOnly || thing.IsSharedContainer) && thing.c_lockLv <= 0 && (thing.things.Count < thing.things.MaxCapacity || thing.things.CanStack(t) != t))
2281 {
2282 Window.SaveData windowSaveData = thing.GetWindowSaveData();
2283 if (windowSaveData != null)
2284 {
2285 if (windowSaveData.priority <= priority || (windowSaveData.noRotten && t.IsDecayed) || (windowSaveData.onlyRottable && t.trait.Decay == 0))
2286 {
2287 continue;
2288 }
2290 if (windowSaveData.userFilter)
2291 {
2292 filterResult = windowSaveData.IsFilterPass(t.GetName(NameStyle.Full, 1));
2293 if (filterResult == Window.SaveData.FilterResult.Block)
2294 {
2295 continue;
2296 }
2297 }
2298 if (filterResult != Window.SaveData.FilterResult.PassWithoutFurtherTest)
2299 {
2300 if (windowSaveData.advDistribution)
2301 {
2302 bool flag2 = false;
2303 foreach (int cat in windowSaveData.cats)
2304 {
2305 if (t.category.uid == cat)
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;
2341 if (p.cell.detail != null)
2342 {
2343 foreach (Thing thing in p.cell.detail.things)
2344 {
2345 if (thing.placeState == PlaceState.roaming)
2346 {
2347 if (target.TryStackTo(thing))
2348 {
2349 return true;
2350 }
2351 num++;
2352 }
2353 }
2354 }
2355 if (num == 0 || !destroyIfFail)
2356 {
2357 EClass._zone.AddCard(target, p);
2358 return true;
2359 }
2360 target.Destroy();
2361 return false;
2362 }
2363
2364 public Thing TryGetThingFromSharedContainer(Func<Thing, bool> func)
2365 {
2366 foreach (Thing container in EClass._map.props.installed.containers)
2367 {
2368 if (container.IsSharedContainer)
2369 {
2370 Thing thing = container.things.Find(func);
2371 if (thing != null)
2372 {
2373 return thing;
2374 }
2375 }
2376 }
2377 return null;
2378 }
2379
2380 public Thing TryGetRestock<T>(string idCat) where T : TraitSpot
2381 {
2382 List<T> list = new List<T>();
2383 foreach (Thing thing2 in EClass._map.things)
2384 {
2385 if (thing2.IsInstalled && thing2.trait is T)
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 {
2394 foreach (Thing thing3 in item2.Things)
2395 {
2396 if (!thing3.IsInstalled || thing3.isSale)
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 }
2408 Thing thing = thing3.things.Find((Thing _t) => IsValid(_t, insideContainer: true));
2409 if (thing != null)
2410 {
2411 return thing;
2412 }
2413 }
2414 }
2415 }
2416 return null;
2417 bool IsValid(Thing t, bool insideContainer)
2418 {
2419 if (t.category.id != idCat || !TraitSalesTag.CanTagSale(t, insideContainer))
2420 {
2421 return false;
2422 }
2423 return true;
2424 }
2425 }
2426
2427 public ZoneProfile GetProfile()
2428 {
2429 string text = IdProfile;
2430 if (text.IsEmpty())
2431 {
2432 Region region = parent as Region;
2433 if (base.lv != 0)
2434 {
2435 text = ((base.lv < 0) ? "Underground" : "Sky");
2436 }
2437 else if (region != null)
2438 {
2440 text = EClass.scene.elomapActor.elomap.GetTileInfo(base.x, base.y).idZoneProfile;
2441 if (bp != null)
2442 {
2443 name = Lang.GetList("zone_" + text.Split('/')[1]).RandomItem();
2444 bp.surrounding = new EloMap.TileInfo[3, 3];
2445 for (int i = 0; i < 3; i++)
2446 {
2447 for (int j = 0; j < 3; j++)
2448 {
2449 bp.surrounding[j, i] = EClass.scene.elomapActor.elomap.GetTileInfo(base.x - 1 + j, base.y - 1 + i);
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 }
2464 return ZoneProfile.Load(text);
2465 }
2466
2467 public void CreateBP()
2468 {
2469 bp = new ZoneBlueprint();
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);
2491 Zone_Field zone_Field = this as Zone_Field;
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 {
2498 Point randomSurface = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2499 if (!randomSurface.HasObj && !randomSurface.HasThing)
2500 {
2501 Thing t = ThingGen.Create("pearl_oyster", new string[3] { "wood_birch", "poplar", "coralwood" }.RandomItem(), ContentLv);
2502 EClass._zone.AddCard(t, randomSurface).Install();
2503 }
2504 }
2505 num = 4 + EClass.rnd(5);
2506 for (int j = 0; j < num; j++)
2507 {
2508 Point randomSurface2 = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2509 if (!randomSurface2.HasObj && !randomSurface2.HasThing && (IsUnderwater || randomSurface2.cell.IsTopWaterAndNoSnow || EClass.rnd(6) == 0))
2510 {
2511 EClass._zone.AddCard(ThingGen.Create("70", -1, ContentLv), randomSurface2);
2512 }
2513 }
2514 for (int k = 0; k < EClass.rnd(EClass.rnd(base.isBeach ? 5 : 3) + 1); k++)
2515 {
2516 Point randomSurface3 = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2517 if (!randomSurface3.HasObj)
2518 {
2519 EClass._zone.AddCard(ThingGen.Create("bottle_message"), randomSurface3);
2520 }
2521 }
2522 }
2523 if (IsUnderwater)
2524 {
2525 for (int l = 0; l < 30 + EClass.rnd(30); l++)
2526 {
2527 SpawnMob(null, SpawnSetting.Fish());
2528 }
2529 Crawler crawler = Crawler.Create("pasture");
2530 int num2 = (EClass.debug.enable ? 3 : EClass.rnd(EClass.rnd(EClass.rnd(EClass.rnd(5) + 1) + 1) + 1));
2531 bool flag2 = this is Zone_Field;
2532 Thing seed = null;
2533 if (IsNefia)
2534 {
2535 int num3 = Mathf.Min(EClass._zone.DangerLv, EClass.pc.Evalue(286) * 2 / 3);
2536 if (num3 > 0)
2537 {
2539 Rand.SetSeed(EClass._zone.uid * 10 + num3);
2540 TraitSeed.LevelSeed(seed, (seed.trait as TraitSeed).row, num3);
2541 Rand.SetSeed();
2542 seed.elements.SetBase(2, EClass.curve(seed.encLV, 50, 10, 80));
2543 }
2544 }
2545 crawler.CrawlUntil(EClass._map, () => EClass._map.GetRandomPoint(), num2 + (flag2 ? 4 : 0), delegate(Crawler.Result r)
2546 {
2547 int num6 = 137;
2548 foreach (Point point in r.points)
2549 {
2550 if (!point.cell.isModified && !point.HasThing && !point.HasBlock && !point.HasObj)
2551 {
2552 map.SetObj(point.x, point.z, num6);
2553 int idx = 3 + ((EClass.rnd(3) == 0) ? 1 : 0) + ((EClass.rnd(3) == 0) ? (-1) : 0) + ((EClass.rnd(3) == 0) ? (-1) : 0);
2554 point.growth.SetStage(idx);
2555 if (seed != null)
2556 {
2557 EClass._map.AddPlant(point, seed);
2558 }
2559 }
2560 }
2561 return false;
2562 });
2563 crawler.CrawlUntil(tries: EClass.rnd(EClass.rnd(5) + 1) + 1 + (flag2 ? 20 : 0), map: EClass._map, onStart: () => EClass._map.GetRandomPoint(), canComplete: delegate(Crawler.Result r)
2564 {
2565 int num5 = 136;
2566 foreach (Point point2 in r.points)
2567 {
2568 if (!point2.cell.isModified && !point2.HasThing && !point2.HasBlock && !point2.HasObj)
2569 {
2570 map.SetObj(point2.x, point2.z, num5, 1, EClass.rnd(4));
2571 }
2572 }
2573 return false;
2574 });
2575 crawler.CrawlUntil(tries: EClass.rnd(EClass.rnd(10) + 1) + 3 + (flag2 ? 40 : 0), map: EClass._map, onStart: () => EClass._map.GetRandomPoint(), canComplete: delegate(Crawler.Result r)
2576 {
2577 int idFloor = 121;
2578 foreach (Point point3 in r.points)
2579 {
2580 map.SetFloor(point3.x, point3.z, 97, idFloor, Mathf.Clamp(4 - r.startPos.Distance(point3) + EClass.rnd(3) - EClass.rnd(3), 0, 3));
2581 }
2582 return false;
2583 });
2584 }
2585 if (zone_Field != null)
2586 {
2587 if (EClass.rnd(3) == 0)
2588 {
2589 int num4 = EClass.rnd(2);
2590 for (int m = 0; m < num4; m++)
2591 {
2592 Point randomSurface4 = EClass._map.bounds.GetRandomSurface();
2593 if (!randomSurface4.HasObj && !randomSurface4.HasThing)
2594 {
2595 Card t2 = ThingGen.Create("chest3").ChangeMaterial(biome.style.matDoor);
2596 EClass._zone.AddCard(t2, randomSurface4).Install();
2597 }
2598 }
2599 }
2600 if (EClass.rnd(8) == 0)
2601 {
2602 SpawnAltar();
2603 }
2604 TrySpawnFollower();
2605 if (!flag && EClass.rnd(EClass.debug.enable ? 1 : 10) == 0)
2606 {
2607 Point randomSurface5 = EClass._map.bounds.GetRandomSurface();
2608 if (randomSurface5.IsValid)
2609 {
2610 EClass._zone.AddCard(CharaGen.Create("priest"), randomSurface5);
2611 }
2612 }
2613 if (base.Tile.isRoad)
2614 {
2615 for (int n = 0; n < EClass.rnd(4); n++)
2616 {
2617 EClass._zone.SpawnMob(map.GetCenterPos().GetRandomPointInRadius(2, 6, requireLos: false, allowChara: false), SpawnSetting.HomeGuest(EClass._zone.DangerLv));
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 {
2626 bool flag = EClass.pc.HasCondition<ConDrawBacker>();
2627 if (!EClass.debug.enable && EClass.rnd(flag ? 3 : 20) != 0)
2628 {
2629 return;
2630 }
2631 Point randomSurface = EClass._map.bounds.GetRandomSurface();
2632 if (!randomSurface.IsValid)
2633 {
2634 return;
2635 }
2636 Chara c = CharaGen.Create("follower");
2637 EClass._zone.AddCard(c, randomSurface);
2638 (EClass._zone.AddThing("gallows", randomSurface).Install().trait as TraitShackle).Restrain(c);
2639 c.c_rescueState = RescueState.WaitingForRescue;
2640 if (EClass.rnd(flag ? 1 : 2) == 0 || EClass.debug.enable)
2641 {
2643 if (row != null)
2644 {
2645 c.ApplyBacker(row.id);
2646 }
2647 }
2648 Religion faith = EClass.game.religions.dictAll.Values.Where((Religion a) => a != c.faith).RandomItem();
2649 for (int i = 0; i < 3 + EClass.rnd(4); i++)
2650 {
2651 Chara chara = CharaGen.Create("fanatic");
2652 chara.SetFaith(faith);
2653 Point point = randomSurface.GetRandomPoint(4) ?? randomSurface.GetNearestPoint();
2654 EClass._zone.AddCard(chara, point);
2655 }
2656 }
2657
2658 public void SpawnAltar()
2659 {
2660 EClass.core.refs.crawlers.start.CrawlUntil(map, () => map.poiMap.GetCenterCell().GetCenter(), 1, delegate(Crawler.Result r)
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;
2668 Religion randomReligion = EClass.game.religions.GetRandomReligion();
2669 "altarPoint".lang(randomReligion.NameDomain.lang());
2670 Thing thing = ThingGen.Create("altar");
2671 (thing.trait as TraitAltar).SetDeity(randomReligion.id);
2672 Chara t = CharaGen.Create("twintail");
2673 EClass._zone.AddCard(t, points.RandomItem());
2674 for (int i = 0; i < 2 + EClass.rnd(2); i++)
2675 {
2676 Chara t2 = CharaGen.Create("twintail");
2677 EClass._zone.AddCard(t2, points.RandomItem());
2678 }
2679 if (points[0].Installed == null)
2680 {
2681 EClass._zone.AddCard(thing, points[0]).Install();
2682 }
2683 foreach (Point item in points)
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 }
2690 item.SetObj();
2691 item.SetFloor(3, 6);
2692 }
2693 return true;
2694 });
2695 }
2696
2697 public virtual void OnGenerateMap()
2698 {
2699 if (MakeEnemiesNeutral)
2700 {
2701 foreach (Chara chara in EClass._map.charas)
2702 {
2703 if (!chara.IsGlobal && chara.hostility < Hostility.Neutral && chara.OriginalHostility < Hostility.Friend)
2704 {
2705 Hostility hostility2 = (chara.c_originalHostility = Hostility.Neutral);
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 }
2729 Crawler.Create("ore").CrawlUntil(tries: EClass.rnd((int)((float)(map.bounds.Width * map.bounds.Height / 200 + 1) * OreChance + 2f)), map: EClass._map, onStart: () => EClass._map.bounds.GetRandomPoint(), canComplete: delegate(Crawler.Result r)
2730 {
2731 byte b = 18;
2732 string group = "ore";
2733 if (EClass.rnd(5) == 0)
2734 {
2735 b++;
2736 group = "gem";
2737 }
2738 SourceMaterial.Row randomMaterial = MATERIAL.GetRandomMaterial(DangerLv, group);
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 {
2752 float num = EvolvedChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f);
2753 if (!force && num <= EClass.rndf(1f))
2754 {
2755 return null;
2756 }
2757 Chara chara = SpawnMob(p, SpawnSetting.Evolved());
2758 for (int i = 0; i < 2 + EClass.rnd(2); i++)
2759 {
2760 chara.ability.AddRandom();
2761 }
2762 chara.AddThing(chara.MakeGene(DNA.Type.Default));
2763 if (EClass.rnd(2) == 0)
2764 {
2765 chara.AddThing(chara.MakeGene(DNA.Type.Superior));
2766 }
2767 return chara;
2768 }
2769
2770 public void TryGenerateBigDaddy()
2771 {
2772 if (!(BigDaddyChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f) <= EClass.rndf(1f)))
2773 {
2774 Point spawnPos = GetSpawnPos(SpawnPosition.Random, 10000);
2775 List<string> list = new List<string> { "big_daddy", "big_daddy2" };
2776 list.Shuffle();
2777 Spawn(list[0], spawnPos);
2778 if (EClass.rnd(EClass.debug.enable ? 2 : 20) == 0)
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 }
2794 Chara chara = CharaGen.Create(id);
2795 if (EClass.pc.HasElement(1270))
2796 {
2797 chara.SetHostility(Hostility.Friend);
2798 }
2799 else if (EClass.pc.HasElement(1271))
2800 {
2801 chara.SetHostility(Hostility.Enemy);
2802 }
2803 EClass._zone.AddCard(chara, pos);
2804 }
2805 }
2806
2807 public void TryGenerateShrine()
2808 {
2809 float num = ShrineChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f);
2810 for (int i = 0; i < 3; i++)
2811 {
2812 Rand.SetSeed(base.uid + i);
2813 if (num <= EClass.rndf(1f))
2814 {
2815 continue;
2816 }
2817 Point randomSpace = EClass._map.GetRandomSpace(3, 3);
2818 if (randomSpace == null)
2819 {
2820 continue;
2821 }
2822 randomSpace.x++;
2823 randomSpace.z++;
2824 if (randomSpace.HasThing || randomSpace.HasChara)
2825 {
2826 continue;
2827 }
2828 randomSpace.SetObj();
2831 if (EClass.rnd(EClass.debug.test ? 2 : 15) == 0)
2832 {
2833 EClass._zone.AddCard(ThingGen.Create("pedestal_power"), randomSpace).Install();
2834 EClass._zone.AddCard(ThingGen.Create(EClass.gamedata.godStatues.RandomItemWeighted((GodStatueData a) => a.chance).idThing, -1, DangerLv), randomSpace).Install();
2835 }
2836 else
2837 {
2838 EClass._zone.AddCard(ThingGen.Create("statue_power", -1, DangerLv), randomSpace).Install().SetRandomDir();
2839 }
2840 }
2841 Rand.SetSeed();
2842 }
2843
2844 public void ResetHostility()
2845 {
2846 foreach (Chara chara in EClass._map.charas)
2847 {
2848 if (!chara.source.hostility.IsEmpty() && chara.source.hostility.ToEnum<Hostility>() >= Hostility.Friend && !chara.IsPCFactionOrMinion)
2849 {
2850 chara.c_originalHostility = (Hostility)0;
2851 }
2852 chara.hostility = chara.OriginalHostility;
2853 if (chara.enemy != null && (chara.enemy.IsPCFaction || chara.IsPCFaction))
2854 {
2855 chara.SetEnemy();
2856 }
2857 }
2858 }
2859
2860 public virtual void OnGenerateRooms(BaseMapGen gen)
2861 {
2862 }
2863
2864 public Point GetSpawnPos(SpawnPosition type, int tries = 100)
2865 {
2866 Point point = new Point();
2867 for (int i = 0; i < tries; i++)
2868 {
2869 point = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2870 if (!point.IsValid || point.cell.hasDoor || point.IsSync)
2871 {
2872 continue;
2873 }
2874 switch (type)
2875 {
2876 case SpawnPosition.Guest:
2877 {
2878 List<TraitSpotGuest> list = EClass._map.props.installed.traits.List<TraitSpotGuest>();
2879 if (list.Count > 0)
2880 {
2881 list.Shuffle();
2882 foreach (TraitSpotGuest item in list)
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 }
2891 Room room = point.cell.room;
2892 if (room != null && room.data.accessType != 0)
2893 {
2894 continue;
2895 }
2896 break;
2897 }
2898 case SpawnPosition.Outside:
2899 if (point.cell.HasRoof || point.cell.light > 0)
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 {
2912 return SpawnMob(pos, new SpawnSetting
2913 {
2914 id = id
2915 });
2916 }
2917
2918 public Chara SpawnMob(Point pos = null, SpawnSetting setting = null)
2919 {
2920 if (setting == null)
2921 {
2922 setting = SpawnSetting.Default;
2923 }
2924 if (pos == null)
2925 {
2926 pos = GetSpawnPos(setting.position, setting.tries);
2927 if (pos == null)
2928 {
2929 pos = GetSpawnPos(SpawnPosition.Random, setting.tries);
2930 if (pos == null)
2931 {
2932 return null;
2933 }
2934 }
2935 }
2936 BiomeProfile biome = pos.cell.biome;
2937 if (IsUnderwater && EClass.rnd(15) != 0)
2938 {
2939 biome = ((EClass.rnd(4) != 0) ? EClass.core.refs.biomes.Water : EClass.core.refs.biomes.Sand);
2940 }
2941 SpawnList spawnList = null;
2942 if (setting.idSpawnList != null)
2943 {
2944 spawnList = SpawnList.Get(setting.idSpawnList);
2945 }
2946 else if (EClass._zone is Zone_DungeonYeek && EClass.rnd(5) != 0)
2947 {
2948 spawnList = SpawnListChara.Get("dungeon_yeek", (SourceChara.Row r) => r.race == "yeek" && r.quality == 0);
2949 }
2950 else if (EClass._zone is Zone_DungeonDragon && EClass.rnd(5) != 0)
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 }
2954 else if (EClass._zone is Zone_DungeonMino && EClass.rnd(5) != 0)
2955 {
2956 spawnList = SpawnListChara.Get("dungeon_mino", (SourceChara.Row r) => r.race == "minotaur" && r.quality == 0);
2957 }
2958 else if (setting.hostility == SpawnHostility.Neutral || (setting.hostility != SpawnHostility.Enemy && Rand.Range(0f, 1f) < ChanceSpawnNeutral))
2959 {
2960 spawnList = SpawnList.Get(IsInstance ? "c_neutral_war" : "c_neutral");
2961 }
2962 else if (biome.spawn.chara.Count > 0)
2963 {
2964 string randomCharaId = biome.spawn.GetRandomCharaId();
2965 spawnList = ((!IsInstance) ? SpawnList.Get(randomCharaId) : SpawnList.Get("instance_" + randomCharaId, randomCharaId, new CharaFilter
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 {
2972 spawnList = SpawnList.Get(biome.name, "chara", new CharaFilter
2973 {
2974 ShouldPass = delegate(SourceChara.Row s)
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);
2985 CardBlueprint cardBlueprint = new CardBlueprint
2986 {
2987 rarity = Rarity.Normal,
2988 idEle = setting.idEle
2989 };
2990 int num2 = ((setting.filterLv == -1) ? num : setting.filterLv);
2991 if (ScaleType == ZoneScaleType.Void)
2992 {
2993 num2 = ((num - 1) % 50 + 5) * 150 / 100;
2994 if (num2 >= 20 && EClass.rnd(100) < num2)
2995 {
2996 num2 = num;
2997 }
2998 }
2999 CardRow cardRow = (setting.id.IsEmpty() ? spawnList.Select(num2, setting.levelRange) : EClass.sources.cards.map[setting.id]);
3000 if (EClass.world.date.month == 12 && setting.rarity == Rarity.Random && EClass._zone.IsNefia && EClass._zone.isRandomSite && EClass.world.date.day >= 24 && EClass.world.date.day <= 26 && EClass.rnd(50 * (1 + EClass.player.flags.santa) * (1 + EClass.player.flags.santa)) == 0)
3001 {
3002 cardRow = EClass.sources.cards.map["santa"];
3004 }
3005 long num3 = ((setting.fixedLv == -1) ? cardRow.LV : setting.fixedLv);
3006 bool flag = setting.fixedLv != -1 || DangerLvBoost > 0;
3007 num3 += setting.addLv;
3008 if (ScaleType == ZoneScaleType.Void)
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 {
3016 if (EClass.rnd(EClass.pc.HasElement(1271) ? 80 : 100) == 0)
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 }
3038 CardBlueprint.Set(cardBlueprint);
3039 Chara chara = CharaGen.Create(cardRow.id, num2);
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 {
3052 switch (chara.id)
3053 {
3054 case "unicorn":
3055 if (EClass.pc.HasElement(1216) && EClass.pc.Evalue(418) < 1)
3056 {
3057 chara.SetHostility(Hostility.Enemy);
3058 }
3059 break;
3060 case "santa":
3061 case "silverwolf":
3062 case "twintail":
3063 case "test17":
3064 if (EClass.pc.HasElement(1270))
3065 {
3066 chara.SetHostility(Hostility.Friend);
3067 }
3068 else if (EClass.pc.HasElement(1271))
3069 {
3070 chara.SetHostility(Hostility.Enemy);
3071 }
3072 break;
3073 }
3074 }
3075 if (setting.isBoss)
3076 {
3077 chara.c_bossType = BossType.Boss;
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;
3110 foreach (Thing thing in EClass._map.things)
3111 {
3112 if (thing.IsInstalled && thing.trait.Electricity != 0 && (thing.isOn || thing.trait.Electricity > 0))
3113 {
3114 base.electricity += thing.trait.Electricity;
3115 }
3116 }
3117 if (!flag)
3118 {
3119 EClass._map.bounds.ForeachCell(delegate(Cell c)
3120 {
3121 if (c.sourceObj.id == 118 && c.growth.IsMature)
3122 {
3123 base.electricity += 20;
3124 }
3125 });
3126 }
3127 foreach (Thing thing2 in EClass._map.things)
3128 {
3129 if (thing2.IsInstalled)
3130 {
3131 thing2.trait.TryToggle();
3132 }
3133 }
3134 }
3135
3136 public int GetElectricity(bool cost = false)
3137 {
3138 bool flag = GetSoilCost() > MaxSoil;
3139 int sum = 0;
3140 foreach (Thing thing in EClass._map.things)
3141 {
3142 if (!thing.IsInstalled || thing.trait.Electricity == 0)
3143 {
3144 continue;
3145 }
3146 if (cost)
3147 {
3148 if (thing.trait.Electricity < 0)
3149 {
3150 sum += -thing.trait.Electricity;
3151 }
3152 }
3153 else if (thing.trait.Electricity > 0)
3154 {
3155 sum += thing.trait.Electricity;
3156 }
3157 }
3158 if (!cost)
3159 {
3160 sum += elements.Value(2201) * 10 + BaseElectricity;
3161 if (!flag)
3162 {
3163 EClass._map.bounds.ForeachCell(delegate(Cell c)
3164 {
3165 if (c.sourceObj.id == 118 && c.growth.IsMature)
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 {
3207 EClass.Sound.StopBGM();
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;
3241 foreach (ZoneEvent item in events.list)
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 {
3254 Room room = EClass.pc.pos.cell.room;
3255 if (room != null && room.lot != null && room.lot.idBGM != 0)
3256 {
3257 playlist = EClass.Sound.plLot;
3258 if (playlist.list[0].data?.id != room.lot.idBGM)
3259 {
3260 playlist.list[0].data = EClass.core.refs.dictBGM.TryGetValue(room.lot.idBGM);
3261 playlist.Reset();
3262 if (!LayerDrama.keepBGM)
3263 {
3264 EClass.Sound.StopBGM(1f);
3265 }
3266 }
3267 }
3268 }
3270 EClass.Sound.SwitchPlaylist(playlist, !LayerDrama.keepBGM);
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 {
3324 landFeats.Add(EClass.sources.elements.alias[text].id);
3325 }
3326 }
3327 if (listBase.Length == 1)
3328 {
3329 List<SourceElement.Row> list = EClass.sources.elements.rows.Where(delegate(SourceElement.Row e)
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();
3351 SourceElement.Row row = list.RandomItemWeighted((SourceElement.Row e) => e.chance);
3352 landFeats.Add(row.id);
3353 list.Remove(row);
3354 row = list.RandomItemWeighted((SourceElement.Row e) => e.chance);
3355 landFeats.Add(row.id);
3356 }
3357 Rand.SetSeed();
3358 }
3359 List<Element> list2 = new List<Element>();
3360 foreach (int landFeat in landFeats)
3361 {
3362 list2.Add(Element.Create(landFeat, 1));
3363 }
3364 return list2;
3365 }
3366
3367 public ZoneExportData Import(string path)
3368 {
3369 ZipFile zipFile = ZipFile.Read(path);
3370 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3371 zipFile.ExtractAll(pathTemp);
3372 zipFile.Dispose();
3373 return IO.LoadFile<ZoneExportData>(pathTemp + "export") ?? new ZoneExportData();
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 {
3385 ZoneExportData zoneExportData = new ZoneExportData
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 {
3399 IO.CopyDir(base.pathSave + "Texture Replace", IO.TempPath + "/Texture Replace");
3400 }
3401 IO.SaveFile(IO.TempPath + "/export", zoneExportData, compress: true);
3402 using (ZipFile zipFile = new ZipFile())
3403 {
3404 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3405 zipFile.AddDirectory(IO.TempPath);
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 {
3421 string text = StandaloneFileBrowser.SaveFilePanel("Export Zone", dir ?? CorePath.ZoneSave, "new zone", "z");
3422 if (!string.IsNullOrEmpty(text))
3423 {
3424 Export(text);
3425 Msg.SayRaw("Exported Zone");
3426 }
3427 });
3428 }
3429
3430 public void ImportDialog(string dir = null)
3431 {
3433 {
3434 string[] array = StandaloneFileBrowser.OpenFilePanel("Import Zone", dir ?? CorePath.ZoneSave, "z", multiselect: false);
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 {
3450 return Map.GetMetaData(path)?.IsValidVersion() ?? false;
3451 }
3452 catch (Exception ex)
3453 {
3454 EClass.ui.Say(ex.Message);
3455 return false;
3456 }
3457 }
3458
3459 public void Export()
3460 {
3462 string text = pathExport;
3463 IO.Copy(text, CorePath.ZoneSave + "Backup/");
3464 Export(text);
3465 Msg.Say("Exported Map:" + text);
3466 }
3467
3468 public void WriteNote(UINote n, Action<UINote> onWriteNote = null, IInspect.NoteMode mode = IInspect.NoteMode.Default, Recipe recipe = null)
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 }
3482 if (this is Zone_SubTown)
3483 {
3484 return -8000000 + base.uid;
3485 }
3486 if (this is Zone_Town)
3487 {
3488 return -9000000 + base.uid;
3489 }
3490 if (this is Zone_Civilized)
3491 {
3492 return -7000000 + base.uid;
3493 }
3494 if (this is Zone_RandomDungeon)
3495 {
3496 return 1000000 + base.uid;
3497 }
3498 return base.uid;
3499 }
3500
3501 public Chara AddRandomVisitor(bool guest = false)
3502 {
3503 Trait random = map.Installed.traits.GetTraitSet<TraitSpotExit>().GetRandom();
3504 if (random == null)
3505 {
3506 return null;
3507 }
3508 Point point = random.GetPoint();
3509 Chara chara = null;
3510 if (guest)
3511 {
3512 Zone z = EClass.world.FindZone("wilds");
3513 chara = EClass.game.cards.ListGlobalChara(z).RandomItem();
3514 if (chara != null)
3515 {
3516 AddCard(chara, point);
3517 Msg.Say("guestArrive", chara);
3518 chara.visitorState = VisitorState.Arrived;
3519 }
3520 }
3521 else
3522 {
3523 chara = CharaGen.CreateFromFilter("c_wilds");
3524 AddCard(chara, point);
3525 chara.goalListType = GoalListType.Enemy;
3526 }
3527 return chara;
3528 }
3529
3530 public void OnSimulateHour(VirtualDate date)
3531 {
3532 if (base.IsPlayerFaction)
3533 {
3534 branch.OnSimulateHour(date);
3535 }
3536 events.OnSimulateHour();
3537 if (date.IsRealTime)
3538 {
3539 foreach (Thing thing in EClass._map.things)
3540 {
3541 if (thing.IsInstalled)
3542 {
3543 thing.trait.TryToggle();
3544 }
3545 }
3547 }
3548 EClass._map.things.ForeachReverse(delegate(Thing t)
3549 {
3550 t.OnSimulateHour(date);
3551 });
3552 foreach (Thing sucker in Suckers)
3553 {
3554 sucker.Destroy();
3555 }
3556 Suckers.Clear();
3557 if (RespawnRate != 0f)
3558 {
3559 int num = 0;
3560 foreach (Chara chara in map.charas)
3561 {
3562 if (!chara.IsGlobal)
3563 {
3564 num++;
3565 }
3566 }
3567 if (num < MaxRespawn)
3568 {
3569 for (int i = 0; i < RespawnPerHour; i++)
3570 {
3571 SpawnMob();
3572 }
3573 }
3574 }
3575 if (!date.IsRealTime && EClass.rnd(24) == 0)
3576 {
3577 RainWater();
3578 }
3579 if (date.hour == 6)
3580 {
3581 GrowPlants(date);
3582 }
3583 }
3584
3585 public void OnSimulateDay(VirtualDate date)
3586 {
3587 if (base.IsPlayerFaction)
3588 {
3589 branch.OnSimulateDay(date);
3590 }
3591 }
3592
3593 public void OnSimulateMonth(VirtualDate date)
3594 {
3595 if (base.IsPlayerFaction)
3596 {
3597 branch.OnSimulateMonth(date);
3598 }
3599 if (date.IsRealTime)
3600 {
3602 }
3603 }
3604
3605 public void RainWater()
3606 {
3607 if (EClass._map.IsIndoor || !IsPCFaction)
3608 {
3609 return;
3610 }
3611 EClass._map.bounds.ForeachCell(delegate(Cell c)
3612 {
3613 if (c.IsFarmField && !c.HasRoof)
3614 {
3615 c.isWatered = true;
3616 }
3617 });
3618 }
3619
3620 public void GrowPlants(VirtualDate date)
3621 {
3622 bool num = (EClass.player.isAutoFarming = IsPCFaction && EClass.Branch.policies.IsActive(2707));
3623 int weedChance = 1;
3624 if (IsPCFaction && EClass.Branch.policies.IsActive(2703))
3625 {
3626 weedChance += (EClass.debug.enable ? 100000 : 20) + EClass.Branch.Evalue(2703) * 10;
3627 }
3628 if (date.sunMap == null)
3629 {
3630 date.BuildSunMap();
3631 }
3632 if (num)
3633 {
3634 HashSet<int> hashSet = new HashSet<int>();
3635 foreach (Thing thing in EClass._map.things)
3636 {
3637 if (!thing.IsInstalled || !(thing.trait is TraitSpotFarm traitSpotFarm))
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 {
3656 bool isWinter = date.IsWinter;
3657 EClass._map.bounds.ForeachCell(delegate(Cell c)
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 }
3673 if (c.decal != 0 && EClass.rnd(3) == 0)
3674 {
3675 c.decal = 0;
3676 }
3677 if (GrowPlant)
3678 {
3679 if (c.growth != null)
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 }
3691 if (isWinter && plantData != null && c.growth != null && c.growth.NeedSunlight && plantData.fert >= 0 && (EClass.rnd(4) == 0 || c.growth.stage.idx == 0))
3692 {
3693 if (date.sunMap == null)
3694 {
3695 date.BuildSunMap();
3696 }
3697 if (!date.sunMap.Contains(c.index) && !c.growth.CanGrow(date))
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 }
3713 else if (EClass.rnd(20) == 0 && GrowWeed && c.CanGrowWeed && EClass.rnd(weedChance) == 0)
3714 {
3715 biome.Populate(c.GetPoint());
3716 if (c.growth != null)
3717 {
3718 c.growth.SetStage(0);
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 {
3751 if (act.IsHostileAct && HasLaw && !IsPCFaction && c.IsPC)
3752 {
3753 return true;
3754 }
3755 return false;
3756 }
3757
3758 public void RefreshCriminal()
3759 {
3760 bool flag = EClass.player.IsCriminal && HasLaw && !AllowCriminal && !IsPCFaction;
3761 Hostility hostility = (flag ? Hostility.Neutral : Hostility.Friend);
3762 foreach (Chara chara in EClass._map.charas)
3763 {
3764 if (chara.trait is TraitGuard)
3765 {
3766 chara.hostility = hostility;
3767 if (!flag && chara.enemy != null && chara.enemy.IsPCParty)
3768 {
3769 chara.SetEnemy();
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 {
3786 dictCitizen[item.uid] = item.Name;
3787 }
3788 }
3789 }
3790
3791 public virtual void SetAlarm(bool enable)
3792 {
3793 base.isAlarmSet = enable;
3794 if (enable)
3795 {
3796 foreach (Chara chara in EClass._map.charas)
3797 {
3798 if (!chara.IsPCFactionOrMinion)
3799 {
3800 chara.SetHostility(Hostility.Enemy);
3801 }
3802 }
3803 Msg.Say("alarm");
3804 Msg.Say("alarm2");
3805 SE.Play("alarm");
3806 return;
3807 }
3808 foreach (Chara chara2 in EClass._map.charas)
3809 {
3810 if (!chara2.IsPCFactionOrMinion)
3811 {
3812 chara2.SetHostility(Hostility.Neutral);
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 }
3824 Tutorial.Reserve("influence");
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);
3843 List<SourceQuest.Row> list = EClass.sources.quests.rows.Where((SourceQuest.Row a) => a.group == "random").ToList();
3844 int num = 0;
3845 foreach (Chara item in map.charas.Concat(map.deadCharas))
3846 {
3847 if (item.quest != null && !EClass.game.quests.list.Contains(item.quest))
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 }
3859 if (EClass._zone.dateQuest > EClass.world.date.GetRaw() && !force)
3860 {
3861 return;
3862 }
3863 EClass._zone.dateQuest = EClass.world.date.GetRaw() + 1440;
3864 int maxQuest = 3;
3865 Rand.UseSeed(base.uid + EClass.player.stats.days / 7 % 100, delegate
3866 {
3867 maxQuest = 4 + EClass.rnd(4);
3868 });
3869 completedQuests.Clear();
3870 List<Zone> list2 = Quest.ListDeliver();
3871 List<Tuple<string, int>> listTag = new List<Tuple<string, int>>();
3872 string[] array = EClass._zone.source.questTag;
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();
3894 if (!chara.trait.CanGiveRandomQuest || chara.isSubsetCard || chara.homeZone != EClass._zone || chara.IsGuest() || chara.memberType == FactionMemberType.Livestock || (chara.quest != null && !force))
3895 {
3896 continue;
3897 }
3898 SourceQuest.Row row = list.RandomItemWeighted(delegate(SourceQuest.Row a)
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 }
3909 if (!EClass._zone.IsPCFaction && a.tags.Contains("bulk"))
3910 {
3911 num2 = 0;
3912 }
3913 return a.chance * num2;
3914 });
3915 if ((!row.tags.Contains("needDestZone") || list2.Count >= 2) && (row.minFame <= 0 || row.minFame < EClass.player.fame || EClass.debug.enable))
3916 {
3917 Quest.Create(row.id, null, chara);
3918 num++;
3919 }
3920 }
3921 }
3922
3923 public List<Chara> ListMinions(Chara c)
3924 {
3925 List<Chara> list = new List<Chara>();
3926 foreach (Chara chara in EClass._map.charas)
3927 {
3928 if (chara.c_uidMaster == c.uid && chara.c_minionType == MinionType.Default)
3929 {
3930 list.Add(chara);
3931 }
3932 }
3933 return list;
3934 }
3935
3936 public int CountMinions(Chara c)
3937 {
3938 int num = 0;
3939 foreach (Chara chara in EClass._map.charas)
3940 {
3941 if (chara.c_uidMaster == c.uid && chara.c_minionType == MinionType.Default)
3942 {
3943 num++;
3944 }
3945 }
3946 return num;
3947 }
3948
3949 public int GetSoilCost()
3950 {
3951 int i = 0;
3952 EClass._map.bounds.ForeachCell(delegate(Cell c)
3953 {
3954 i += c.sourceObj.costSoil;
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 }
3968 if (EClass.rnd(30) == 0)
3969 {
3970 Thing thing = ThingGen.Create("purse");
3971 thing.isLostProperty = true;
3972 thing.things.DestroyAll();
3973 int num2 = (thing.c_lockLv = EClass.rndHalf(Mathf.Min(base.development / 10 + 10, 50)));
3974 thing.Add("money", EClass.rndHalf(num2 * 60 + 1000));
3975 if (EClass.rnd(2) == 0)
3976 {
3977 thing.Add("plat", EClass.rnd(4));
3978 }
3979 else
3980 {
3981 thing.Add("medal", EClass.rnd(2));
3982 }
3983 EClass._zone.AddCard(thing, point);
3984 }
3985 else
3986 {
3988 }
3989 }
3990 static Point GetPos()
3991 {
3992 for (int j = 0; j < 10; j++)
3993 {
3994 Point randomPoint = EClass._zone.bounds.GetRandomPoint();
3995 if (!randomPoint.IsBlocked && !randomPoint.HasThing && !randomPoint.HasObj && !randomPoint.HasBlock)
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;
4007 IList<SourceBacker.Row> list = EClass.sources.backers.listPet.Copy();
4008 list.Shuffle();
4010 {
4011 list.ForeachReverse(delegate(SourceBacker.Row a)
4012 {
4013 if (EClass.player.doneBackers.Contains(a.id))
4014 {
4015 list.Remove(a);
4016 }
4017 });
4018 }
4019 foreach (Chara chara in EClass._map.charas)
4020 {
4021 if (chara.IsGlobal || chara.IsMinion)
4022 {
4023 continue;
4024 }
4025 if (chara.isBackerContent)
4026 {
4027 if (chara.sourceBacker.isStatic != 0)
4028 {
4029 continue;
4030 }
4031 if (chara.id != "follower")
4032 {
4033 chara.RemoveBacker();
4034 }
4035 }
4036 if ((flag && chara.race.id != "cat") || (!EClass.debug.enable && EClass.rnd((!flag) ? (draw ? 3 : 10) : (draw ? 1 : 2)) != 0))
4037 {
4038 continue;
4039 }
4040 foreach (SourceBacker.Row item in list)
4041 {
4042 if (item.chara == chara.id)
4043 {
4044 chara.ApplyBacker(item.id);
4045 list.Remove(item);
4046 break;
4047 }
4048 }
4049 }
4050 }
4051
4052 public FortuneRollData GetOrCreateFortuneRollData(bool refresh = true)
4053 {
4054 if (fortuneRoll == null)
4055 {
4056 fortuneRoll = new FortuneRollData();
4057 fortuneRoll.seed = EClass._zone.uid * 100 + EClass.game.seed;
4058 }
4059 if (refresh || fortuneRoll.count == 0)
4060 {
4061 fortuneRoll.Refresh();
4062 }
4063 return fortuneRoll;
4064 }
4065}
BossType
Definition: BossType.cs:2
CTAG
Definition: CTAG.cs:2
@ seed
ClearInventoryType
ContainerFlag
Definition: ContainerFlag.cs:5
CureType
Definition: CureType.cs:2
if(!match.Success)
GoalListType
Definition: GoalListType.cs:2
Hostility
Definition: Hostility.cs:2
MinionType
Definition: MinionType.cs:2
$ Installed
Definition: ModManager.cs:306
NameStyle
Definition: NameStyle.cs:2
PlaceState
Definition: PlaceState.cs:2
Rarity
Definition: Rarity.cs:2
RescueState
Definition: RescueState.cs:2
SpawnHostility
SpawnPosition
Definition: SpawnPosition.cs:2
VisitorState
Definition: VisitorState.cs:2
ZoneScaleType
Definition: ZoneScaleType.cs:2
virtual void OnSimulatePosition()
Definition: AIAct.cs:604
void SimulateZone(int days)
Definition: AIAct.cs:592
Definition: ACT.cs:62
virtual bool IsHostileAct
Definition: ACT.cs:129
BaseArea.AccessType accessType
Definition: AreaData.cs:42
static int indexFollower
AreaData data
Definition: BaseArea.cs:29
void WaitForEndOfFrame(Action action)
Definition: BaseCore.cs:61
Version version
Definition: BaseCore.cs:17
List< SpawnListChara > chara
string GetRandomCharaId()
void Populate(Point point, bool interior=false, float mtpDensity=1f)
static void Set(CardBlueprint _bp=null)
Thing container_shipping
Definition: CardManager.cs:52
GlobalCharaList globalCharas
Definition: CardManager.cs:46
List< Chara > ListGlobalChara(Zone z)
Definition: CardManager.cs:103
override void OnLeaveScreen()
void KillActor()
int quality
Definition: CardRow.cs:19
string id
Definition: CardRow.cs:7
Definition: Card.cs:11
MinionType c_minionType
Definition: Card.cs:1015
Props props
Definition: Card.cs:52
bool IsPCFactionOrMinion
Definition: Card.cs:2342
bool IsDecayed
Definition: Card.cs:2357
virtual bool isThing
Definition: Card.cs:2133
virtual Chara Chara
Definition: Card.cs:2122
virtual void OnSimulateHour(VirtualDate date)
Definition: Card.cs:7057
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3925
string id
Definition: Card.cs:36
SourceBacker.Row sourceBacker
Definition: Card.cs:955
bool isSubsetCard
Definition: Card.cs:749
bool isRestrained
Definition: Card.cs:569
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6626
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3214
int c_lockLv
Definition: Card.cs:991
Card AddCard(Card c)
Definition: Card.cs:3263
bool isSale
Definition: Card.cs:869
int c_uidMaster
Definition: Card.cs:1489
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3277
int hp
Definition: Card.cs:245
Rarity rarity
Definition: Card.cs:317
ICardParent parent
Definition: Card.cs:56
bool hasSpawned
Definition: Card.cs:905
PlaceState placeState
Definition: Card.cs:86
bool HasTag(CTAG tag)
Definition: Card.cs:2728
Point pos
Definition: Card.cs:60
void DecayNatural(int hour=1)
Definition: Card.cs:7066
int uid
Definition: Card.cs:125
virtual void HealHP(long a, HealSource origin=HealSource.None)
Definition: Card.cs:4185
Trait trait
Definition: Card.cs:54
Window.SaveData GetWindowSaveData()
Definition: Card.cs:2649
void RemoveBacker()
Definition: Card.cs:7517
int c_idBacker
Definition: Card.cs:1477
void PlayAnimeLoot()
Definition: Card.cs:6655
void Destroy()
Definition: Card.cs:5305
ThingContainer things
Definition: Card.cs:39
bool IsInstalled
Definition: Card.cs:2451
virtual bool isChara
Definition: Card.cs:2135
virtual Thing Thing
Definition: Card.cs:2110
int Evalue(int ele)
Definition: Card.cs:2704
bool isOn
Definition: Card.cs:545
bool TryStackTo(Thing to)
Definition: Card.cs:3575
Card Install()
Definition: Card.cs:3919
void ApplyBacker(int bid)
Definition: Card.cs:7481
void SetRandomDir()
Definition: Card.cs:6688
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:3254
SourceCategory.Row category
Definition: Card.cs:2101
bool IsContainer
Definition: Card.cs:2141
CardRenderer renderer
Definition: Card.cs:64
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6364
bool isBackerContent
Definition: Card.cs:952
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7304
List< Thing > things
Definition: CellDetail.cs:11
Definition: Cell.cs:7
Room room
Definition: Cell.cs:110
byte decal
Definition: Cell.cs:46
bool IsTopWaterAndNoSnow
Definition: Cell.cs:720
bool IsFarmField
Definition: Cell.cs:738
BiomeProfile biome
Definition: Cell.cs:1087
bool isModified
Definition: Cell.cs:446
byte light
Definition: Cell.cs:66
GrowSystem growth
Definition: Cell.cs:233
CellDetail detail
Definition: Cell.cs:100
bool HasRoof
Definition: Cell.cs:656
SourceObj.Row sourceObj
Definition: Cell.cs:1084
Point GetPoint()
Definition: Cell.cs:1113
bool CanGrowWeed
Definition: Cell.cs:750
int index
Definition: Cell.cs:122
bool hasDoor
Definition: Cell.cs:266
void AddRandom()
static Chara CreateFromFilter(string id, int lv=-1, int levelRange=-1)
Definition: CharaGen.cs:22
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
BaseCondition GetCondition(string idCon)
Definition: Chara.cs:10025
new TraitChara trait
Definition: Chara.cs:509
Hostility OriginalHostility
Definition: Chara.cs:475
AIAct ai
Definition: Chara.cs:206
void ValidateWorks()
Definition: Chara.cs:9764
ConSuspend conSuspend
Definition: Chara.cs:104
bool CanRevive()
Definition: Chara.cs:5417
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9798
Faction faction
Definition: Chara.cs:431
override bool IsPC
Definition: Chara.cs:630
Chara host
Definition: Chara.cs:33
override bool IsGlobal
Definition: Chara.cs:628
override bool IsPCParty
Definition: Chara.cs:633
bool HasCondition(string alias)
Definition: Chara.cs:9970
AIAct SetAI(AIAct g)
Definition: Chara.cs:9413
override bool IsMinion
Definition: Chara.cs:645
Point orgPos
Definition: Chara.cs:21
override bool IsPCFaction
Definition: Chara.cs:689
Goal GetGoalWork()
Definition: Chara.cs:9348
override int MaxHP
Definition: Chara.cs:726
Zone currentZone
Definition: Chara.cs:259
Goal GetGoalHobby()
Definition: Chara.cs:9361
SourceChara.Row source
Definition: Chara.cs:162
Stats mana
Definition: Chara.cs:1213
Stats stamina
Definition: Chara.cs:1205
void TryRestock(bool onCreate)
Definition: Chara.cs:4944
GlobalData global
Definition: Chara.cs:76
bool IsHomeMember()
Definition: Chara.cs:6939
Chara master
Definition: Chara.cs:88
void Revive(Point p=null, bool msg=false)
Definition: Chara.cs:5443
Zone homeZone
Definition: Chara.cs:271
bool IsGuest()
Definition: Chara.cs:6964
Thing MakeGene(DNA.Type? type=null)
Definition: Chara.cs:8641
override void SetDir(int d)
Definition: Chara.cs:3754
Religion faith
Definition: Chara.cs:443
Chara enemy
Definition: Chara.cs:86
CharaAbility ability
Definition: Chara.cs:428
bool IsInActiveZone
Definition: Chara.cs:885
Chara SetEnemy(Chara c=null)
Definition: Chara.cs:6643
FactionBranch homeBranch
Definition: Chara.cs:1113
void ChooseNewGoal()
Definition: Chara.cs:9284
Hostility hostility
Definition: Chara.cs:295
bool isDead
Definition: Chara.cs:393
void SetFaith(string id)
Definition: Chara.cs:1776
void Cure(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Definition: Chara.cs:10074
Chara SetHostility(Hostility h)
Definition: Chara.cs:1505
void MoveZone(string alias)
Definition: Chara.cs:3548
SourceRace.Row race
Definition: Chara.cs:468
void AddSpawn(string id)
Definition: CodexManager.cs:65
bool ignoreBackerDestoryFlag
Definition: CoreConfig.cs:570
void SetBGMInterval()
Definition: CoreConfig.cs:1022
bool test
Definition: CoreDebug.cs:185
bool enable
Definition: CoreDebug.cs:301
static string ZoneSave
Definition: CorePath.cs:192
BiomeProfile Water
Definition: CoreRef.cs:155
BiomeProfile Sand
Definition: CoreRef.cs:153
Crawler start
Definition: CoreRef.cs:217
Dictionary< int, BGMData > dictBGM
Definition: CoreRef.cs:388
Biomes biomes
Definition: CoreRef.cs:344
Crawlers crawlers
Definition: CoreRef.cs:346
CoreRef refs
Definition: Core.cs:51
bool IsGameStarted
Definition: Core.cs:87
CoreConfig config
Definition: Core.cs:70
static Crawler Create(string id)
Definition: Crawler.cs:193
bool CrawlUntil(Map map, Func< Point > onStart, int tries, Func< Result, bool > canComplete, Action onFail=null)
Definition: Crawler.cs:59
Definition: DNA.cs:8
Type
Definition: DNA.cs:10
int hour
Definition: Date.cs:74
int GetRaw(int offsetHours=0)
Definition: Date.cs:328
int month
Definition: Date.cs:50
int day
Definition: Date.cs:62
bool IsExpired(int time)
Definition: Date.cs:338
bool IsNight
Definition: Date.cs:112
bool IsWinter
Definition: Date.cs:192
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static int curve(long _a, int start, int step, int rate=75)
Definition: EClass.cs:69
static Scene scene
Definition: EClass.cs:31
static GameData gamedata
Definition: EClass.cs:37
static Core core
Definition: EClass.cs:7
static Zone _zone
Definition: EClass.cs:21
static World world
Definition: EClass.cs:41
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static SourceManager sources
Definition: EClass.cs:43
static float rndf(float a)
Definition: EClass.cs:102
static FactionBranch Branch
Definition: EClass.cs:23
static int rndHalf(int a)
Definition: EClass.cs:97
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
static SoundManager Sound
Definition: EClass.cs:47
static UI ui
Definition: EClass.cs:17
static GameSetting setting
Definition: EClass.cs:35
Definition: Effect.cs:7
static Effect Get(Effect original)
Definition: Effect.cs:80
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:100
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1130
void Initialize(EloMap _elomap)
Definition: EloMapActor.cs:28
EloMap elomap
Definition: EloMapActor.cs:7
string idZoneProfile
Definition: EloMap.cs:68
Definition: EloMap.cs:8
void SetZone(int gx, int gy, Zone z, bool updateMesh=false)
Definition: EloMap.cs:234
TileInfo GetTileInfo(int gx, int gy)
Definition: EloMap.cs:286
void OnAfterSimulate()
int Evalue(int ele)
void OnUnclaimZone()
List< Chara > members
PolicyManager policies
string Log(string idLang, string ref1=null, string ref2=null, string ref3=null, string ref4=null)
void AddMemeber(Chara c)
List< GodStatueData > godStatues
Definition: GameData.cs:9
BalanceSetting balance
Definition: GameSetting.cs:311
bool isLoading
Definition: Game.cs:242
ReligionManager religions
Definition: Game.cs:159
SpatialManager spatials
Definition: Game.cs:153
CardManager cards
Definition: Game.cs:156
Zone activeZone
Definition: Game.cs:252
bool IsSurvival
Definition: Game.cs:276
QuestManager quests
Definition: Game.cs:183
int seed
Definition: Game.cs:201
Zone StartZone
Definition: Game.cs:278
ZoneTransition transition
Definition: GlobalData.cs:6
Definition: Goal.cs:4
void SetStage(int idx, bool renewHarvest=false)
Definition: GrowSystem.cs:451
virtual bool IsMature
Definition: GrowSystem.cs:117
Stage stage
Definition: GrowSystem.cs:115
virtual bool NeedSunlight
Definition: GrowSystem.cs:107
bool CanGrow(VirtualDate date)
Definition: GrowSystem.cs:287
Definition: IO.cs:10
static void CreateTempDirectory(string path=null)
Definition: IO.cs:419
static void DeleteDirectory(string path)
Definition: IO.cs:392
static void Copy(string fromPath, string toPath)
Definition: IO.cs:309
static string TempPath
Definition: IO.cs:63
static void SaveFile(string path, object obj, bool compress=false, JsonSerializerSettings setting=null)
Definition: IO.cs:88
static void DeleteTempDirectory(string path=null)
Definition: IO.cs:424
static void CopyDir(string sourceDirectory, string targetDirectory, Func< string, bool > funcExclude=null)
Definition: IO.cs:276
Definition: Lang.cs:7
static string[] GetList(string id)
Definition: Lang.cs:113
static bool keepBGM
Definition: LayerDrama.cs:10
int idBGM
Definition: Lot.cs:16
static SourceMaterial.Row GetRandomMaterial(int lv, string group=null, bool tryLevelMatTier=false)
Definition: MATERIAL.cs:56
void ForeachCell(Action< Cell > action)
Definition: MapBounds.cs:279
Point GetRandomSurface(int x, int z, int radius, bool walkable=true, bool allowWater=false)
Definition: MapBounds.cs:182
int x
Definition: MapBounds.cs:8
Point GetRandomSpace(int width, int height, int tries=100)
Definition: MapBounds.cs:246
Point GetCenterPos()
Definition: MapBounds.cs:52
Point GetRandomPoint()
Definition: MapBounds.cs:97
bool IsValidVersion()
Definition: MapMetaData.cs:31
Definition: Map.cs:13
bool IsIndoor
Definition: Map.cs:131
void ResetEditorPos()
Definition: Map.cs:357
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
Definition: Map.cs:2261
List< Thing > things
Definition: Map.cs:49
PropsManager props
Definition: Map.cs:91
PlantData AddPlant(Point pos, Thing seed)
Definition: Map.cs:1998
RoomManager rooms
Definition: Map.cs:31
static MapMetaData GetMetaData(string pathZip)
Definition: Map.cs:750
Version version
Definition: Map.cs:28
List< Chara > charas
Definition: Map.cs:81
void RevealAll(bool reveal=true)
Definition: Map.cs:918
void RefreshAllTiles()
Definition: Map.cs:2154
MapBounds bounds
Definition: Map.cs:52
Definition: Msg.cs:5
static string SayRaw(string text)
Definition: Msg.cs:118
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
Definition: NoGoal.cs:4
static PathManager Instance
Definition: PathManager.cs:16
bool IsPathClear(Point origin, Point dest, IPathfindWalker walker, int radius)
Definition: PathManager.cs:47
int santa
Definition: Player.cs:604
int days
Definition: Player.cs:75
Flags flags
Definition: Player.cs:1161
CodexManager codex
Definition: Player.cs:1182
Stats stats
Definition: Player.cs:1083
bool isAutoFarming
Definition: Player.cs:1251
List< Chara > listCarryoverMap
Definition: Player.cs:1293
HashSet< int > doneBackers
Definition: Player.cs:1140
Zone nextZone
Definition: Player.cs:1297
Point lastZonePos
Definition: Player.cs:1170
int seedShrine
Definition: Player.cs:1008
int fame
Definition: Player.cs:948
bool simulatingZone
Definition: Player.cs:1249
Definition: Point.cs:9
void SetObj(int id=0, int value=1, int dir=0)
Definition: Point.cs:934
Point Set(int _x, int _z)
Definition: Point.cs:503
bool IsBlocked
Definition: Point.cs:363
List< Thing > Things
Definition: Point.cs:338
int x
Definition: Point.cs:36
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
Definition: Point.cs:624
int z
Definition: Point.cs:39
bool IsSync
Definition: Point.cs:344
void SetFloor(int idMat=0, int idFloor=0)
Definition: Point.cs:929
bool HasThing
Definition: Point.cs:251
bool Equals(int _x, int _z)
Definition: Point.cs:966
bool IsValid
Definition: Point.cs:88
bool HasObj
Definition: Point.cs:137
bool ForeachNearestPoint(Func< Point, bool > endFunc, bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int maxRange=30)
Definition: Point.cs:696
Point Clamp(bool useBounds=false)
Definition: Point.cs:1014
bool HasBlock
Definition: Point.cs:141
bool IsInBounds
Definition: Point.cs:104
Cell cell
Definition: Point.cs:51
Thing FindThing(Func< Thing, bool > func)
Definition: Point.cs:1146
GrowSystem growth
Definition: Point.cs:77
bool HasChara
Definition: Point.cs:238
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
Definition: Point.cs:774
bool IsActive(int id, int days=-1)
PropsInstalled installed
Definition: PropsManager.cs:8
TraitManager traits
Definition: Props.cs:18
Thing Find(int uid)
Definition: Props.cs:389
List< Thing > containers
Definition: Props.cs:22
List< Quest > list
Definition: QuestManager.cs:11
Definition: Quest.cs:7
static List< Zone > ListDeliver()
Definition: Quest.cs:259
static Quest Create(string _id, string _idPerson=null, Chara c=null, bool assignQuest=true)
Definition: Quest.cs:241
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:49
static void UseSeed(int seed, Action action)
Definition: Rand.cs:24
static void SetSeed(int a=-1)
Definition: Rand.cs:44
Definition: Recipe.cs:7
Definition: Region.cs:8
EloMap elomap
Definition: Region.cs:9
Dictionary< string, Religion > dictAll
Religion GetRandomReligion(bool onlyJoinable=true, bool includeMinor=false)
int LV
Definition: RenderRow.cs:22
void AssignCharas()
Definition: RoomManager.cs:39
Definition: Room.cs:4
Lot lot
Definition: Room.cs:21
static string[] OpenFilePanel(string title, string directory, string extension, bool multiselect)
static string SaveFilePanel(string title, string directory, string defaultName, string extension)
EloMapActor elomapActor
Definition: Scene.cs:101
void Clear()
Definition: Scene.cs:355
void RemoveActorEx(Card c)
Definition: Scene.cs:1034
EloMap elomap
Definition: Scene.cs:149
List< Row > listFollower
List< Row > listPet
Dictionary< string, CardRow > map
Definition: SourceCard.cs:9
SourceCard cards
SourceObj objs
SourceBacker backers
SourceElement elements
SourceQuest quests
string[] tags
Definition: SourceQuest.cs:23
void Remove(Spatial s)
Zone Find(string id)
int mapX
Definition: Spatial.cs:460
int lv
Definition: Spatial.cs:142
bool isRandomSite
Definition: Spatial.cs:334
int uid
Definition: Spatial.cs:70
virtual bool IsRegion
Definition: Spatial.cs:515
virtual string Name
Definition: Spatial.cs:509
int dateQuest
Definition: Spatial.cs:286
virtual void Destroy()
Definition: Spatial.cs:690
SourceZone.Row source
Definition: Spatial.cs:453
bool isConquered
Definition: Spatial.cs:382
int y
Definition: Spatial.cs:106
Zone FindDeepestZone()
Definition: Spatial.cs:715
int mapY
Definition: Spatial.cs:472
int x
Definition: Spatial.cs:94
Zone FindZone(int lv)
Definition: Spatial.cs:728
static SpawnList Get(string id, Func< SourceChara.Row, bool > func)
static SpawnList Get(string id, string parent=null, CardFilter filter=null)
Definition: SpawnList.cs:18
CardRow Select(int lv=-1, int levelRange=-1)
Definition: SpawnList.cs:139
static SpawnSetting Default
Definition: SpawnSetting.cs:33
static SpawnSetting Fish()
static SpawnSetting HomeGuest(int lv)
static SpawnSetting Evolved(int fixedLv=-1)
Definition: SpawnSetting.cs:37
virtual void Mod(int a)
Definition: Stats.cs:135
virtual int value
Definition: Stats.cs:56
virtual int max
Definition: Stats.cs:68
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
void DestroyAll(Func< Thing, bool > funcExclude=null)
Thing Find(int uid)
Thing CanStack(Thing target, int destInvX=-1, int destInvY=-1)
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
override string GetName(NameStyle style, int _num=-1)
Definition: Thing.cs:532
bool IsSharedContainer
Definition: Thing.cs:110
virtual bool CanGiveRandomQuest
Definition: TraitChara.cs:119
virtual bool CanAutoRevive
Definition: TraitChara.cs:21
virtual bool IsFor(Zone z)
static bool CanTagSale(Card t, bool insideContainer=false)
Definition: TraitSalesTag.cs:9
static Thing MakeSeed(string idSource)
Definition: TraitSeed.cs:105
static void LevelSeed(Thing t, SourceObj.Row obj, int num)
Definition: TraitSeed.cs:184
Definition: Trait.cs:7
virtual string IDActorEx
Definition: Trait.cs:187
virtual void TryToggle()
Definition: Trait.cs:1327
Point GetRandomPoint(Func< Point, bool > func=null, Chara accessChara=null)
Definition: Trait.cs:846
virtual ShopType ShopType
Definition: Trait.cs:532
string GetParam(int i, string def=null)
Definition: Trait.cs:587
Point GetPoint()
Definition: Trait.cs:841
virtual int Electricity
Definition: Trait.cs:119
virtual List< Point > ListPoints(Point center=null, bool onlyPassable=true, bool allowChara=true)
Definition: Trait.cs:864
virtual int Decay
Definition: Trait.cs:123
static void Reserve(string idStep, Action onBeforePlay=null)
Definition: Tutorial.cs:55
Definition: UINote.cs:6
bool IsRealTime
Definition: VirtualDate.cs:7
void SimulateHour()
Definition: VirtualDate.cs:66
void BuildSunMap()
Definition: VirtualDate.cs:54
HashSet< int > sunMap
Definition: VirtualDate.cs:9
FilterResult IsFilterPass(string text)
Definition: Window.cs:498
ContainerFlag flag
Definition: Window.cs:267
HashSet< int > cats
Definition: Window.cs:119
bool userFilter
Definition: Window.cs:132
bool noRotten
Definition: Window.cs:439
bool onlyRottable
Definition: Window.cs:451
bool advDistribution
Definition: Window.cs:427
Definition: Window.cs:13
GameDate date
Definition: World.cs:6
static ZoneProfile Load(string id)
Definition: ZoneProfile.cs:73
EnterState state
Definition: Zone.cs:12
virtual bool IsNefia
Definition: Zone.cs:289
Zone GetTopZone()
Definition: Zone.cs:2054
FactionBranch branch
Definition: Zone.cs:34
Card AddThing(string id, int x, int z)
Definition: Zone.cs:2088
void RefreshPlaylist()
Definition: Zone.cs:3217
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:3175
MapBounds bounds
Definition: Zone.cs:49
bool IsInstance
Definition: Zone.cs:493
void ClearZones(Zone current=null)
Definition: Zone.cs:2023
Chara SpawnMob(string id, Point pos=null)
Definition: Zone.cs:2910
void RemoveCard(Card t)
Definition: Zone.cs:2138
override int DangerLv
Definition: Zone.cs:112
bool IsPCFaction
Definition: Zone.cs:477
ZoneInstance instance
Definition: Zone.cs:55
Card AddCard(Card t, Point point)
Definition: Zone.cs:2098
void RemoveCard(Card c)
NoteMode
Definition: IInspect.cs:7
bool IsBelow(int _major, int _minor, int _batch)
Definition: Version.cs:31
int GetInt()
Definition: Version.cs:21