Elin Decompiled Documentation EA 23.319 Nightly 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 1120 of file Zone.cs.

1121{
1122 if (idHat != null && EClass.world.date.IsExpired(base.dateHat))
1123 {
1124 idHat = null;
1125 base.dateHat = 0;
1126 }
1127 sourceHat = ((idHat != null) ? EClass.sources.cards.map[idHat] : ((IDHat != null) ? EClass.sources.cards.map[IDHat] : null));
1128 }
1129
1130 public void OnVisit()
1131 {
1132 if (EClass.world.date.IsExpired(base.dateRevive))
1133 {
1134 ResetHostility();
1135 Revive();
1136 List<Chara> list = new List<Chara>();
1137 foreach (Chara chara in EClass._map.charas)
1138 {
1139 chara.TryRestock(onCreate: false);
1140 if (!chara.IsPCFaction)
1141 {
1142 chara.c_fur = 0;
1143 }
1144 if (chara.IsMinion && chara.master != null && !chara.master.IsPCParty)
1145 {
1146 list.Add(chara);
1147 }
1148 }
1149 foreach (Chara item in list)
1150 {
1151 item.Destroy();
1152 }
1153 }
1154 if (!EClass.game.isLoading)
1155 {
1156 RefreshDeathSentense();
1157 }
1158 RefreshCriminal();
1160 events.OnVisit();
1161 OnActivate();
1162 UpdateQuests();
1163 OnBeforeSimulate();
1164 isSimulating = true;
1165 Simulate();
1166 isSimulating = false;
1167 OnAfterSimulate();
1168 if (EClass.Branch != null)
1169 {
1171 }
1172 base.lastActive = EClass.world.date.GetRaw();
1173 if (!EClass.game.isLoading)
1174 {
1175 base.visitCount++;
1176 }
1177 base.version = EClass.core.version.GetInt();
1178 if (fieldElements.dict.Count() > 0)
1179 {
1180 Tutorial.Reserve("field");
1181 }
1182 }
1183
1184 public void RefreshDeathSentense()
1185 {
1186 foreach (Chara chara in EClass._map.charas)
1187 {
1188 if (chara.HasCondition<ConDeathSentense>())
1189 {
1190 chara.GetCondition<ConDeathSentense>().TryRemove();
1191 }
1192 }
1193 }
1194
1195 public void Revive()
1196 {
1197 base.dateRevive = EClass.world.date.GetRaw() + 1440 * EClass.setting.balance.dateRevive;
1198 if (ShouldAutoRevive)
1199 {
1200 foreach (Chara deadChara in map.deadCharas)
1201 {
1202 if (deadChara.trait.CanAutoRevive && deadChara.CanRevive())
1203 {
1204 deadChara.Revive();
1206 {
1207 deadChara.RemoveBacker();
1208 }
1209 EClass._zone.AddCard(deadChara, (deadChara.orgPos != null && deadChara.orgPos.IsInBounds) ? deadChara.orgPos : deadChara.pos);
1210 }
1211 }
1212 }
1213 foreach (Chara value in EClass.game.cards.globalCharas.Values)
1214 {
1215 if (value.isDead && value.CanRevive() && value.homeZone == this)
1216 {
1217 value.Revive();
1218 Point point = GetSpawnPos(value);
1219 if (value.orgPos != null && value.orgPos.IsInBounds)
1220 {
1221 point = value.orgPos.GetNearestPoint() ?? point;
1222 }
1223 EClass._zone.AddCard(value, point);
1224 }
1225 }
1226 map.deadCharas.Clear();
1227 }
1228
1229 public virtual void OnRegenerate()
1230 {
1231 }
1232
1233 public virtual void OnActivate()
1234 {
1235 if (!(id == "startVillage2"))
1236 {
1237 return;
1238 }
1239 if (EClass._map.version.IsBelow(0, 23, 226))
1240 {
1241 SetBGM(121, refresh: false);
1242 }
1243 int num = 0;
1244 foreach (Chara chara in EClass._map.charas)
1245 {
1246 if (chara.id == "cat_silver" && !chara.IsPCFaction)
1247 {
1248 num++;
1249 }
1250 }
1251 if (num > 0)
1252 {
1253 Msg.Say("num_silvercat", num.ToString() ?? "");
1254 }
1255 }
1256
1257 public virtual void OnBeforeDeactivate()
1258 {
1259 }
1260
1261 public virtual void OnDeactivate()
1262 {
1263 }
1264
1265 public virtual void OnBeforeSimulate()
1266 {
1267 }
1268
1269 public virtual void OnVisitNewMapOrRegenerate()
1270 {
1271 }
1272
1273 public virtual void OnAfterSimulate()
1274 {
1275 }
1276
1277 public virtual void OnAdvanceHour()
1278 {
1279 }
1280
1281 public void Simulate()
1282 {
1283 if (!EClass.game.isLoading && base.visitCount > 0)
1284 {
1285 if (Boss != null && IsNefia)
1286 {
1287 Msg.Say("bossLeave", Boss.Name.ToTitleCase(), EClass._zone.Name);
1290 }
1291 int num = Mathf.Clamp(MinsSinceLastActive, 1, 10000);
1292 foreach (Chara chara2 in EClass._map.charas)
1293 {
1294 if (chara2.hp < 0)
1295 {
1296 chara2.hp = 0;
1297 }
1298 if (!chara2.IsPCParty)
1299 {
1300 if (chara2.mana.value < 0)
1301 {
1302 chara2.mana.value = 0;
1303 }
1304 if (chara2.stamina.value < 0)
1305 {
1306 chara2.stamina.value = 0;
1307 }
1308 }
1309 if (num > 60)
1310 {
1311 chara2.resistCon = null;
1312 }
1313 if (chara2.rarity >= Rarity.Legendary && !chara2.IsPCFaction && num > 0)
1314 {
1315 Msg.ignoreAll = true;
1316 chara2.Cure(CureType.Boss, 20 + num * 10);
1317 chara2.HealHP((int)((long)Mathf.Max(1, chara2.MaxHP) * (long)Mathf.Min(num, 20) / 20));
1318 chara2.mana.Mod(Mathf.Max(1, chara2.mana.max) * Mathf.Min(num, 20) / 20);
1319 chara2.stamina.Mod(Mathf.Max(1, chara2.stamina.max) * Mathf.Min(num, 20) / 20);
1320 Msg.ignoreAll = false;
1321 }
1322 }
1323 }
1324 Debug.Log("Last Active:" + base.lastActive);
1325 if (base.lastActive == 0 || HourSinceLastActive <= 1 || IsRegion)
1326 {
1327 return;
1328 }
1329 Debug.Log(Name + " Simulate:" + HourSinceLastActive + " hours");
1330 VirtualDate virtualDate = new VirtualDate(HourSinceLastActive);
1331 List<Chara> list = EClass._map.charas.ToList();
1332 int num2 = HourSinceLastActive / 24;
1333 int num3 = 0;
1334 if (num2 > 0)
1335 {
1336 foreach (Chara item in list)
1337 {
1338 if (!item.IsPCParty)
1339 {
1340 item.OnSleep(200, num2);
1341 if (item.conSleep != null)
1342 {
1343 item.conSleep.Kill();
1344 }
1345 if (EClass.rnd(EClass.world.date.IsNight ? 20 : 200) == 0 && !item.IsPCFaction)
1346 {
1347 item.AddCondition<ConSleep>(1000 + EClass.rnd(1000), force: true);
1348 }
1349 if (item.things.Count > 20)
1350 {
1351 item.ClearInventory(ClearInventoryType.Purge);
1352 }
1353 }
1354 }
1355 }
1356 VirtualDate.current = virtualDate;
1357 for (int i = 0; i < HourSinceLastActive; i++)
1358 {
1359 virtualDate.SimulateHour();
1360 if (!virtualDate.IsWinter)
1361 {
1362 num3++;
1363 }
1364 }
1365 EClass._map.things.ForeachReverse(delegate(Thing t)
1366 {
1367 t.DecayNatural(HourSinceLastActive);
1368 });
1369 VirtualDate.current = null;
1370 if (!IsPCFaction)
1371 {
1372 return;
1373 }
1374 int num4 = 0;
1375 foreach (Chara item2 in list)
1376 {
1377 if (item2.IsPCParty)
1378 {
1379 continue;
1380 }
1381 if (!item2.IsHomeMember())
1382 {
1383 if (item2.id == "bee")
1384 {
1385 num4++;
1386 }
1387 if (num2 > 0 && item2.IsGuest())
1388 {
1389 item2.ChooseNewGoal();
1390 item2.ai.SimulateZone(num2);
1391 }
1392 continue;
1393 }
1394 if (num2 > 0)
1395 {
1396 Goal goalWork = item2.GetGoalWork();
1397 item2.SetAI(goalWork);
1398 if (goalWork is GoalWork)
1399 {
1400 (goalWork as GoalWork).FindWork(item2);
1401 }
1402 item2.ai.SimulateZone(num2);
1403 goalWork = item2.GetGoalHobby();
1404 item2.SetAI(goalWork);
1405 if (goalWork is GoalWork)
1406 {
1407 (goalWork as GoalWork).FindWork(item2);
1408 }
1409 item2.ai.SimulateZone(num2);
1410 }
1411 item2.ChooseNewGoal();
1412 if (item2.conSuspend == null)
1413 {
1414 item2.ai.OnSimulatePosition();
1415 }
1416 }
1417 List<Thing> list2 = new List<Thing>();
1418 foreach (Thing thing in map.things)
1419 {
1420 if (thing.IsInstalled && thing.trait is TraitBeekeep)
1421 {
1422 list2.Add(thing);
1423 }
1424 }
1425 if (num4 >= list2.Count)
1426 {
1427 return;
1428 }
1429 for (int j = num4; j < list2.Count; j++)
1430 {
1431 if (EClass.rnd(200) <= HourSinceLastActive)
1432 {
1433 Chara chara = CharaGen.Create("bee");
1434 AddCard(chara, list2.RandomItem().pos);
1435 Hostility c_originalHostility = (chara.hostility = Hostility.Neutral);
1436 chara.c_originalHostility = c_originalHostility;
1437 }
1438 }
1439 }
1440
1441 public Point GetSpawnPos(Chara c, ZoneTransition.EnterState destState = ZoneTransition.EnterState.Auto)
1442 {
1443 ZoneTransition zoneTransition = c.global?.transition;
1444 Zone zone = zoneTransition?.lastZone;
1445 ZoneTransition.EnterState enterState = zoneTransition?.state ?? destState;
1446 bool flag = zone == null || zone.lv > base.lv;
1447 if (IsRegion)
1448 {
1449 if (zone != null && !EClass.player.simulatingZone)
1450 {
1451 Zone topZone = zone.GetTopZone();
1452 if (GetZoneAt(topZone.x, topZone.y) != null)
1453 {
1454 return new Point(topZone.mapX, topZone.mapY);
1455 }
1456 }
1457 }
1458 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))
1459 {
1460 return EClass.player.lastZonePos;
1461 }
1462 if (enterState == ZoneTransition.EnterState.Region)
1463 {
1464 enterState = RegionEnterState;
1465 }
1466 if (this is Zone_Kapul && enterState == ZoneTransition.EnterState.Left)
1467 {
1468 enterState = ZoneTransition.EnterState.Right;
1469 }
1470 float rate = zoneTransition?.ratePos ?? (-1f);
1471 if (IsPCFaction)
1472 {
1473 if ((uint)(enterState - 3) <= 4u || enterState == ZoneTransition.EnterState.Return)
1474 {
1476 if (spot != null)
1477 {
1478 Point nearestPoint = (spot.trait as TraitSpotGuidePC).GetRandomPoint((Point p) => !p.IsBlocked && !p.Equals(spot.pos)).GetNearestPoint();
1479 if (nearestPoint != null && nearestPoint.IsValid)
1480 {
1481 return nearestPoint;
1482 }
1483 }
1484 }
1485 }
1486 while (true)
1487 {
1488 switch (enterState)
1489 {
1490 case ZoneTransition.EnterState.UndergroundOrSky:
1491 return new Point(zoneTransition.x, zoneTransition.z);
1492 case ZoneTransition.EnterState.Teleport:
1493 {
1494 foreach (Thing thing2 in map.things)
1495 {
1496 if (thing2.IsInstalled)
1497 {
1498 TraitTeleporter traitTeleporter = thing2.trait as TraitTeleporter;
1499 if (traitTeleporter != null)
1500 {
1501 Debug.Log(zoneTransition.idTele + "/" + traitTeleporter.id.IsEmpty(traitTeleporter.GetParam(3)) + "/" + traitTeleporter.GetParam(3));
1502 }
1503 if (traitTeleporter != null && !zoneTransition.idTele.IsEmpty() && zoneTransition.idTele == traitTeleporter.id.IsEmpty(traitTeleporter.GetParam(3)))
1504 {
1505 return thing2.pos.GetNearestPoint();
1506 }
1507 }
1508 }
1509 foreach (Thing thing3 in map.things)
1510 {
1511 if (thing3.IsInstalled && thing3.trait is TraitTeleporter traitTeleporter2 && traitTeleporter2.IsFor(zoneTransition.lastZone))
1512 {
1513 return thing3.pos.GetNearestPoint();
1514 }
1515 }
1516 Thing randomThing2 = EClass._map.props.installed.traits.GetRandomThing<TraitTeleporter>();
1517 if (randomThing2 != null)
1518 {
1519 return randomThing2.pos.GetNearestPoint();
1520 }
1521 goto case ZoneTransition.EnterState.Return;
1522 }
1523 case ZoneTransition.EnterState.Return:
1524 case ZoneTransition.EnterState.Elevator:
1525 case ZoneTransition.EnterState.Moongate:
1526 {
1527 if (enterState == ZoneTransition.EnterState.Elevator)
1528 {
1529 foreach (Thing thing4 in map.things)
1530 {
1531 if (thing4.IsInstalled && thing4.trait is TraitElevator traitElevator && traitElevator.IsFor(zoneTransition.lastZone))
1532 {
1533 return thing4.pos.GetNearestPoint();
1534 }
1535 }
1536 Thing randomThing = EClass._map.props.installed.traits.GetRandomThing<TraitElevator>();
1537 if (randomThing != null)
1538 {
1539 return randomThing.pos.GetNearestPoint();
1540 }
1541 }
1542 Thing thing = null;
1543 thing = map.props.installed.traits.GetRandomThing<TraitWaystone>();
1544 if (thing != null)
1545 {
1546 return thing.pos.GetNearestPoint();
1547 }
1548 thing = map.props.installed.traits.GetRandomThing<TraitCoreZone>();
1549 if (thing != null)
1550 {
1551 return thing.pos.GetNearestPoint();
1552 }
1553 if (base.lv == 0)
1554 {
1555 goto IL_04a1;
1556 }
1557 flag = base.lv <= 0;
1558 break;
1559 }
1560 case ZoneTransition.EnterState.Center:
1561 case ZoneTransition.EnterState.Encounter:
1562 if (map.config.embarkX != 0)
1563 {
1564 return new Point(map.config.embarkX, map.config.embarkY);
1565 }
1566 return map.GetCenterPos().GetNearestPoint(allowBlock: false, allowChara: false);
1567 case ZoneTransition.EnterState.Top:
1568 return map.bounds.GetTopPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1569 case ZoneTransition.EnterState.Right:
1570 return map.bounds.GetRightPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1571 case ZoneTransition.EnterState.Bottom:
1572 return map.bounds.GetBottomPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1573 case ZoneTransition.EnterState.Left:
1574 return map.bounds.GetLeftPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1575 case ZoneTransition.EnterState.Dead:
1576 case ZoneTransition.EnterState.Exact:
1577 case ZoneTransition.EnterState.PortalReturn:
1578 case ZoneTransition.EnterState.Fall:
1579 if (zoneTransition.x == 0 && EClass._map.bounds.x != 0)
1580 {
1581 return new Point(map.config.embarkX, map.config.embarkY);
1582 }
1583 return new Point(zoneTransition.x, zoneTransition.z);
1584 case ZoneTransition.EnterState.RandomVisit:
1585 return GetRandomVisitPos(c);
1586 case ZoneTransition.EnterState.Down:
1587 flag = true;
1588 break;
1589 case ZoneTransition.EnterState.Up:
1590 flag = false;
1591 break;
1592 }
1593 break;
1594 IL_04a1:
1595 enterState = ZoneTransition.EnterState.Center;
1596 }
1597 foreach (Thing thing5 in map.things)
1598 {
1599 if (thing5.trait is TraitNewZone { zone: not null } traitNewZone && zone != null && traitNewZone.zone.uid == zone.uid)
1600 {
1601 if (c != null && enterState != 0)
1602 {
1603 c.SetDir(traitNewZone.owner.dir);
1604 }
1605 return traitNewZone.GetExitPos();
1606 }
1607 }
1608 foreach (Thing thing6 in map.things)
1609 {
1610 if (thing6.trait is TraitNewZone traitNewZone2 && ((flag && traitNewZone2.IsUpstairs) || (!flag && traitNewZone2.IsDownstairs)))
1611 {
1612 if (c != null && enterState != 0)
1613 {
1614 c.SetDir(traitNewZone2.owner.dir);
1615 }
1616 return traitNewZone2.GetExitPos();
1617 }
1618 }
1619 return GetRandomVisitPos(c);
1620 }
1621
1622 public Point GetRandomVisitPos(Chara c)
1623 {
1624 Point point = null;
1625 if (EClass.rnd(3) == 0 && map.rooms.listRoom.Count > 0)
1626 {
1627 point = map.rooms.listRoom.RandomItem().points.RandomItem();
1628 }
1629 if (point == null && EClass.rnd(4) != 0)
1630 {
1631 IEnumerable<Chara> ie = map.charas.Where((Chara t) => t.trait.ShopType != 0 && t.pos != null && t.pos.IsValid);
1632 if (ie.Count() > 0)
1633 {
1634 point = ie.RandomItem().pos.GetRandomPoint(3);
1635 }
1636 }
1637 if (point == null)
1638 {
1639 point = map.bounds.GetRandomSurface(centered: false, walkable: true, !IsPCFaction && !(this is Zone_Civilized)) ?? map.bounds.GetRandomPoint();
1640 }
1641 return point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false) ?? EClass._map.GetCenterPos().GetNearestPoint();
1642 }
1643
1644 public void AddGlobalCharasOnActivate()
1645 {
1646 Point spawnPosPC = null;
1647 if (EClass.pc.currentZone == this)
1648 {
1649 spawnPosPC = GetSpawnPos(EClass.pc);
1650 }
1651 if (spawnPosPC == null)
1652 {
1653 spawnPosPC = map.GetCenterPos();
1654 }
1655 if (spawnPosPC.IsValid && EClass.pc.global.transition != null && spawnPosPC.HasBlock)
1656 {
1657 spawnPosPC = spawnPosPC.GetNearestPoint();
1658 }
1659 spawnPosPC = spawnPosPC.Clamp(useBounds: true).GetNearestPoint();
1660 foreach (Chara c in EClass.game.cards.globalCharas.Values)
1661 {
1662 if (c.currentZone != this)
1663 {
1664 continue;
1665 }
1666 if (c.parent is Chara)
1667 {
1668 Chara chara = c.parent as Chara;
1669 c.currentZone = chara.currentZone;
1670 }
1671 else
1672 {
1673 if (c.isDead)
1674 {
1675 continue;
1676 }
1677 if (c.isRestrained && c.currentZone == EClass.pc.currentZone && (!c.pos.IsValid || c.pos.FindThing<TraitShackle>() == null))
1678 {
1679 c.isRestrained = false;
1680 }
1681 if (c.global.transition != null)
1682 {
1683 Point pos = (c.IsPC ? spawnPosPC : (c.IsPCParty ? spawnPosPC.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: true, ignoreCenter: true) : GetSpawnPos(c)));
1684 if (c.IsPCParty && !c.IsPC)
1685 {
1686 if (c.host == EClass.pc)
1687 {
1688 pos.Set(spawnPosPC);
1689 }
1690 else if (pos.Equals(spawnPosPC) || !PathManager.Instance.IsPathClear(spawnPosPC, pos, c, 5))
1691 {
1692 c.pos.Set(spawnPosPC);
1693 if (!spawnPosPC.ForeachNearestPoint(delegate(Point p)
1694 {
1695 if (PathManager.Instance.IsPathClear(spawnPosPC, p, c, 10) && !p.Equals(spawnPosPC))
1696 {
1697 pos.Set(p);
1698 return true;
1699 }
1700 return false;
1701 }, allowBlock: false, EClass.pc.party.members.Count >= 12, allowInstalled: true, ignoreCenter: true, EClass._zone.IsRegion ? 2 : 6))
1702 {
1703 pos.Set(spawnPosPC);
1704 }
1705 }
1706 }
1707 c.pos.Set(pos);
1708 c.global.transition = null;
1709 }
1710 map.charas.Add(c);
1711 map.AddCardOnActivate(c);
1712 }
1713 }
1715 {
1716 Point nearestPoint = spawnPosPC.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: true, ignoreCenter: true);
1717 item.enemy = null;
1718 item.pos.Set(nearestPoint);
1719 map.charas.Add(item);
1720 map.AddCardOnActivate(item);
1721 }
1723 }
1724
1725 public void Deactivate()
1726 {
1727 if (!IsUserZone && !IsPCFaction && map != null)
1728 {
1729 List<Thing> list = new List<Thing>();
1730 foreach (Thing thing in map.things)
1731 {
1732 if (thing.rarity >= Rarity.Artifact && thing.HasTag(CTAG.godArtifact))
1733 {
1734 list.Add(thing);
1735 }
1736 }
1737 if (this is Zone_Tent)
1738 {
1739 foreach (Thing item in map.props.stocked.Things.Concat(map.props.roaming.Things))
1740 {
1741 if (item.IsContainer)
1742 {
1743 foreach (Thing thing2 in item.things)
1744 {
1745 if (thing2.trait is TraitTent)
1746 {
1747 list.Add(thing2);
1748 }
1749 }
1750 }
1751 if (item.trait is TraitTent)
1752 {
1753 list.Add(item);
1754 }
1755 }
1756 }
1757 if (list.Count > 0)
1758 {
1759 Msg.Say("pick_valuable");
1760 foreach (Thing item2 in list)
1761 {
1762 Msg.Say("pick_valuable2", item2);
1763 EClass.pc.AddCard(item2);
1764 }
1765 }
1766 }
1768 {
1769 base.isPeace = false;
1770 }
1771 OnBeforeDeactivate();
1772 if (IsPCFaction)
1773 {
1774 foreach (Chara member in branch.members)
1775 {
1776 member.ValidateWorks();
1777 }
1778 }
1779 EClass.game.lastActiveZone = EClass.game.activeZone;
1780 base.lastActive = EClass.world.date.GetRaw();
1781 map.OnDeactivate();
1782 EClass.scene.Clear();
1783 EClass.game.activeZone = null;
1784 if (IsInstance)
1785 {
1786 UnloadMap();
1787 base.isGenerated = false;
1788 }
1789 if (forceRegenerate)
1790 {
1791 UnloadMap();
1792 }
1793 OnDeactivate();
1794 }
1795
1796 public void OnKillGame()
1797 {
1798 foreach (Thing thing in map.things)
1799 {
1800 if (thing.renderer.hasActor)
1801 {
1802 thing.renderer.KillActor();
1803 }
1804 }
1805 }
1806
1807 public void UnloadMap()
1808 {
1809 map = null;
1810 if (bp != null)
1811 {
1812 bp.map = null;
1813 }
1814 if (branch != null)
1815 {
1816 branch.OnUnloadMap();
1817 }
1818 Debug.Log("Unloaded Map:" + this);
1819 }
1820
1821 public void ClaimZone(bool debug = false, Point pos = null)
1822 {
1824 SetMainFaction(EClass.pc.faction);
1825 branch = new FactionBranch();
1826 branch.OnCreate(this);
1827 if (base.icon == 0)
1828 {
1829 base.icon = 332;
1830 }
1831 instance = null;
1832 base.dateExpire = 0;
1833 SetInt(2, EClass.world.date.GetRaw());
1834 Register();
1835 foreach (Thing thing in map.things)
1836 {
1837 thing.isNPCProperty = false;
1838 }
1841 if (debug)
1842 {
1843 for (int i = 0; i < 7; i++)
1844 {
1845 Chara chara = CharaGen.CreateFromFilter("c_neutral");
1846 EClass._zone.AddCard(chara, EClass._map.bounds.GetRandomPoint().GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false));
1847 branch.AddMemeber(chara);
1848 }
1849 }
1850 else
1851 {
1852 Msg.Say("claimedZone");
1853 EClass.Branch.Log("claimedZone");
1854 EClass.Sound.Play("jingle_embark");
1855 EClass.pc.PlaySound("build");
1856 if (pos == null)
1857 {
1858 pos = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: true, allowInstalled: false);
1859 }
1860 Effect.Get("aura_heaven").Play(pos);
1861 EClass._zone.AddCard(ThingGen.Create("core_zone"), pos).SetPlaceState(PlaceState.installed);
1862 }
1863 base.idPrefix = 0;
1865 {
1866 EClass.player.spawnZone = EClass._zone;
1867 }
1869 {
1870 EClass._zone.SetBGM(new List<int> { 41, 90, 44, 43 });
1872 }
1873 }
1874
1875 public void AbandonZone()
1876 {
1877 FactionBranch destBranch = ((EClass.pc.homeBranch == branch) ? EClass.game.StartZone.branch : EClass.pc.homeBranch);
1878 branch.members.ForeachReverse(delegate(Chara m)
1879 {
1880 destBranch.AddMemeber(m);
1881 if (!m.IsPCParty)
1882 {
1883 m.MoveZone(destBranch.owner);
1884 }
1885 });
1887 SetMainFaction(null);
1888 base.dateExpire = EClass.world.date.GetRaw() + 10080;
1889 }
1890
1891 public bool CanDestroy()
1892 {
1893 if (IsActiveZone || IsPCFaction || EClass.player.simulatingZone)
1894 {
1895 return false;
1896 }
1897 if (IsInstance)
1898 {
1899 return true;
1900 }
1901 bool flag = false;
1902 switch (id)
1903 {
1904 case "cave_dragon":
1905 if (!(this is Zone_DungeonDragon))
1906 {
1907 flag = true;
1908 }
1909 break;
1910 case "cave_yeek":
1911 if (!(this is Zone_DungeonYeek))
1912 {
1913 flag = true;
1914 }
1915 break;
1916 case "cave_mino":
1917 if (!(this is Zone_DungeonMino))
1918 {
1919 flag = true;
1920 }
1921 break;
1922 case "cave_dead":
1923 if (!(this is Zone_DungeonDead))
1924 {
1925 flag = true;
1926 }
1927 break;
1928 }
1929 Zone topZone = GetTopZone();
1930 if (!flag)
1931 {
1932 if (base.dateExpire == 0 || !EClass.world.date.IsExpired(base.dateExpire))
1933 {
1934 return false;
1935 }
1936 if (!base.isRandomSite && !(this is Zone_Field) && (topZone == null || topZone == this || topZone.FindDeepestZone() == this))
1937 {
1938 return false;
1939 }
1940 }
1941 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()))
1942 {
1943 return false;
1944 }
1946 {
1948 if (zone != null && zone.GetTopZone() == this)
1949 {
1950 return false;
1951 }
1952 }
1953 return true;
1954 }
1955
1956 public override void _OnBeforeSave()
1957 {
1958 if (CanDestroy())
1959 {
1960 Debug.Log("Deleting Zone:" + this);
1961 if (!destryoed)
1962 {
1963 Destroy();
1964 }
1965 }
1966 else if (map != null)
1967 {
1968 Debug.Log("Saving Zone:" + this);
1969 map.Save(base.pathSave);
1970 if (!base.isMapSaved)
1971 {
1972 base.isMapSaved = true;
1973 IO.DeleteDirectory(base.pathSave + "Texture Replace");
1974 IO.CopyDir(pathTemp + "Texture Replace", base.pathSave + "/Texture Replace");
1975 }
1976 if (!IsActiveZone)
1977 {
1978 UnloadMap();
1979 }
1980 }
1981 }
1982
1983 public override void OnLoad()
1984 {
1985 if (branch != null)
1986 {
1987 branch.SetOwner(this);
1988 }
1989 events.OnLoad(this);
1990 }
1991
1992 public override void Destroy()
1993 {
1994 children.ForeachReverse(delegate(Spatial z)
1995 {
1996 z.Destroy();
1997 });
1998 if (map != null)
1999 {
2000 UnloadMap();
2001 }
2002 if (parent != null && parent.IsRegion && instance == null)
2003 {
2004 EClass.scene.elomap.SetZone(base.x, base.y, null, updateMesh: true);
2005 }
2006 EClass.game.spatials.Remove(this);
2007 destryoed = true;
2008 base.isGenerated = false;
2009 }
2010
2011 public void ClearZones(Zone current = null)
2012 {
2013 if (map != null)
2014 {
2015 UnloadMap();
2016 }
2017 base.isGenerated = false;
2018 Zone topZone = GetTopZone();
2019 if (topZone != this)
2020 {
2021 topZone.ClearZones(this);
2022 return;
2023 }
2024 children.ForeachReverse(delegate(Spatial c)
2025 {
2026 if (c != current)
2027 {
2028 c.Destroy();
2029 }
2030 });
2031 }
2032
2033 public void OnChildNumChange(Card c)
2034 {
2035 }
2036
2037 public ICardParent GetRoot()
2038 {
2039 return this;
2040 }
2041
2042 public Zone GetTopZone()
2043 {
2044 if (parent == null || parent.IsRegion)
2045 {
2046 return this;
2047 }
2048 return parent as Zone;
2049 }
2050
2051 public Card AddCardSplinkle(Card t, Point center, int radius = 4)
2052 {
2053 Point point = new Point(center);
2054 for (int i = 0; i < 1000; i++)
2055 {
2056 point.x = center.x + EClass.rnd(radius) - EClass.rnd(radius);
2057 point.z = center.z + EClass.rnd(radius) - EClass.rnd(radius);
2058 if (point.IsValid && !point.IsBlocked && !point.HasChara)
2059 {
2060 return AddCard(t, point);
2061 }
2062 }
2063 return AddCard(t, center);
2064 }
2065
2066 public Chara AddChara(string id, int x, int z)
2067 {
2068 return AddCard(CharaGen.Create(id), x, z) as Chara;
2069 }
2070
2071 public Chara AddChara(string id, Point p)
2072 {
2073 return AddChara(id, p.x, p.z);
2074 }
2075
2076 public Card AddThing(string id, int x, int z)
2077 {
2078 return AddCard(ThingGen.Create(id), x, z);
2079 }
2080
2081 public Card AddThing(string id, Point p)
2082 {
2083 return AddThing(id, p.x, p.z);
2084 }
2085
2086 public Card AddCard(Card t, Point point)
2087 {
2088 return AddCard(t, point.x, point.z);
2089 }
2090
2091 public Card AddCard(Card t)
2092 {
2093 return AddCard(t, 0, 0);
2094 }
2095
2096 public Card AddCard(Card t, int x, int z)
2097 {
2098 if (t.parent != null)
2099 {
2100 t.parent.RemoveCard(t);
2101 }
2102 t.parent = this;
2103 Chara chara = t.Chara;
2104 if (chara != null)
2105 {
2106 chara.currentZone = this;
2107 chara.SetAI(new NoGoal());
2108 }
2109 if (IsActiveZone)
2110 {
2111 map.OnCardAddedToZone(t, x, z);
2112 if (isStarted && t.isThing && t.placeState == PlaceState.roaming && !ignoreSpawnAnime)
2113 {
2114 t.PlayAnimeLoot();
2115 }
2116 ignoreSpawnAnime = false;
2117 }
2118 if (chara != null && EClass.player != null && !chara.hasSpawned)
2119 {
2120 EClass.player.codex.AddSpawn(chara.id);
2121 chara.hasSpawned = true;
2122 }
2123 return t;
2124 }
2125
2126 public void RemoveCard(Card t)
2127 {
2128 if (IsActiveZone)
2129 {
2130 map.OnCardRemovedFromZone(t);
2131 }
2132 t.parent = null;
2133 if (t.isChara)
2134 {
2135 t.Chara.currentZone = null;
2136 }
2137 if (t.isThing && !t.trait.IDActorEx.IsEmpty())
2138 {
2140 }
2141 if (t.renderer.hasActor)
2142 {
2144 }
2145 }
2146
2147 public T GetRandomSpot<T>() where T : Trait
2148 {
2149 return EClass._map.props.installed.traits.GetRandomThing<T>() as T;
2150 }
2151
2152 public bool TryAddThingInSpot<T>(Thing t, bool useContainer = true) where T : Trait
2153 {
2154 Thing randomThing = EClass._map.props.installed.traits.GetRandomThing<T>();
2155 if (randomThing == null)
2156 {
2157 AddCard(t, EClass._map.bounds.GetRandomSurface());
2158 return false;
2159 }
2160 if (useContainer && (!t.IsContainer || t.things.Count == 0))
2161 {
2162 List<Thing> list = new List<Thing>();
2163 foreach (Point item in randomThing.trait.ListPoints(null, onlyPassable: false))
2164 {
2165 foreach (Card item2 in item.ListCards())
2166 {
2167 if (item2.IsContainer && !(item2.trait is TraitDeliveryChest))
2168 {
2169 list.Add(item2.Thing);
2170 }
2171 }
2172 }
2173 if (TryAddThingInSharedContainer(t, list, add: true, msg: false, null, sharedOnly: false))
2174 {
2175 return true;
2176 }
2177 }
2178 AddCard(t, randomThing.trait.GetRandomPoint());
2179 return true;
2180 }
2181
2182 public List<Thing> TryListThingsInSpot<T>(Func<Thing, bool> func = null) where T : TraitSpot
2183 {
2184 List<T> list = new List<T>();
2185 List<Thing> list2 = new List<Thing>();
2186 foreach (Thing thing in EClass._map.things)
2187 {
2188 if (thing.IsInstalled && thing.trait is T)
2189 {
2190 list.Add(thing.trait as T);
2191 }
2192 }
2193 foreach (T item in list)
2194 {
2195 foreach (Point item2 in item.ListPoints(null, onlyPassable: false))
2196 {
2197 foreach (Thing thing2 in item2.Things)
2198 {
2199 if (!thing2.IsInstalled)
2200 {
2201 continue;
2202 }
2203 if (thing2.things.Count == 0)
2204 {
2205 if (IsValid(thing2))
2206 {
2207 list2.Add(thing2);
2208 }
2209 continue;
2210 }
2211 foreach (Thing item3 in thing2.things.List((Thing _t) => IsValid(_t)))
2212 {
2213 list2.Add(item3);
2214 }
2215 }
2216 }
2217 }
2218 return list2;
2219 bool IsValid(Thing t)
2220 {
2221 if (func != null && !func(t))
2222 {
2223 return false;
2224 }
2225 return true;
2226 }
2227 }
2228
2229 public bool TryAddThingInSharedContainer(Thing t, List<Thing> containers = null, bool add = true, bool msg = false, Chara chara = null, bool sharedOnly = true)
2230 {
2231 Thing dest = null;
2232 int priority = -1;
2233 ContainerFlag flag = t.category.GetRoot().id.ToEnum<ContainerFlag>();
2234 if (flag == ContainerFlag.none)
2235 {
2236 flag = ContainerFlag.other;
2237 }
2238 if (containers == null)
2239 {
2240 containers = EClass._map.props.installed.containers;
2241 }
2242 if (SearchDest() != null)
2243 {
2244 return true;
2245 }
2246 if (dest == null)
2247 {
2248 return false;
2249 }
2250 if (add)
2251 {
2252 if (msg)
2253 {
2254 chara.Say("putSharedItem", chara, t, dest.GetName(NameStyle.Full));
2255 }
2256 dest.AddThing(t);
2257 }
2258 return true;
2259 Thing SearchDest()
2260 {
2261 foreach (Thing container in containers)
2262 {
2263 Thing thing = container;
2264 if (thing.trait is TraitShippingChest)
2265 {
2267 }
2268 if ((!sharedOnly || thing.IsSharedContainer) && thing.c_lockLv <= 0 && (thing.things.Count < thing.things.MaxCapacity || thing.things.CanStack(t) != t))
2269 {
2270 Window.SaveData windowSaveData = thing.GetWindowSaveData();
2271 if (windowSaveData != null)
2272 {
2273 if (windowSaveData.priority <= priority || (windowSaveData.noRotten && t.IsDecayed) || (windowSaveData.onlyRottable && t.trait.Decay == 0))
2274 {
2275 continue;
2276 }
2278 if (windowSaveData.userFilter)
2279 {
2280 filterResult = windowSaveData.IsFilterPass(t.GetName(NameStyle.Full, 1));
2281 if (filterResult == Window.SaveData.FilterResult.Block)
2282 {
2283 continue;
2284 }
2285 }
2286 if (filterResult != Window.SaveData.FilterResult.PassWithoutFurtherTest)
2287 {
2288 if (windowSaveData.advDistribution)
2289 {
2290 bool flag2 = false;
2291 foreach (int cat in windowSaveData.cats)
2292 {
2293 if (t.category.uid == cat)
2294 {
2295 flag2 = true;
2296 break;
2297 }
2298 }
2299 if (!flag2)
2300 {
2301 continue;
2302 }
2303 }
2304 else if (windowSaveData.flag.HasFlag(flag))
2305 {
2306 continue;
2307 }
2308 }
2309 priority = windowSaveData.priority;
2310 }
2311 else
2312 {
2313 if (priority != -1)
2314 {
2315 continue;
2316 }
2317 priority = 0;
2318 }
2319 dest = thing;
2320 }
2321 }
2322 return null;
2323 }
2324 }
2325
2326 public bool TryAddThing(Thing target, Point p, bool destroyIfFail = false)
2327 {
2328 int num = 0;
2329 if (p.cell.detail != null)
2330 {
2331 foreach (Thing thing in p.cell.detail.things)
2332 {
2333 if (thing.placeState == PlaceState.roaming)
2334 {
2335 if (target.TryStackTo(thing))
2336 {
2337 return true;
2338 }
2339 num++;
2340 }
2341 }
2342 }
2343 if (num == 0 || !destroyIfFail)
2344 {
2345 EClass._zone.AddCard(target, p);
2346 return true;
2347 }
2348 target.Destroy();
2349 return false;
2350 }
2351
2352 public Thing TryGetThingFromSharedContainer(Func<Thing, bool> func)
2353 {
2354 foreach (Thing container in EClass._map.props.installed.containers)
2355 {
2356 if (container.IsSharedContainer)
2357 {
2358 Thing thing = container.things.Find(func);
2359 if (thing != null)
2360 {
2361 return thing;
2362 }
2363 }
2364 }
2365 return null;
2366 }
2367
2368 public Thing TryGetRestock<T>(string idCat) where T : TraitSpot
2369 {
2370 List<T> list = new List<T>();
2371 foreach (Thing thing2 in EClass._map.things)
2372 {
2373 if (thing2.IsInstalled && thing2.trait is T)
2374 {
2375 list.Add(thing2.trait as T);
2376 }
2377 }
2378 foreach (T item in list)
2379 {
2380 foreach (Point item2 in item.ListPoints(null, onlyPassable: false))
2381 {
2382 foreach (Thing thing3 in item2.Things)
2383 {
2384 if (!thing3.IsInstalled || thing3.isSale)
2385 {
2386 continue;
2387 }
2388 if (thing3.things.Count == 0)
2389 {
2390 if (IsValid(thing3, insideContainer: false))
2391 {
2392 return thing3;
2393 }
2394 continue;
2395 }
2396 Thing thing = thing3.things.Find((Thing _t) => IsValid(_t, insideContainer: true));
2397 if (thing != null)
2398 {
2399 return thing;
2400 }
2401 }
2402 }
2403 }
2404 return null;
2405 bool IsValid(Thing t, bool insideContainer)
2406 {
2407 if (t.category.id != idCat || !TraitSalesTag.CanTagSale(t, insideContainer))
2408 {
2409 return false;
2410 }
2411 return true;
2412 }
2413 }
2414
2415 public ZoneProfile GetProfile()
2416 {
2417 string text = IdProfile;
2418 if (text.IsEmpty())
2419 {
2420 Region region = parent as Region;
2421 if (base.lv != 0)
2422 {
2423 text = ((base.lv < 0) ? "Underground" : "Sky");
2424 }
2425 else if (region != null)
2426 {
2428 text = EClass.scene.elomapActor.elomap.GetTileInfo(base.x, base.y).idZoneProfile;
2429 if (bp != null)
2430 {
2431 name = Lang.GetList("zone_" + text.Split('/')[1]).RandomItem();
2432 bp.surrounding = new EloMap.TileInfo[3, 3];
2433 for (int i = 0; i < 3; i++)
2434 {
2435 for (int j = 0; j < 3; j++)
2436 {
2437 bp.surrounding[j, i] = EClass.scene.elomapActor.elomap.GetTileInfo(base.x - 1 + j, base.y - 1 + i);
2438 }
2439 }
2440 if (text == "Random/R_Shore")
2441 {
2442 base.isBeach = true;
2443 }
2444 }
2445 }
2446 else
2447 {
2448 text = "Random";
2449 }
2450 idProfile = text;
2451 }
2452 return ZoneProfile.Load(text);
2453 }
2454
2455 public void CreateBP()
2456 {
2457 bp = new ZoneBlueprint();
2458 bp.Create();
2459 bp.genSetting.seed = base.Seed;
2460 OnCreateBP();
2461 }
2462
2463 public virtual void OnCreateBP()
2464 {
2465 }
2466
2467 public void Generate()
2468 {
2469 base.isGenerated = true;
2470 if (bp == null)
2471 {
2472 CreateBP();
2473 }
2474 if (bp.map == null)
2475 {
2476 bp.GenerateMap(this);
2477 }
2478 map.SetZone(this);
2479 Zone_Field zone_Field = this as Zone_Field;
2480 bool flag = IdBiome == "Sand" || IdBiome == "Water" || IsUnderwater;
2481 if (flag)
2482 {
2483 int num = 1 + EClass.rnd((IdBiome == "Water") ? 3 : 2);
2484 for (int i = 0; i < num; i++)
2485 {
2486 Point randomSurface = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2487 if (!randomSurface.HasObj && !randomSurface.HasThing)
2488 {
2489 Thing t = ThingGen.Create("pearl_oyster", new string[3] { "wood_birch", "poplar", "coralwood" }.RandomItem(), ContentLv);
2490 EClass._zone.AddCard(t, randomSurface).Install();
2491 }
2492 }
2493 num = 4 + EClass.rnd(5);
2494 for (int j = 0; j < num; j++)
2495 {
2496 Point randomSurface2 = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2497 if (!randomSurface2.HasObj && !randomSurface2.HasThing && (IsUnderwater || randomSurface2.cell.IsTopWaterAndNoSnow || EClass.rnd(6) == 0))
2498 {
2499 EClass._zone.AddCard(ThingGen.Create("70", -1, ContentLv), randomSurface2);
2500 }
2501 }
2502 for (int k = 0; k < EClass.rnd(EClass.rnd(base.isBeach ? 5 : 3) + 1); k++)
2503 {
2504 Point randomSurface3 = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2505 if (!randomSurface3.HasObj)
2506 {
2507 EClass._zone.AddCard(ThingGen.Create("bottle_message"), randomSurface3);
2508 }
2509 }
2510 }
2511 if (IsUnderwater)
2512 {
2513 for (int l = 0; l < 30 + EClass.rnd(30); l++)
2514 {
2515 SpawnMob(null, SpawnSetting.Fish());
2516 }
2517 Crawler crawler = Crawler.Create("pasture");
2518 int num2 = (EClass.debug.enable ? 3 : EClass.rnd(EClass.rnd(EClass.rnd(EClass.rnd(5) + 1) + 1) + 1));
2519 bool flag2 = this is Zone_Field;
2520 Thing seed = null;
2521 if (IsNefia)
2522 {
2523 int num3 = Mathf.Min(EClass._zone.DangerLv, EClass.pc.Evalue(286) * 2 / 3);
2524 if (num3 > 0)
2525 {
2527 Rand.SetSeed(EClass._zone.uid * 10 + num3);
2528 TraitSeed.LevelSeed(seed, (seed.trait as TraitSeed).row, num3);
2529 Rand.SetSeed();
2530 seed.elements.SetBase(2, EClass.curve(seed.encLV, 50, 10, 80));
2531 }
2532 }
2533 crawler.CrawlUntil(EClass._map, () => EClass._map.GetRandomPoint(), num2 + (flag2 ? 4 : 0), delegate(Crawler.Result r)
2534 {
2535 int num6 = 137;
2536 foreach (Point point in r.points)
2537 {
2538 if (!point.cell.isModified && !point.HasThing && !point.HasBlock && !point.HasObj)
2539 {
2540 map.SetObj(point.x, point.z, num6);
2541 int idx = 3 + ((EClass.rnd(3) == 0) ? 1 : 0) + ((EClass.rnd(3) == 0) ? (-1) : 0) + ((EClass.rnd(3) == 0) ? (-1) : 0);
2542 point.growth.SetStage(idx);
2543 if (seed != null)
2544 {
2545 EClass._map.AddPlant(point, seed);
2546 }
2547 }
2548 }
2549 return false;
2550 });
2551 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)
2552 {
2553 int num5 = 136;
2554 foreach (Point point2 in r.points)
2555 {
2556 if (!point2.cell.isModified && !point2.HasThing && !point2.HasBlock && !point2.HasObj)
2557 {
2558 map.SetObj(point2.x, point2.z, num5, 1, EClass.rnd(4));
2559 }
2560 }
2561 return false;
2562 });
2563 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)
2564 {
2565 int idFloor = 121;
2566 foreach (Point point3 in r.points)
2567 {
2568 map.SetFloor(point3.x, point3.z, 97, idFloor, Mathf.Clamp(4 - r.startPos.Distance(point3) + EClass.rnd(3) - EClass.rnd(3), 0, 3));
2569 }
2570 return false;
2571 });
2572 }
2573 if (zone_Field != null)
2574 {
2575 if (EClass.rnd(3) == 0)
2576 {
2577 int num4 = EClass.rnd(2);
2578 for (int m = 0; m < num4; m++)
2579 {
2580 Point randomSurface4 = EClass._map.bounds.GetRandomSurface();
2581 if (!randomSurface4.HasObj && !randomSurface4.HasThing)
2582 {
2583 Card t2 = ThingGen.Create("chest3").ChangeMaterial(biome.style.matDoor);
2584 EClass._zone.AddCard(t2, randomSurface4).Install();
2585 }
2586 }
2587 }
2588 if (EClass.rnd(8) == 0)
2589 {
2590 SpawnAltar();
2591 }
2592 TrySpawnFollower();
2593 if (!flag && EClass.rnd(EClass.debug.enable ? 1 : 10) == 0)
2594 {
2595 Point randomSurface5 = EClass._map.bounds.GetRandomSurface();
2596 if (randomSurface5.IsValid)
2597 {
2598 EClass._zone.AddCard(CharaGen.Create("priest"), randomSurface5);
2599 }
2600 }
2601 if (base.Tile.isRoad)
2602 {
2603 for (int n = 0; n < EClass.rnd(4); n++)
2604 {
2605 EClass._zone.SpawnMob(map.GetCenterPos().GetRandomPointInRadius(2, 6, requireLos: false, allowChara: false), SpawnSetting.HomeGuest(EClass._zone.DangerLv));
2606 }
2607 }
2608 }
2609 map.plDay = CreatePlaylist(ref map._plDay, EClass.Sound.GetPlaylist(IDPlayList) ?? EClass.Sound.GetPlaylist("Day"));
2610 }
2611
2612 public void TrySpawnFollower()
2613 {
2614 bool flag = EClass.pc.HasCondition<ConDrawBacker>();
2615 if (!EClass.debug.enable && EClass.rnd(flag ? 3 : 20) != 0)
2616 {
2617 return;
2618 }
2619 Point randomSurface = EClass._map.bounds.GetRandomSurface();
2620 if (!randomSurface.IsValid)
2621 {
2622 return;
2623 }
2624 Chara c = CharaGen.Create("follower");
2625 EClass._zone.AddCard(c, randomSurface);
2626 (EClass._zone.AddThing("gallows", randomSurface).Install().trait as TraitShackle).Restrain(c);
2627 c.c_rescueState = RescueState.WaitingForRescue;
2628 if (EClass.rnd(flag ? 1 : 2) == 0 || EClass.debug.enable)
2629 {
2631 if (row != null)
2632 {
2633 c.ApplyBacker(row.id);
2634 }
2635 }
2636 Religion faith = EClass.game.religions.dictAll.Values.Where((Religion a) => a != c.faith).RandomItem();
2637 for (int i = 0; i < 3 + EClass.rnd(4); i++)
2638 {
2639 Chara chara = CharaGen.Create("fanatic");
2640 chara.SetFaith(faith);
2641 Point point = randomSurface.GetRandomPoint(4) ?? randomSurface.GetNearestPoint();
2642 EClass._zone.AddCard(chara, point);
2643 }
2644 }
2645
2646 public void SpawnAltar()
2647 {
2648 EClass.core.refs.crawlers.start.CrawlUntil(map, () => map.poiMap.GetCenterCell().GetCenter(), 1, delegate(Crawler.Result r)
2649 {
2650 if (r.points.Count <= 4)
2651 {
2652 return false;
2653 }
2654 map.poiMap.OccyupyPOI(r.points[0]);
2655 List<Point> points = r.points;
2656 Religion randomReligion = EClass.game.religions.GetRandomReligion();
2657 "altarPoint".lang(randomReligion.NameDomain.lang());
2658 Thing thing = ThingGen.Create("altar");
2659 (thing.trait as TraitAltar).SetDeity(randomReligion.id);
2660 Chara t = CharaGen.Create("twintail");
2661 EClass._zone.AddCard(t, points.RandomItem());
2662 for (int i = 0; i < 2 + EClass.rnd(2); i++)
2663 {
2664 Chara t2 = CharaGen.Create("twintail");
2665 EClass._zone.AddCard(t2, points.RandomItem());
2666 }
2667 if (points[0].Installed == null)
2668 {
2669 EClass._zone.AddCard(thing, points[0]).Install();
2670 }
2671 foreach (Point item in points)
2672 {
2673 if (item.x % 3 == 0 && item.z % 2 == 0 && item != points[0] && !item.Equals(points[0].Front) && item.Installed == null)
2674 {
2675 thing = ThingGen.Create("pillar1");
2676 EClass._zone.AddCard(thing, item).Install();
2677 }
2678 item.SetObj();
2679 item.SetFloor(3, 6);
2680 }
2681 return true;
2682 });
2683 }
2684
2685 public virtual void OnGenerateMap()
2686 {
2687 if (MakeEnemiesNeutral)
2688 {
2689 foreach (Chara chara in EClass._map.charas)
2690 {
2691 if (!chara.IsGlobal && chara.hostility < Hostility.Neutral && chara.OriginalHostility < Hostility.Friend)
2692 {
2693 Hostility hostility2 = (chara.c_originalHostility = Hostility.Neutral);
2694 chara.hostility = hostility2;
2695 }
2696 }
2697 }
2698 if (PrespawnRate != 0f && !IsSkyLevel)
2699 {
2700 for (int i = 0; i < (int)((float)MaxSpawn * PrespawnRate); i++)
2701 {
2702 SpawnMob();
2703 }
2704 }
2705 TryGenerateOre();
2706 TryGenerateBigDaddy();
2707 TryGenerateEvolved();
2708 TryGenerateShrine();
2709 }
2710
2711 public void TryGenerateOre()
2712 {
2713 if (OreChance <= 0f)
2714 {
2715 return;
2716 }
2717 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)
2718 {
2719 byte b = 18;
2720 string group = "ore";
2721 if (EClass.rnd(5) == 0)
2722 {
2723 b++;
2724 group = "gem";
2725 }
2726 SourceMaterial.Row randomMaterial = MATERIAL.GetRandomMaterial(DangerLv, group);
2727 foreach (Point point in r.points)
2728 {
2729 if (point.sourceBlock.ContainsTag("ore"))
2730 {
2731 map.SetObj(point.x, point.z, randomMaterial.id, b, 1, 0);
2732 }
2733 }
2734 return false;
2735 });
2736 }
2737
2738 public Chara TryGenerateEvolved(bool force = false, Point p = null)
2739 {
2740 float num = EvolvedChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f);
2741 if (!force && num <= EClass.rndf(1f))
2742 {
2743 return null;
2744 }
2745 Chara chara = SpawnMob(p, SpawnSetting.Evolved());
2746 for (int i = 0; i < 2 + EClass.rnd(2); i++)
2747 {
2748 chara.ability.AddRandom();
2749 }
2750 chara.AddThing(chara.MakeGene(DNA.Type.Default));
2751 if (EClass.rnd(2) == 0)
2752 {
2753 chara.AddThing(chara.MakeGene(DNA.Type.Superior));
2754 }
2755 return chara;
2756 }
2757
2758 public void TryGenerateBigDaddy()
2759 {
2760 if (!(BigDaddyChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f) <= EClass.rndf(1f)))
2761 {
2762 Point spawnPos = GetSpawnPos(SpawnPosition.Random, 10000);
2763 List<string> list = new List<string> { "big_daddy", "big_daddy2" };
2764 list.Shuffle();
2765 Spawn(list[0], spawnPos);
2766 if (EClass.rnd(EClass.debug.enable ? 2 : 20) == 0)
2767 {
2768 Spawn(list[1], spawnPos.GetNearestPoint(allowBlock: false, allowChara: false));
2769 }
2770 Msg.Say("sign_bigdaddy");
2771 }
2772 void Spawn(string id, Point pos)
2773 {
2774 int num = (int)((long)DangerLv * 125L / 100);
2775 if (num >= 30)
2776 {
2778 {
2779 lv = num
2780 });
2781 }
2782 Chara chara = CharaGen.Create(id);
2783 if (EClass.pc.HasElement(1270))
2784 {
2785 chara.SetHostility(Hostility.Friend);
2786 }
2787 else if (EClass.pc.HasElement(1271))
2788 {
2789 chara.SetHostility(Hostility.Enemy);
2790 }
2791 EClass._zone.AddCard(chara, pos);
2792 }
2793 }
2794
2795 public void TryGenerateShrine()
2796 {
2797 float num = ShrineChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f);
2798 for (int i = 0; i < 3; i++)
2799 {
2800 Rand.SetSeed(base.uid + i);
2801 if (num <= EClass.rndf(1f))
2802 {
2803 continue;
2804 }
2805 Point randomSpace = EClass._map.GetRandomSpace(3, 3);
2806 if (randomSpace == null)
2807 {
2808 continue;
2809 }
2810 randomSpace.x++;
2811 randomSpace.z++;
2812 if (randomSpace.HasThing || randomSpace.HasChara)
2813 {
2814 continue;
2815 }
2816 randomSpace.SetObj();
2819 if (EClass.rnd(EClass.debug.test ? 2 : 15) == 0)
2820 {
2821 EClass._zone.AddCard(ThingGen.Create("pedestal_power"), randomSpace).Install();
2822 EClass._zone.AddCard(ThingGen.Create(EClass.gamedata.godStatues.RandomItemWeighted((GodStatueData a) => a.chance).idThing, -1, DangerLv), randomSpace).Install();
2823 }
2824 else
2825 {
2826 EClass._zone.AddCard(ThingGen.Create("statue_power", -1, DangerLv), randomSpace).Install().SetRandomDir();
2827 }
2828 }
2829 Rand.SetSeed();
2830 }
2831
2832 public void ResetHostility()
2833 {
2834 foreach (Chara chara in EClass._map.charas)
2835 {
2836 if (!chara.source.hostility.IsEmpty() && chara.source.hostility.ToEnum<Hostility>() >= Hostility.Friend && !chara.IsPCFactionOrMinion)
2837 {
2838 chara.c_originalHostility = (Hostility)0;
2839 }
2840 chara.hostility = chara.OriginalHostility;
2841 if (chara.enemy != null && (chara.enemy.IsPCFaction || chara.IsPCFaction))
2842 {
2843 chara.SetEnemy();
2844 }
2845 }
2846 }
2847
2848 public virtual void OnGenerateRooms(BaseMapGen gen)
2849 {
2850 }
2851
2852 public Point GetSpawnPos(SpawnPosition type, int tries = 100)
2853 {
2854 Point point = new Point();
2855 for (int i = 0; i < tries; i++)
2856 {
2857 point = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2858 if (!point.IsValid || point.cell.hasDoor || point.IsSync)
2859 {
2860 continue;
2861 }
2862 switch (type)
2863 {
2864 case SpawnPosition.Guest:
2865 {
2866 Room room = point.cell.room;
2867 if (room != null && room.data.accessType != 0)
2868 {
2869 continue;
2870 }
2871 break;
2872 }
2873 case SpawnPosition.Outside:
2874 if (point.cell.HasRoof || point.cell.light > 0)
2875 {
2876 continue;
2877 }
2878 break;
2879 }
2880 return point;
2881 }
2882 return null;
2883 }
2884
2885 public Chara SpawnMob(string id, Point pos = null)
2886 {
2887 return SpawnMob(pos, new SpawnSetting
2888 {
2889 id = id
2890 });
2891 }
2892
2893 public Chara SpawnMob(Point pos = null, SpawnSetting setting = null)
2894 {
2895 if (setting == null)
2896 {
2897 setting = SpawnSetting.Default;
2898 }
2899 if (pos == null)
2900 {
2901 pos = GetSpawnPos(setting.position, setting.tries);
2902 if (pos == null)
2903 {
2904 pos = GetSpawnPos(SpawnPosition.Random, setting.tries);
2905 if (pos == null)
2906 {
2907 return null;
2908 }
2909 }
2910 }
2911 BiomeProfile biome = pos.cell.biome;
2912 if (IsUnderwater && EClass.rnd(15) != 0)
2913 {
2914 biome = ((EClass.rnd(4) != 0) ? EClass.core.refs.biomes.Water : EClass.core.refs.biomes.Sand);
2915 }
2916 SpawnList spawnList = null;
2917 if (setting.idSpawnList != null)
2918 {
2919 spawnList = SpawnList.Get(setting.idSpawnList);
2920 }
2921 else if (EClass._zone is Zone_DungeonYeek && EClass.rnd(5) != 0)
2922 {
2923 spawnList = SpawnListChara.Get("dungeon_yeek", (SourceChara.Row r) => r.race == "yeek" && r.quality == 0);
2924 }
2925 else if (EClass._zone is Zone_DungeonDragon && EClass.rnd(5) != 0)
2926 {
2927 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);
2928 }
2929 else if (EClass._zone is Zone_DungeonMino && EClass.rnd(5) != 0)
2930 {
2931 spawnList = SpawnListChara.Get("dungeon_mino", (SourceChara.Row r) => r.race == "minotaur" && r.quality == 0);
2932 }
2933 else if (setting.hostility == SpawnHostility.Neutral || (setting.hostility != SpawnHostility.Enemy && Rand.Range(0f, 1f) < ChanceSpawnNeutral))
2934 {
2935 spawnList = SpawnList.Get(IsInstance ? "c_neutral_war" : "c_neutral");
2936 }
2937 else if (biome.spawn.chara.Count > 0)
2938 {
2939 string randomCharaId = biome.spawn.GetRandomCharaId();
2940 spawnList = ((!IsInstance) ? SpawnList.Get(randomCharaId) : SpawnList.Get("instance_" + randomCharaId, randomCharaId, new CharaFilter
2941 {
2942 ShouldPass = (SourceChara.Row s) => (!(s.hostility != "") || (!s.tag.Contains("cat") && !s.race_row.tag.Contains("cat"))) ? true : false
2943 }));
2944 }
2945 else
2946 {
2947 spawnList = SpawnList.Get(biome.name, "chara", new CharaFilter
2948 {
2949 ShouldPass = delegate(SourceChara.Row s)
2950 {
2951 if (s.hostility != "")
2952 {
2953 return false;
2954 }
2955 return s.biome == biome.name || s.biome.IsEmpty();
2956 }
2957 });
2958 }
2959 int num = ((setting.dangerLv == -1) ? DangerLv : setting.dangerLv);
2960 CardBlueprint cardBlueprint = new CardBlueprint
2961 {
2962 rarity = Rarity.Normal,
2963 idEle = setting.idEle
2964 };
2965 int num2 = ((setting.filterLv == -1) ? num : setting.filterLv);
2966 if (ScaleType == ZoneScaleType.Void)
2967 {
2968 num2 = ((num - 1) % 50 + 5) * 150 / 100;
2969 if (num2 >= 20 && EClass.rnd(100) < num2)
2970 {
2971 num2 = num;
2972 }
2973 }
2974 CardRow cardRow = (setting.id.IsEmpty() ? spawnList.Select(num2, setting.levelRange) : EClass.sources.cards.map[setting.id]);
2975 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)
2976 {
2977 cardRow = EClass.sources.cards.map["santa"];
2979 }
2980 long num3 = ((setting.fixedLv == -1) ? cardRow.LV : setting.fixedLv);
2981 bool flag = setting.fixedLv != -1 || DangerLvBoost > 0;
2982 num3 += setting.addLv;
2983 if (ScaleType == ZoneScaleType.Void)
2984 {
2985 num3 = (50L + (long)cardRow.LV) * Mathf.Max(1, (num - 1) / 50);
2986 flag = true;
2987 }
2988 num3 += DangerLvBoost;
2989 if (setting.rarity == Rarity.Random && cardRow.quality == 0)
2990 {
2991 if (EClass.rnd(EClass.pc.HasElement(1271) ? 80 : 100) == 0)
2992 {
2993 cardBlueprint.rarity = Rarity.Legendary;
2994 num3 = num3 * 125 / 100;
2995 }
2996 }
2997 else
2998 {
2999 cardBlueprint.rarity = setting.rarity;
3000 }
3001 if (setting.isBoss)
3002 {
3003 num3 = num3 * 150 / 100;
3004 }
3005 if (setting.isEvolved)
3006 {
3007 num3 = num3 * 2 + 20;
3008 }
3009 if (num3 != cardRow.LV)
3010 {
3011 cardBlueprint.lv = (int)Mathf.Min(num3, 100000000f);
3012 }
3013 CardBlueprint.Set(cardBlueprint);
3014 Chara chara = CharaGen.Create(cardRow.id, num2);
3015 if (!flag)
3016 {
3017 chara.isScaled = false;
3018 }
3019 AddCard(chara, pos);
3020 if (setting.forcedHostility.HasValue)
3021 {
3022 Hostility c_originalHostility = (chara.hostility = setting.forcedHostility.Value);
3023 chara.c_originalHostility = c_originalHostility;
3024 }
3025 else
3026 {
3027 switch (chara.id)
3028 {
3029 case "unicorn":
3030 if (EClass.pc.HasElement(1216) && EClass.pc.Evalue(418) < 1)
3031 {
3032 chara.SetHostility(Hostility.Enemy);
3033 }
3034 break;
3035 case "santa":
3036 case "silverwolf":
3037 case "twintail":
3038 case "test17":
3039 if (EClass.pc.HasElement(1270))
3040 {
3041 chara.SetHostility(Hostility.Friend);
3042 }
3043 else if (EClass.pc.HasElement(1271))
3044 {
3045 chara.SetHostility(Hostility.Enemy);
3046 }
3047 break;
3048 }
3049 }
3050 if (setting.isBoss)
3051 {
3052 chara.c_bossType = BossType.Boss;
3053 }
3054 if (setting.isEvolved)
3055 {
3056 chara.c_bossType = BossType.Evolved;
3057 }
3058 if (DangerLv >= 20 && !IsPCFaction && !IsTown && EClass.rnd(200) == 0)
3059 {
3061 }
3062 return chara;
3063 }
3064
3065 public bool HasField(int idEle)
3066 {
3067 return fieldElements.Has(idEle);
3068 }
3069
3070 public void SetFieldEffect(int idEle, int a)
3071 {
3072 fieldElements.SetBase(idEle, a);
3073 }
3074
3075 public void RefreshElectricity()
3076 {
3077 dirtyElectricity = false;
3078 bool flag = GetSoilCost() > MaxSoil;
3079 base.electricity = elements.Value(2201) * 10 + BaseElectricity;
3080 foreach (Thing thing in EClass._map.things)
3081 {
3082 if (thing.IsInstalled && thing.trait.Electricity != 0 && (thing.isOn || thing.trait.Electricity > 0))
3083 {
3084 base.electricity += thing.trait.Electricity;
3085 }
3086 }
3087 if (!flag)
3088 {
3089 EClass._map.bounds.ForeachCell(delegate(Cell c)
3090 {
3091 if (c.sourceObj.id == 118 && c.growth.IsMature)
3092 {
3093 base.electricity += 20;
3094 }
3095 });
3096 }
3097 foreach (Thing thing2 in EClass._map.things)
3098 {
3099 if (thing2.IsInstalled)
3100 {
3101 thing2.trait.TryToggle();
3102 }
3103 }
3104 }
3105
3106 public int GetElectricity(bool cost = false)
3107 {
3108 bool flag = GetSoilCost() > MaxSoil;
3109 int sum = 0;
3110 foreach (Thing thing in EClass._map.things)
3111 {
3112 if (!thing.IsInstalled || thing.trait.Electricity == 0)
3113 {
3114 continue;
3115 }
3116 if (cost)
3117 {
3118 if (thing.trait.Electricity < 0)
3119 {
3120 sum += -thing.trait.Electricity;
3121 }
3122 }
3123 else if (thing.trait.Electricity > 0)
3124 {
3125 sum += thing.trait.Electricity;
3126 }
3127 }
3128 if (!cost)
3129 {
3130 sum += elements.Value(2201) * 10 + BaseElectricity;
3131 if (!flag)
3132 {
3133 EClass._map.bounds.ForeachCell(delegate(Cell c)
3134 {
3135 if (c.sourceObj.id == 118 && c.growth.IsMature)
3136 {
3137 sum += 20;
3138 }
3139 });
3140 }
3141 }
3142 return sum;
3143 }
3144
3145 public void SetBGM(List<int> ids, bool refresh = true, float fadeDuration = 0f)
3146 {
3147 map._plDay.Clear();
3148 if (ids.Count > 0)
3149 {
3150 foreach (int id in ids)
3151 {
3152 if (id != -1)
3153 {
3154 map._plDay.Add(id);
3155 }
3156 }
3157 }
3158 UnityEngine.Object.DestroyImmediate(map.plDay);
3159 map.plDay = null;
3160 RefreshPlaylist();
3161 if (!refresh)
3162 {
3163 return;
3164 }
3165 if (fadeDuration > 0f)
3166 {
3167 EClass.Sound.StopBGM(fadeDuration, playLastBGM: false, delegate
3168 {
3170 {
3171 RefreshBGM();
3172 }
3173 });
3174 }
3175 else
3176 {
3177 EClass.Sound.StopBGM();
3178 RefreshBGM();
3179 }
3180 }
3181
3182 public void SetBGM(int id = -1, bool refresh = true, float fadeDuration = 0f)
3183 {
3184 SetBGM(new List<int> { id }, refresh, fadeDuration);
3185 }
3186
3187 public void RefreshPlaylist()
3188 {
3189 if (map.plDay == null)
3190 {
3191 map.plDay = CreatePlaylist(ref map._plDay, EClass.Sound.GetPlaylist(IDPlayList));
3192 }
3193 }
3194
3195 public void ResetPlaylist()
3196 {
3197 map._plDay.Clear();
3198 UnityEngine.Object.DestroyImmediate(map.plDay);
3199 map.plDay = null;
3200 RefreshPlaylist();
3201 }
3202
3203 public void RefreshBGM()
3204 {
3206 {
3207 return;
3208 }
3209 RefreshPlaylist();
3210 Playlist playlist = map.plDay;
3211 foreach (ZoneEvent item in events.list)
3212 {
3213 if (item.playlist != null)
3214 {
3215 playlist = item.playlist;
3216 }
3217 }
3218 if (IDPlaylistOverwrite != null)
3219 {
3220 playlist = EClass.Sound.GetPlaylist(IDPlaylistOverwrite);
3221 }
3223 {
3224 Room room = EClass.pc.pos.cell.room;
3225 if (room != null && room.lot != null && room.lot.idBGM != 0)
3226 {
3227 playlist = EClass.Sound.plLot;
3228 if (playlist.list[0].data?.id != room.lot.idBGM)
3229 {
3230 playlist.list[0].data = EClass.core.refs.dictBGM.TryGetValue(room.lot.idBGM);
3231 playlist.Reset();
3232 if (!LayerDrama.keepBGM)
3233 {
3234 EClass.Sound.StopBGM(1f);
3235 }
3236 }
3237 }
3238 }
3240 EClass.Sound.SwitchPlaylist(playlist, !LayerDrama.keepBGM);
3241 }
3242
3243 public Playlist CreatePlaylist(ref List<int> list, Playlist mold = null)
3244 {
3245 return ModUtil.CreatePlaylist(ref list, mold);
3246 }
3247
3248 public Chara FindChara(string id)
3249 {
3250 return map.charas.Find((Chara c) => c.id == id);
3251 }
3252
3253 public Chara FindChara(int uid)
3254 {
3255 return map.charas.Find((Chara c) => c.uid == uid);
3256 }
3257
3258 public int GetDeepestLv()
3259 {
3260 int max = base.lv;
3261 return GetDeepestLv(ref max);
3262 }
3263
3264 public int GetDeepestLv(ref int max)
3265 {
3266 if (Mathf.Abs(base.lv) > Mathf.Abs(max))
3267 {
3268 max = base.lv;
3269 }
3270 foreach (Spatial child in children)
3271 {
3272 (child as Zone).GetDeepestLv(ref max);
3273 }
3274 return max;
3275 }
3276
3277 public List<Element> ListLandFeats()
3278 {
3279 if (landFeats == null)
3280 {
3281 landFeats = new List<int>();
3283 string[] listBase = IDBaseLandFeat.Split(',');
3284 string[] array = listBase;
3285 foreach (string text in array)
3286 {
3287 if (!text.IsEmpty())
3288 {
3289 landFeats.Add(EClass.sources.elements.alias[text].id);
3290 }
3291 }
3292 if (listBase.Length == 1)
3293 {
3294 List<SourceElement.Row> list = EClass.sources.elements.rows.Where(delegate(SourceElement.Row e)
3295 {
3296 if (e.category != "landfeat" || e.chance == 0)
3297 {
3298 return false;
3299 }
3300 bool flag = true;
3301 string[] tag = e.tag;
3302 foreach (string text2 in tag)
3303 {
3304 if (text2.StartsWith("bf"))
3305 {
3306 flag = false;
3307 if (listBase[0] == text2)
3308 {
3309 flag = true;
3310 break;
3311 }
3312 }
3313 }
3314 return flag ? true : false;
3315 }).ToList();
3316 SourceElement.Row row = list.RandomItemWeighted((SourceElement.Row e) => e.chance);
3317 landFeats.Add(row.id);
3318 list.Remove(row);
3319 row = list.RandomItemWeighted((SourceElement.Row e) => e.chance);
3320 landFeats.Add(row.id);
3321 }
3322 Rand.SetSeed();
3323 }
3324 List<Element> list2 = new List<Element>();
3325 foreach (int landFeat in landFeats)
3326 {
3327 list2.Add(Element.Create(landFeat, 1));
3328 }
3329 return list2;
3330 }
3331
3332 public ZoneExportData Import(string path)
3333 {
3334 ZipFile zipFile = ZipFile.Read(path);
3335 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3336 zipFile.ExtractAll(pathTemp);
3337 zipFile.Dispose();
3338 return IO.LoadFile<ZoneExportData>(pathTemp + "export") ?? new ZoneExportData();
3339 }
3340
3341 public void Export(string path, PartialMap partial = null, bool usermap = false)
3342 {
3343 if (subset != null)
3344 {
3345 SE.Beep();
3346 return;
3347 }
3348 try
3349 {
3350 ZoneExportData zoneExportData = new ZoneExportData
3351 {
3352 name = name,
3353 usermap = usermap
3354 };
3356 if (!map.config.retainDecal)
3357 {
3358 map.ClearRainAndDecal();
3359 }
3360 map.Save(IO.TempPath + "/", zoneExportData, partial);
3361 map.ExportMetaData(IO.TempPath + "/", Path.GetFileNameWithoutExtension(path), partial);
3362 if (partial == null)
3363 {
3364 IO.CopyDir(base.pathSave + "Texture Replace", IO.TempPath + "/Texture Replace");
3365 }
3366 IO.SaveFile(IO.TempPath + "/export", zoneExportData, compress: true);
3367 using (ZipFile zipFile = new ZipFile())
3368 {
3369 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3370 zipFile.AddDirectory(IO.TempPath);
3371 zipFile.Save(path);
3372 zipFile.Dispose();
3373 }
3375 }
3376 catch (Exception ex)
3377 {
3378 EClass.ui.Say(ex.Message + ":" + path);
3379 }
3380 }
3381
3382 public void ExportDialog(string dir = null)
3383 {
3385 {
3386 string text = StandaloneFileBrowser.SaveFilePanel("Export Zone", dir ?? CorePath.ZoneSave, "new zone", "z");
3387 if (!string.IsNullOrEmpty(text))
3388 {
3389 Export(text);
3390 Msg.SayRaw("Exported Zone");
3391 }
3392 });
3393 }
3394
3395 public void ImportDialog(string dir = null)
3396 {
3398 {
3399 string[] array = StandaloneFileBrowser.OpenFilePanel("Import Zone", dir ?? CorePath.ZoneSave, "z", multiselect: false);
3400 if (array.Length != 0)
3401 {
3402 Zone_User zone_User = SpatialGen.Create("user", EClass.world.region, register: true) as Zone_User;
3403 zone_User.path = array[0];
3404 Thing thing = ThingGen.Create("teleporter");
3405 thing.c_uidZone = zone_User.uid;
3406 EClass._zone.AddCard(thing, EClass.pc.pos);
3407 }
3408 });
3409 }
3410
3411 public static bool IsImportValid(string path)
3412 {
3413 try
3414 {
3415 return Map.GetMetaData(path)?.IsValidVersion() ?? false;
3416 }
3417 catch (Exception ex)
3418 {
3419 EClass.ui.Say(ex.Message);
3420 return false;
3421 }
3422 }
3423
3424 public void Export()
3425 {
3427 string text = pathExport;
3428 IO.Copy(text, CorePath.ZoneSave + "Backup/");
3429 Export(text);
3430 Msg.Say("Exported Map:" + text);
3431 }
3432
3433 public void WriteNote(UINote n, Action<UINote> onWriteNote = null, IInspect.NoteMode mode = IInspect.NoteMode.Default, Recipe recipe = null)
3434 {
3435 }
3436
3437 public void OnInspect()
3438 {
3439 }
3440
3441 public int GetSortVal()
3442 {
3443 if (IsPCFaction)
3444 {
3445 return -10000000 + base.uid;
3446 }
3447 if (this is Zone_SubTown)
3448 {
3449 return -8000000 + base.uid;
3450 }
3451 if (this is Zone_Town)
3452 {
3453 return -9000000 + base.uid;
3454 }
3455 if (this is Zone_Civilized)
3456 {
3457 return -7000000 + base.uid;
3458 }
3459 if (this is Zone_RandomDungeon)
3460 {
3461 return 1000000 + base.uid;
3462 }
3463 return base.uid;
3464 }
3465
3466 public Chara AddRandomVisitor(bool guest = false)
3467 {
3468 Trait random = map.Installed.traits.GetTraitSet<TraitSpotExit>().GetRandom();
3469 if (random == null)
3470 {
3471 return null;
3472 }
3473 Point point = random.GetPoint();
3474 Chara chara = null;
3475 if (guest)
3476 {
3477 Zone z = EClass.world.FindZone("wilds");
3478 chara = EClass.game.cards.ListGlobalChara(z).RandomItem();
3479 if (chara != null)
3480 {
3481 AddCard(chara, point);
3482 Msg.Say("guestArrive", chara);
3483 chara.visitorState = VisitorState.Arrived;
3484 }
3485 }
3486 else
3487 {
3488 chara = CharaGen.CreateFromFilter("c_wilds");
3489 AddCard(chara, point);
3490 chara.goalListType = GoalListType.Enemy;
3491 }
3492 return chara;
3493 }
3494
3495 public void OnSimulateHour(VirtualDate date)
3496 {
3497 if (base.IsPlayerFaction)
3498 {
3499 branch.OnSimulateHour(date);
3500 }
3501 events.OnSimulateHour();
3502 if (date.IsRealTime)
3503 {
3504 foreach (Thing thing in EClass._map.things)
3505 {
3506 if (thing.IsInstalled)
3507 {
3508 thing.trait.TryToggle();
3509 }
3510 }
3512 }
3513 EClass._map.things.ForeachReverse(delegate(Thing t)
3514 {
3515 t.OnSimulateHour(date);
3516 });
3517 foreach (Thing sucker in Suckers)
3518 {
3519 sucker.Destroy();
3520 }
3521 Suckers.Clear();
3522 if (RespawnRate != 0f)
3523 {
3524 int num = 0;
3525 foreach (Chara chara in map.charas)
3526 {
3527 if (!chara.IsGlobal)
3528 {
3529 num++;
3530 }
3531 }
3532 if (num < MaxRespawn)
3533 {
3534 for (int i = 0; i < RespawnPerHour; i++)
3535 {
3536 SpawnMob();
3537 }
3538 }
3539 }
3540 if (!date.IsRealTime && EClass.rnd(24) == 0)
3541 {
3542 RainWater();
3543 }
3544 if (date.hour == 6)
3545 {
3546 GrowPlants(date);
3547 }
3548 }
3549
3550 public void OnSimulateDay(VirtualDate date)
3551 {
3552 if (base.IsPlayerFaction)
3553 {
3554 branch.OnSimulateDay(date);
3555 }
3556 }
3557
3558 public void OnSimulateMonth(VirtualDate date)
3559 {
3560 if (base.IsPlayerFaction)
3561 {
3562 branch.OnSimulateMonth(date);
3563 }
3564 if (date.IsRealTime)
3565 {
3567 }
3568 }
3569
3570 public void RainWater()
3571 {
3572 if (EClass._map.IsIndoor || !IsPCFaction)
3573 {
3574 return;
3575 }
3576 EClass._map.bounds.ForeachCell(delegate(Cell c)
3577 {
3578 if (c.IsFarmField && !c.HasRoof)
3579 {
3580 c.isWatered = true;
3581 }
3582 });
3583 }
3584
3585 public void GrowPlants(VirtualDate date)
3586 {
3587 bool num = (EClass.player.isAutoFarming = IsPCFaction && EClass.Branch.policies.IsActive(2707));
3588 int weedChance = 1;
3589 if (IsPCFaction && EClass.Branch.policies.IsActive(2703))
3590 {
3591 weedChance += (EClass.debug.enable ? 100000 : 20) + EClass.Branch.Evalue(2703) * 10;
3592 }
3593 if (date.sunMap == null)
3594 {
3595 date.BuildSunMap();
3596 }
3597 if (num)
3598 {
3599 HashSet<int> hashSet = new HashSet<int>();
3600 foreach (Thing thing in EClass._map.things)
3601 {
3602 if (!thing.IsInstalled || !(thing.trait is TraitSpotFarm traitSpotFarm))
3603 {
3604 continue;
3605 }
3606 foreach (Point item in traitSpotFarm.ListPoints(null, onlyPassable: false))
3607 {
3608 hashSet.Add(item.index);
3609 }
3610 }
3611 Perform(hashSet);
3612 EClass.player.isAutoFarming = false;
3613 Perform(hashSet);
3614 }
3615 else
3616 {
3617 Perform(null);
3618 }
3619 void Perform(HashSet<int> farmMap)
3620 {
3621 bool isWinter = date.IsWinter;
3622 EClass._map.bounds.ForeachCell(delegate(Cell c)
3623 {
3624 if (farmMap != null)
3625 {
3627 {
3628 if (!farmMap.Contains(c.index))
3629 {
3630 return;
3631 }
3632 }
3633 else if (farmMap.Contains(c.index))
3634 {
3635 return;
3636 }
3637 }
3638 if (c.decal != 0 && EClass.rnd(3) == 0)
3639 {
3640 c.decal = 0;
3641 }
3642 if (GrowPlant)
3643 {
3644 if (c.growth != null)
3645 {
3646 bool flag = false;
3647 if (!EClass.player.isAutoFarming && c.growth.HaltGrowth() && (c.IsFarmField || c.IsTopWater) && (!isWinter || !date.IsRealTime))
3648 {
3649 flag = true;
3650 }
3651 PlantData plantData = map.TryGetPlant(c);
3652 if (!flag && (plantData == null || plantData.fert >= 0))
3653 {
3654 c.TryGrow(date);
3655 }
3656 if (isWinter && plantData != null && c.growth != null && c.growth.NeedSunlight && plantData.fert >= 0 && (EClass.rnd(4) == 0 || c.growth.stage.idx == 0))
3657 {
3658 if (date.sunMap == null)
3659 {
3660 date.BuildSunMap();
3661 }
3662 if (!date.sunMap.Contains(c.index) && !c.growth.CanGrow(date))
3663 {
3664 c.growth.Perish();
3665 }
3666 }
3667 }
3668 else if (c.detail != null)
3669 {
3670 c.Things.ForeachReverse(delegate(Thing t)
3671 {
3672 if (t.IsInstalled && t.trait is TraitSeed && !t.isSale)
3673 {
3674 (t.trait as TraitSeed).TrySprout(force: false, sucker: false, date);
3675 }
3676 });
3677 }
3678 else if (EClass.rnd(20) == 0 && GrowWeed && c.CanGrowWeed && EClass.rnd(weedChance) == 0)
3679 {
3680 biome.Populate(c.GetPoint());
3681 if (c.growth != null)
3682 {
3683 c.growth.SetStage(0);
3684 }
3685 }
3686 }
3687 c.isWatered = false;
3688 });
3689 }
3690 }
3691
3692 public Zone GetZoneAt(int _x, int _y)
3693 {
3694 if (IsRegion)
3695 {
3696 foreach (Spatial child in children)
3697 {
3698 if (!(child is Zone_Field) && _x == child.x && _y == child.y)
3699 {
3700 return child as Zone;
3701 }
3702 }
3703 }
3704 foreach (Spatial child2 in children)
3705 {
3706 if (_x == child2.x && _y == child2.y)
3707 {
3708 return child2 as Zone;
3709 }
3710 }
3711 return null;
3712 }
3713
3714 public bool IsCrime(Chara c, Act act)
3715 {
3716 if (act.IsHostileAct && HasLaw && !IsPCFaction && c.IsPC)
3717 {
3718 return true;
3719 }
3720 return false;
3721 }
3722
3723 public void RefreshCriminal()
3724 {
3725 bool flag = EClass.player.IsCriminal && HasLaw && !AllowCriminal && !IsPCFaction;
3726 Hostility hostility = (flag ? Hostility.Neutral : Hostility.Friend);
3727 foreach (Chara chara in EClass._map.charas)
3728 {
3729 if (chara.trait is TraitGuard)
3730 {
3731 chara.hostility = hostility;
3732 if (!flag && chara.enemy != null && chara.enemy.IsPCParty)
3733 {
3734 chara.SetEnemy();
3735 }
3736 }
3737 }
3738 }
3739
3740 public void RefreshListCitizen()
3741 {
3742 if (base.lv != 0)
3743 {
3744 return;
3745 }
3746 dictCitizen.Clear();
3747 foreach (Chara item in map.charas.Concat(map.deadCharas))
3748 {
3749 if (item.trait.IsCitizen && !item.IsGlobal && !item.isSubsetCard)
3750 {
3751 dictCitizen[item.uid] = item.Name;
3752 }
3753 }
3754 }
3755
3756 public virtual void SetAlarm(bool enable)
3757 {
3758 base.isAlarmSet = enable;
3759 if (enable)
3760 {
3761 foreach (Chara chara in EClass._map.charas)
3762 {
3763 if (!chara.IsPCFactionOrMinion)
3764 {
3765 chara.SetHostility(Hostility.Enemy);
3766 }
3767 }
3768 Msg.Say("alarm");
3769 Msg.Say("alarm2");
3770 SE.Play("alarm");
3771 return;
3772 }
3773 foreach (Chara chara2 in EClass._map.charas)
3774 {
3775 if (!chara2.IsPCFactionOrMinion)
3776 {
3777 chara2.SetHostility(Hostility.Neutral);
3778 }
3779 }
3780 }
3781
3782 public void ModInfluence(int a)
3783 {
3784 base.influence += a;
3785 if (a > 0)
3786 {
3787 Msg.Say("gainInfluence", Name, a.ToString() ?? "");
3788 }
3789 Tutorial.Reserve("influence");
3790 }
3791
3792 public void ModDevelopment(int a)
3793 {
3794 base.development += a;
3795 if (a > 0)
3796 {
3797 Msg.Say("gainDevelopment", Name, a.ToString() ?? "");
3798 }
3799 }
3800
3801 public void UpdateQuests(bool force = false)
3802 {
3803 if (!IsPCFaction && (!(this is Zone_Town) || base.lv != 0))
3804 {
3805 return;
3806 }
3807 Debug.Log("Updating Quest:" + force);
3808 List<SourceQuest.Row> list = EClass.sources.quests.rows.Where((SourceQuest.Row a) => a.group == "random").ToList();
3809 int num = 0;
3810 foreach (Chara item in map.charas.Concat(map.deadCharas))
3811 {
3812 if (item.quest != null && !EClass.game.quests.list.Contains(item.quest))
3813 {
3814 if (item.quest.IsExpired || completedQuests.Contains(item.quest.uid) || force)
3815 {
3816 item.quest = null;
3817 }
3818 else
3819 {
3820 num++;
3821 }
3822 }
3823 }
3824 if (EClass._zone.dateQuest > EClass.world.date.GetRaw() && !force)
3825 {
3826 return;
3827 }
3828 EClass._zone.dateQuest = EClass.world.date.GetRaw() + 1440;
3829 int maxQuest = 3;
3830 Rand.UseSeed(base.uid + EClass.player.stats.days / 7 % 100, delegate
3831 {
3832 maxQuest = 4 + EClass.rnd(4);
3833 });
3834 completedQuests.Clear();
3835 List<Zone> list2 = Quest.ListDeliver();
3836 List<Tuple<string, int>> listTag = new List<Tuple<string, int>>();
3837 string[] array = EClass._zone.source.questTag;
3839 {
3840 array = new string[9] { "supply/8", "deliver/7", "food/8", "escort/4", "deliver/4", "monster/0", "war/0", "farm/0", "music/0" };
3841 }
3842 string[] array2 = array;
3843 for (int i = 0; i < array2.Length; i++)
3844 {
3845 string[] array3 = array2[i].Split('/');
3846 listTag.Add(new Tuple<string, int>(array3[0], array3[1].ToInt()));
3847 }
3848 for (int j = 0; j < map.charas.Count * 2; j++)
3849 {
3850 if (num > maxQuest)
3851 {
3852 break;
3853 }
3854 if (num > 15)
3855 {
3856 break;
3857 }
3858 Chara chara = map.charas.RandomItem();
3859 if (!chara.trait.CanGiveRandomQuest || chara.isSubsetCard || chara.homeZone != EClass._zone || chara.IsGuest() || chara.memberType == FactionMemberType.Livestock || (chara.quest != null && !force))
3860 {
3861 continue;
3862 }
3863 SourceQuest.Row row = list.RandomItemWeighted(delegate(SourceQuest.Row a)
3864 {
3865 int num2 = 1;
3866 foreach (Tuple<string, int> item2 in listTag)
3867 {
3868 if (a.tags.Contains(item2.Item1))
3869 {
3870 num2 = item2.Item2;
3871 break;
3872 }
3873 }
3874 if (!EClass._zone.IsPCFaction && a.tags.Contains("bulk"))
3875 {
3876 num2 = 0;
3877 }
3878 return a.chance * num2;
3879 });
3880 if ((!row.tags.Contains("needDestZone") || list2.Count >= 2) && (row.minFame <= 0 || row.minFame < EClass.player.fame || EClass.debug.enable))
3881 {
3882 Quest.Create(row.id, null, chara);
3883 num++;
3884 }
3885 }
3886 }
3887
3888 public List<Chara> ListMinions(Chara c)
3889 {
3890 List<Chara> list = new List<Chara>();
3891 foreach (Chara chara in EClass._map.charas)
3892 {
3893 if (chara.c_uidMaster == c.uid && chara.c_minionType == MinionType.Default)
3894 {
3895 list.Add(chara);
3896 }
3897 }
3898 return list;
3899 }
3900
3901 public int CountMinions(Chara c)
3902 {
3903 int num = 0;
3904 foreach (Chara chara in EClass._map.charas)
3905 {
3906 if (chara.c_uidMaster == c.uid && chara.c_minionType == MinionType.Default)
3907 {
3908 num++;
3909 }
3910 }
3911 return num;
3912 }
3913
3914 public int GetSoilCost()
3915 {
3916 int i = 0;
3917 EClass._map.bounds.ForeachCell(delegate(Cell c)
3918 {
3919 i += c.sourceObj.costSoil;
3920 });
3921 return i / 10;
3922 }
3923
3924 public void SpawnLostItems()
3925 {
3926 for (int i = 0; i < 2 + EClass.rnd(4); i++)
3927 {
3928 Point point = GetPos();
3929 if (point == null)
3930 {
3931 continue;
3932 }
3933 if (EClass.rnd(30) == 0)
3934 {
3935 Thing thing = ThingGen.Create("purse");
3936 thing.isLostProperty = true;
3937 thing.things.DestroyAll();
3938 int num2 = (thing.c_lockLv = EClass.rndHalf(Mathf.Min(base.development / 10 + 10, 50)));
3939 thing.Add("money", EClass.rndHalf(num2 * 60 + 1000));
3940 if (EClass.rnd(2) == 0)
3941 {
3942 thing.Add("plat", EClass.rnd(4));
3943 }
3944 else
3945 {
3946 thing.Add("medal", EClass.rnd(2));
3947 }
3948 EClass._zone.AddCard(thing, point);
3949 }
3950 else
3951 {
3953 }
3954 }
3955 static Point GetPos()
3956 {
3957 for (int j = 0; j < 10; j++)
3958 {
3959 Point randomPoint = EClass._zone.bounds.GetRandomPoint();
3960 if (!randomPoint.IsBlocked && !randomPoint.HasThing && !randomPoint.HasObj && !randomPoint.HasBlock)
3961 {
3962 return randomPoint;
3963 }
3964 }
3965 return null;
3966 }
3967 }
3968
3969 public void ApplyBackerPet(bool draw)
3970 {
3971 bool flag = this is Zone_Yowyn && base.lv == -1;
3972 IList<SourceBacker.Row> list = EClass.sources.backers.listPet.Copy();
3973 list.Shuffle();
3975 {
3976 list.ForeachReverse(delegate(SourceBacker.Row a)
3977 {
3978 if (EClass.player.doneBackers.Contains(a.id))
3979 {
3980 list.Remove(a);
3981 }
3982 });
3983 }
3984 foreach (Chara chara in EClass._map.charas)
3985 {
3986 if (chara.IsGlobal || chara.IsMinion)
3987 {
3988 continue;
3989 }
3990 if (chara.isBackerContent)
3991 {
3992 if (chara.sourceBacker.isStatic != 0)
3993 {
3994 continue;
3995 }
3996 if (chara.id != "follower")
3997 {
3998 chara.RemoveBacker();
3999 }
4000 }
4001 if ((flag && chara.race.id != "cat") || (!EClass.debug.enable && EClass.rnd((!flag) ? (draw ? 3 : 10) : (draw ? 1 : 2)) != 0))
4002 {
4003 continue;
4004 }
4005 foreach (SourceBacker.Row item in list)
4006 {
4007 if (item.chara == chara.id)
4008 {
4009 chara.ApplyBacker(item.id);
4010 list.Remove(item);
4011 break;
4012 }
4013 }
4014 }
4015 }
4016
4017 public FortuneRollData GetOrCreateFortuneRollData(bool refresh = true)
4018 {
4019 if (fortuneRoll == null)
4020 {
4021 fortuneRoll = new FortuneRollData();
4022 fortuneRoll.seed = EClass._zone.uid * 100 + EClass.game.seed;
4023 }
4024 if (refresh || fortuneRoll.count == 0)
4025 {
4026 fortuneRoll.Refresh();
4027 }
4028 return fortuneRoll;
4029 }
4030}
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:2326
bool IsDecayed
Definition: Card.cs:2341
virtual bool isThing
Definition: Card.cs:2133
virtual Chara Chara
Definition: Card.cs:2122
virtual void OnSimulateHour(VirtualDate date)
Definition: Card.cs:6993
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3905
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:6562
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3194
int c_lockLv
Definition: Card.cs:991
virtual void HealHP(int a, HealSource origin=HealSource.None)
Definition: Card.cs:4165
Card AddCard(Card c)
Definition: Card.cs:3243
bool isSale
Definition: Card.cs:869
int c_uidMaster
Definition: Card.cs:1489
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3257
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:2712
Point pos
Definition: Card.cs:60
void DecayNatural(int hour=1)
Definition: Card.cs:7002
int uid
Definition: Card.cs:125
Trait trait
Definition: Card.cs:54
Window.SaveData GetWindowSaveData()
Definition: Card.cs:2633
void RemoveBacker()
Definition: Card.cs:7453
int c_idBacker
Definition: Card.cs:1477
void PlayAnimeLoot()
Definition: Card.cs:6591
void Destroy()
Definition: Card.cs:5268
ThingContainer things
Definition: Card.cs:39
bool IsInstalled
Definition: Card.cs:2435
virtual bool isChara
Definition: Card.cs:2135
virtual Thing Thing
Definition: Card.cs:2110
int Evalue(int ele)
Definition: Card.cs:2688
bool isOn
Definition: Card.cs:545
bool TryStackTo(Thing to)
Definition: Card.cs:3555
Card Install()
Definition: Card.cs:3899
void ApplyBacker(int bid)
Definition: Card.cs:7417
void SetRandomDir()
Definition: Card.cs:6624
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:3234
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:6304
bool isBackerContent
Definition: Card.cs:952
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7240
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
new TraitChara trait
Definition: Chara.cs:509
Hostility OriginalHostility
Definition: Chara.cs:475
AIAct ai
Definition: Chara.cs:206
void ValidateWorks()
Definition: Chara.cs:9617
ConSuspend conSuspend
Definition: Chara.cs:104
bool CanRevive()
Definition: Chara.cs:5301
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9646
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:9811
AIAct SetAI(AIAct g)
Definition: Chara.cs:9266
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:9201
override int MaxHP
Definition: Chara.cs:726
Zone currentZone
Definition: Chara.cs:259
Goal GetGoalHobby()
Definition: Chara.cs:9214
SourceChara.Row source
Definition: Chara.cs:162
Stats mana
Definition: Chara.cs:1189
Stats stamina
Definition: Chara.cs:1181
void TryRestock(bool onCreate)
Definition: Chara.cs:4839
GlobalData global
Definition: Chara.cs:76
bool IsHomeMember()
Definition: Chara.cs:6823
Chara master
Definition: Chara.cs:88
void Revive(Point p=null, bool msg=false)
Definition: Chara.cs:5327
Zone homeZone
Definition: Chara.cs:271
bool IsGuest()
Definition: Chara.cs:6848
Thing MakeGene(DNA.Type? type=null)
Definition: Chara.cs:8498
override void SetDir(int d)
Definition: Chara.cs:3649
Religion faith
Definition: Chara.cs:443
Chara enemy
Definition: Chara.cs:86
CharaAbility ability
Definition: Chara.cs:428
bool IsInActiveZone
Definition: Chara.cs:861
Chara SetEnemy(Chara c=null)
Definition: Chara.cs:6527
FactionBranch homeBranch
Definition: Chara.cs:1089
void ChooseNewGoal()
Definition: Chara.cs:9137
Hostility hostility
Definition: Chara.cs:295
bool isDead
Definition: Chara.cs:393
void SetFaith(string id)
Definition: Chara.cs:1752
void Cure(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Definition: Chara.cs:9903
Chara SetHostility(Hostility h)
Definition: Chara.cs:1481
void MoveZone(string alias)
Definition: Chara.cs:3451
SourceRace.Row race
Definition: Chara.cs:468
void AddSpawn(string id)
Definition: CodexManager.cs:65
bool ignoreBackerDestoryFlag
Definition: CoreConfig.cs:568
void SetBGMInterval()
Definition: CoreConfig.cs:1020
bool test
Definition: CoreDebug.cs:185
bool enable
Definition: CoreDebug.cs:301
static string ZoneSave
Definition: CorePath.cs:192
BiomeProfile Water
Definition: CoreRef.cs:153
BiomeProfile Sand
Definition: CoreRef.cs:151
Crawler start
Definition: CoreRef.cs:215
Dictionary< int, BGMData > dictBGM
Definition: CoreRef.cs:386
Biomes biomes
Definition: CoreRef.cs:342
Crawlers crawlers
Definition: CoreRef.cs:344
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:1121
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
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:2260
List< Thing > things
Definition: Map.cs:49
PropsManager props
Definition: Map.cs:91
PlantData AddPlant(Point pos, Thing seed)
Definition: Map.cs:1997
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:2153
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:117
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 List< Point > ListPoints(Point center=null, bool onlyPassable=true)
Definition: Trait.cs:864
virtual void TryToggle()
Definition: Trait.cs:1321
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 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:2042
FactionBranch branch
Definition: Zone.cs:34
Card AddThing(string id, int x, int z)
Definition: Zone.cs:2076
void RefreshPlaylist()
Definition: Zone.cs:3187
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:3145
MapBounds bounds
Definition: Zone.cs:49
bool IsInstance
Definition: Zone.cs:493
void ClearZones(Zone current=null)
Definition: Zone.cs:2011
Chara SpawnMob(string id, Point pos=null)
Definition: Zone.cs:2885
void RemoveCard(Card t)
Definition: Zone.cs:2126
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:2086
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