2using System.Collections.Generic;
55 public Dictionary<int, string>
dictCitizen =
new Dictionary<int, string>();
86 public static List<Thing>
Suckers =
new List<Thing>();
98 base.uidBoss = value?.
uid ?? 0;
148 public virtual string IDPlayList => base.source.idPlaylist.IsEmpty((base.lv != 0) ?
"Underground" :
null);
152 public virtual string IDHat =>
null;
160 if (base.source.idFile.Length != 0)
162 return base.source.idFile[
fileVariation] + ((base.lv == 0) ?
"" : (
"_F" + base.lv));
168 public string pathTemp => GameIO.pathTemp + base.uid +
"/";
286 public virtual int MaxLv => 99999999;
288 public virtual int MinLv => -99999999;
320 public virtual int MaxSpawn => map.bounds.Width * map.bounds.Height / 175 + 2;
366 return base.source.tag.Contains(
"return");
378 return base.lv <
MaxLv;
398 public virtual bool UseFog => base.lv < 0;
410 return base.source.tag.Contains(
"light");
422 public virtual FlockController.SpawnType
FlockType => FlockController.SpawnType.Default;
432 return "conquered".lang();
536 if (destLv == base.lv)
558 zoneFullName = zoneFullName.Replace(
'/',
'@');
559 int num = zoneFullName.LastIndexOf(
'@');
561 if (num > 0 && num < zoneFullName.Length - 1)
563 text = zoneFullName[..num];
564 item = zoneFullName[(num + 1)..].ToInt();
568 text = zoneFullName.Replace(
"@",
"");
570 string text2 = text.Replace(
"Zone_",
"");
571 text =
"Zone_" + text2;
597 return base.source.id;
611 return " " +
"zoneLevelB".lang((_lv * -1).
ToString() ??
"");
613 return " " +
"zoneLevel".lang((_lv + 1).
ToString() ??
"");
647 EClass.game.config.reverseSnow =
false;
654 EClass.pc.global.transition.uidLastZone = 0;
662 EClass.game.activeZone =
this;
664 Debug.Log(
NameWithLevel +
"/" +
id +
"/" + base.uid +
"/" + base.isGenerated +
"/" +
IsLoaded +
"/" + File.Exists(base.pathSave +
"map"));
665 if (base.isGenerated && !
IsLoaded && !File.Exists(base.pathSave +
"map"))
667 Debug.Log(
"(Bug) File does not exist:" +
destryoed +
"/" + base.pathSave);
668 base.isGenerated =
false;
674 string lhs = CorePath.ZoneSave +
"_new.z";
675 bool flag3 = File.Exists(fullName) && !PathComparer.Default.Equals(lhs, fullName);
678 if (!flag3 && (base.source.tag.Contains(
"addMap") || flag4))
680 string[] array =
new string[4]
687 for (
int i = 0; i < array.Length; i++)
689 FileInfo fileInfo = PackageIterator.GetFiles(array[i]).LastOrDefault();
690 if (fileInfo !=
null)
692 fullName = fileInfo.FullName;
699 if (!base.isGenerated && (!flag4 || !flag3))
701 Debug.Log(
"generating random map");
724 Debug.Log(
"zone is already loaded");
738 Debug.Log(base.isGenerated +
"/" + flag5 +
"/" + flag2 +
"/" +
IDSubset);
739 if (!base.isGenerated || flag5 || flag2)
741 Debug.Log(
"importing map:" + fullName);
746 IO.DeleteDirectory(
pathTemp +
"Texture Replace");
751 zoneExportData =
Import(fullName);
752 base.isGenerated =
true;
758 zoneExportData.orgMap = IO.DeepCopy(
map);
762 zoneExportData.orgMap =
GameIO.LoadFile<
Map>(base.pathSave +
"map");
766 catch (Exception message)
770 base.isGenerated =
true;
779 Debug.Log(
"loading map: imported? " +
isImported +
" regenerate? " + flag5);
785 catch (Exception message2)
787 EClass.
ui.Say(
$"Can't load map '{base.uid}/{Name}'; File may be corrupted.\n" +
"Try replacing the following file if you have a backup:\n" + text +
"\nDefault file is at:\n" + fullName);
788 Debug.LogError(message2);
806 if (zoneExportData.
orgMap !=
null)
810 map.charas = orgMap.
charas;
820 map.
cells[num, num2].
isSeen = array2[num * EClass._map.Size + num2].GetBit(1);
826 Debug.Log(
"Importing New Chara:" +
item.id +
"/" +
item.Name +
"/" +
item.orgPos);
829 bool resetMedal =
GetInt(4) != 0;
834 foreach (Thing thing in orgMap.things)
836 if (t.id == thing.id && t.pos.Equals(thing.pos))
838 if (t.trait is TraitNewZone)
841 map.things.Insert(0, thing);
842 thing.stackOrder = 0;
846 t.ChangeMaterial(thing.material);
856 foreach (Thing thing2 in orgMap.things)
858 if (thing2.trait is TraitNewZone && t.pos.Equals(thing2.pos))
861 map.things.Add(thing2);
867 if (!resetMedal && (t.id ==
"medal" || t.id ==
"856"))
869 foreach (Thing thing3 in orgMap.things)
871 if (t.id == thing3.id && t.pos.Equals(thing3.pos))
901 thing4.isSubsetCard =
false;
921 if (isImported && IsTown)
923 RefreshListCitizen();
926 AddGlobalCharasOnActivate();
930 foreach (
Card item3
in map.
Cards.ToList())
940 idCurrentSubset = forceSubset ?? IDSubset;
941 if (idCurrentSubset !=
null)
949 if (MakeTownProperties)
960 thing7.isNPCProperty =
false;
964 if (instance !=
null)
969 if (isImported && !flag5 && !RevealRoom)
979 point2.cell.isSeen =
false;
988 PathManager.Instance._pathfinder.PunishChangeDirection =
false;
992 EClass._map.config.idSceneProfile =
"indoor_water";
995 if (flag && IsTown && base.lv == 0)
999 if (base.visitCount == 0)
1007 map.effectManager.GetOrCreate(cell.GetSharedPoint());
1012 cell._bridge = (cell._bridgeMat = 0);
1027 Map.isDirtySunMap =
true;
1039 card.CalculateFOV();
1043 chara.dirtySpeed =
true;
1048 if (
card.IsUnique && !
card.IsPCFaction && !
card.IsPCParty)
1058 int num3 =
card.GetInt(55);
1063 if (chara2.
uid == num3)
1067 chara.enemy = chara2;
1069 chara.calmCheckTurn = 20 +
EClass.
rnd(30);
1077 if (
card.c_uidMaster != 0 && chara.
master ==
null)
1090 else if (
card.IsInstalled &&
card.trait is
TraitDoor traitDoor &&
card.pos.HasChara && !traitDoor.IsOpen())
1092 traitDoor.ToggleDoor(sound:
false, refresh:
false);
1096 forceRegenerate =
false;
1108 OnVisitNewMapOrRegenerate();
1113 EClass.player.uidLastTown = 0;
1115 else if (IsTown && base.lv == 0)
1117 EClass.player.uidLastTown = base.uid;
1121 RefreshElectricity();
1153 List<Chara> list =
new List<Chara>();
1173 RefreshDeathSentense();
1181 isSimulating =
true;
1186 catch (Exception exception)
1188 Debug.LogException(exception);
1192 isSimulating =
false;
1202 if (HasField(10000))
1222 if (ShouldAutoRevive)
1242 Point point = GetSpawnPos(value);
1259 if (!(
id ==
"startVillage2"))
1265 SetBGM(121, refresh:
false);
1277 Msg.
Say(
"num_silvercat", num.ToString() ??
"");
1309 if (
Boss !=
null && IsNefia)
1315 int num = Mathf.Clamp(MinsSinceLastActive, 1, 10000);
1326 chara2.mana.value = 0;
1330 chara2.stamina.value = 0;
1335 chara2.resistCon =
null;
1339 Msg.ignoreAll =
true;
1341 chara2.
HealHP((
int)((
long)Mathf.Max(1, chara2.
MaxHP) * (
long)Mathf.Min(num, 20) / 20));
1342 chara2.
mana.
Mod(Mathf.Max(1, chara2.
mana.
max) * Mathf.Min(num, 20) / 20);
1344 Msg.ignoreAll =
false;
1348 Debug.Log(
"Last Active:" + base.lastActive);
1349 if (base.lastActive == 0 || IsRegion)
1353 if (pendingSimHours < 0)
1355 pendingSimHours = 0;
1357 int num2 = GetInt(3);
1363 int hourSinceLastActive = HourSinceLastActive;
1364 if (hourSinceLastActive <= 1 && pendingSimHours == 0)
1368 int num3 = hourSinceLastActive + pendingSimHours;
1369 int num4 = ((num2 > 0 && num3 > num2) ? (num3 - num2) : 0);
1371 int num5 = ((EClass.player.simulatingZone && num3 > maxSleepSimHours) ? maxSleepSimHours : num3);
1372 pendingSimHours = num3 - num5;
1373 Debug.Log(
$"{Name} Simulate/{num5}/{pendingSimHours}/skipped {num4}");
1378 int passed = num5 + num4;
1379 int num6 = passed / 24;
1384 if (!
item.IsPCParty)
1386 item.OnSleep(200, num6);
1387 if (
item.conSleep !=
null)
1389 item.conSleep.Kill();
1395 if (
item.things.Count > 20)
1402 VirtualDate.current = virtualDate;
1404 for (
int i = 0; i < num5; i++)
1410 catch (Exception exception)
1414 Debug.LogException(exception);
1422 VirtualDate.current =
null;
1428 foreach (
Chara item2
in list)
1436 if (item2.
id ==
"bee")
1440 if (num6 > 0 && item2.
IsGuest())
1451 item2.
SetAI(goalWork);
1454 (goalWork as
GoalWork).FindWork(item2);
1458 item2.
SetAI(goalWork);
1461 (goalWork as
GoalWork).FindWork(item2);
1471 List<Thing> list2 =
new List<Thing>();
1479 if (num8 >= list2.Count)
1483 for (
int num9 = num8; num9 < list2.Count; num9++)
1488 AddCard(chara, list2.RandomItem().
pos);
1490 chara.c_originalHostility = c_originalHostility;
1496 VirtualDate.current =
null;
1505 bool flag = zone ==
null || zone.lv > base.
lv;
1511 if (GetZoneAt(topZone.
x, topZone.
y) !=
null)
1523 enterState = RegionEnterState;
1529 float rate = zoneTransition?.
ratePos ?? (-1f);
1538 if (nearestPoint !=
null && nearestPoint.
IsValid)
1540 return nearestPoint;
1550 return new Point(zoneTransition.
x, zoneTransition.
z);
1558 if (traitTeleporter !=
null)
1562 if (traitTeleporter !=
null && !zoneTransition.
idTele.IsEmpty() && zoneTransition.
idTele == traitTeleporter.
id.IsEmpty(traitTeleporter.
GetParam(3)))
1576 if (randomThing2 !=
null)
1596 if (randomThing !=
null)
1624 flag = base.lv <= 0;
1650 return new Point(zoneTransition.
x, zoneTransition.
z);
1652 return GetRandomVisitPos(c);
1666 if (thing5.
trait is
TraitNewZone { zone: not null } traitNewZone && zone !=
null && traitNewZone.
zone.
uid == zone.uid)
1670 c.
SetDir(traitNewZone.owner.dir);
1672 return traitNewZone.GetExitPos();
1677 if (thing6.
trait is
TraitNewZone traitNewZone2 && ((flag && traitNewZone2.IsUpstairs) || (!flag && traitNewZone2.IsDownstairs)))
1681 c.
SetDir(traitNewZone2.owner.dir);
1683 return traitNewZone2.GetExitPos();
1686 return GetRandomVisitPos(c);
1694 point = map.
rooms.
listRoom.RandomItem().points.RandomItem();
1696 if (point ==
null &&
EClass.
rnd(4) != 0)
1713 Point spawnPosPC =
null;
1716 spawnPosPC = GetSpawnPos(
EClass.
pc);
1718 if (spawnPosPC ==
null)
1746 c.isRestrained =
false;
1750 Point pos = (c.IsPC ? spawnPosPC : (c.IsPCParty ? spawnPosPC.GetNearestPoint(allowBlock:
false, allowChara:
false, allowInstalled:
true, ignoreCenter:
true) : GetSpawnPos(c)));
1755 pos.
Set(spawnPosPC);
1760 if (!spawnPosPC.ForeachNearestPoint(delegate(
Point p)
1768 }, allowBlock:
false, EClass.pc.party.members.Count >= 12, allowInstalled:
true, ignoreCenter:
true, EClass._zone.IsRegion ? 2 : 6))
1770 pos.
Set(spawnPosPC);
1775 c.global.transition =
null;
1783 Point nearestPoint = spawnPosPC.
GetNearestPoint(allowBlock:
false, allowChara:
false, allowInstalled:
true, ignoreCenter:
true);
1785 item.pos.Set(nearestPoint);
1794 if (!IsUserZone && !IsPCFaction && map !=
null)
1796 List<Thing> list =
new List<Thing>();
1808 if (
item.IsContainer)
1826 Msg.
Say(
"pick_valuable");
1827 foreach (
Thing item2
in list)
1829 Msg.
Say(
"pick_valuable2", item2);
1836 base.isPeace =
false;
1838 OnBeforeDeactivate();
1850 EClass.game.activeZone =
null;
1854 base.isGenerated =
false;
1856 if (forceRegenerate)
1885 Debug.Log(
"Unloaded Map:" +
this);
1899 base.dateExpire = 0;
1904 thing.isNPCProperty =
false;
1910 for (
int i = 0; i < 7; i++)
1954 SetMainFaction(
null);
2002 Zone topZone = GetTopZone();
2009 if (!base.isRandomSite && !(
this is
Zone_Field) && (topZone ==
null || topZone ==
this || topZone.
FindDeepestZone() ==
this))
2021 if (zone !=
null && zone.
GetTopZone() ==
this)
2033 Debug.Log(
"Deleting Zone:" +
this);
2039 else if (map !=
null)
2041 Debug.Log(
"Saving Zone:" +
this);
2042 map.
Save(base.pathSave);
2043 if (!base.isMapSaved)
2045 base.isMapSaved =
true;
2046 IO.DeleteDirectory(base.pathSave +
"Texture Replace");
2047 IO.CopyDir(pathTemp +
"Texture Replace", base.pathSave +
"/Texture Replace");
2067 children.ForeachReverse(delegate(
Spatial z)
2075 if (parent !=
null && parent.IsRegion && instance ==
null)
2081 base.isGenerated =
false;
2090 base.isGenerated =
false;
2091 Zone topZone = GetTopZone();
2092 if (topZone !=
this)
2097 children.ForeachReverse(delegate(
Spatial c)
2117 if (parent ==
null || parent.IsRegion)
2121 return parent as
Zone;
2127 for (
int i = 0; i < 1000; i++)
2133 return AddCard(t, point);
2136 return AddCard(t, center);
2146 return AddChara(
id, p.
x, p.
z);
2156 return AddThing(
id, p.
x, p.
z);
2161 return AddCard(t, point.
x, point.
z);
2166 return AddCard(t, 0, 0);
2179 chara.currentZone =
this;
2189 ignoreSpawnAnime =
false;
2194 chara.hasSpawned =
true;
2208 t.Chara.currentZone =
null;
2220 public T GetRandomSpot<T>() where T :
Trait
2225 public bool TryAddThingInSpot<T>(
Thing t,
bool useContainer =
true) where T :
Trait
2228 if (randomThing ==
null)
2242 List<Thing> list =
new List<Thing>();
2245 foreach (
Card item2
in item.ListCards())
2249 list.Add(item2.
Thing);
2253 if (TryAddThingInSharedContainer(t, list, add:
true, msg:
false,
null, sharedOnly:
false))
2269 public List<Thing> TryListThingsInSpot<T>(Func<Thing, bool> func =
null) where T :
TraitSpot
2271 List<T> list =
new List<T>();
2272 List<Thing> list2 =
new List<Thing>();
2277 list.Add(thing.
trait as T);
2280 foreach (T
item in list)
2282 foreach (
Point item2
in item.ListPoints(
null, onlyPassable:
false))
2290 if (thing2.
things.Count == 0)
2292 if (IsValid(thing2))
2306 bool IsValid(
Thing t)
2308 if (func !=
null && !func(t))
2318 Thing thing = FindSharedContainer(t, containers, sharedOnly);
2343 if (containers ==
null)
2351 foreach (
Thing container
in containers)
2353 Thing thing = container;
2361 if (windowSaveData !=
null)
2381 foreach (
int cat
in windowSaveData.
cats)
2394 else if (windowSaveData.
flag.HasFlag(flag))
2399 priority = windowSaveData.
priority;
2433 if (num == 0 || !destroyIfFail)
2460 List<T> list =
new List<T>();
2465 list.Add(thing2.
trait as T);
2468 foreach (T
item in list)
2470 foreach (
Point item2
in item.ListPoints(
null, onlyPassable:
false))
2478 if (thing3.
things.Count == 0)
2480 if (IsValid(thing3, insideContainer:
false))
2495 bool IsValid(
Thing t,
bool insideContainer)
2507 string text = IdProfile;
2513 text = ((base.lv < 0) ?
"Underground" :
"Sky");
2515 else if (region !=
null)
2521 name =
Lang.
GetList(
"zone_" + text.Split(
'/')[1]).RandomItem();
2523 for (
int i = 0; i < 3; i++)
2525 for (
int j = 0; j < 3; j++)
2530 if (text ==
"Random/R_Shore")
2532 base.isBeach =
true;
2549 bp.genSetting.seed = base.Seed;
2559 base.isGenerated =
true;
2570 bool flag = IdBiome ==
"Sand" || IdBiome ==
"Water" || IsUnderwater;
2573 int num = 1 +
EClass.
rnd((IdBiome ==
"Water") ? 3 : 2);
2574 for (
int i = 0; i < num; i++)
2579 Thing t =
ThingGen.
Create(
"pearl_oyster",
new string[3] {
"wood_birch",
"poplar",
"coralwood" }.RandomItem(), ContentLv);
2584 for (
int j = 0; j < num; j++)
2595 if (!randomSurface3.
HasObj)
2603 for (
int l = 0; l < 30 +
EClass.
rnd(30); l++)
2626 foreach (
Point point
in r.points)
2630 map.
SetObj(point.
x, point.
z, num7);
2644 foreach (
Point point2
in r.points)
2656 foreach (
Point point3
in r.points)
2663 if (zone_Field !=
null)
2668 for (
int num5 = 0; num5 < num4; num5++)
2691 if (base.Tile.isRoad)
2693 for (
int num6 = 0; num6 <
EClass.
rnd(4); num6++)
2727 for (
int num = 0; num < 3 +
EClass.
rnd(4); num++)
2740 if (r.points.Count <= 4)
2745 List<Point> points = r.points;
2747 "altarPoint".lang(randomReligion.NameDomain.lang());
2752 for (
int i = 0; i < 2 +
EClass.
rnd(2); i++)
2763 if (
item.x % 3 == 0 &&
item.z % 2 == 0 &&
item != points[0] && !
item.Equals(points[0].Front) &&
item.Installed ==
null)
2765 thing = ThingGen.Create(
"pillar1");
2766 EClass._zone.AddCard(thing, item).Install();
2769 item.SetFloor(3, 6);
2777 if (MakeEnemiesNeutral)
2784 chara.hostility = hostility;
2788 if (PrespawnRate != 0f && !IsSkyLevel)
2790 for (
int i = 0; i < (int)((
float)MaxSpawn * PrespawnRate); i++)
2796 TryGenerateBigDaddy();
2797 TryGenerateEvolved();
2798 TryGenerateShrine();
2803 if (OreChance <= 0f)
2810 string text =
"ore";
2811 if (EClass.rnd(5) == 0)
2817 foreach (
Point point in r.points)
2819 if (point.sourceBlock.ContainsTag(
"ore"))
2821 map.SetObj(point.x, point.z, randomMaterial.id, num, 1, 0);
2836 for (
int i = 0; i < 2 +
EClass.
rnd(2); i++)
2853 List<string> list =
new List<string> {
"big_daddy",
"big_daddy2" };
2855 Spawn(list[0], spawnPos);
2858 Spawn(list[1], spawnPos.
GetNearestPoint(allowBlock:
false, allowChara:
false));
2860 Msg.
Say(
"sign_bigdaddy");
2862 void Spawn(
string id,
Point pos)
2864 int num = (int)((
long)DangerLv * 125L / 100);
2888 for (
int i = 0; i < 3; i++)
2896 if (randomSpace ==
null)
2928 chara.c_originalHostility = (
Hostility)0;
2945 for (
int i = 0; i < tries; i++)
2962 List<Point> list2 =
item.ListPoints(
null, onlyPassable:
true, allowChara:
false);
2963 if (list2.Count > 0)
2965 return list2.RandomItem();
2998 if (setting ==
null)
3004 pos = GetSpawnPos(setting.position, setting.tries);
3015 if (IsUnderwater &&
EClass.
rnd(15) != 0)
3020 if (setting.idSpawnList !=
null)
3030 spawnList =
SpawnListChara.
Get(
"dungeon_dragon", (
SourceChara.
Row r) => (r.race ==
"dragon" || r.race ==
"drake" || r.race ==
"wyvern" || r.race ==
"lizardman" || r.race ==
"dinosaur") && r.quality == 0);
3038 spawnList =
SpawnList.
Get(IsInstance ?
"c_neutral_war" :
"c_neutral");
3045 ShouldPass = (
SourceChara.Row s) => (!(s.hostility !=
"") || (!s.tag.Contains(
"cat") && !s.race_row.tag.Contains(
"cat"))) ? true :
false
3054 if (s.hostility !=
"")
3058 return s.biome == biome.name || s.biome.IsEmpty();
3062 int num = ((setting.dangerLv == -1) ? DangerLv : setting.dangerLv);
3066 idEle = setting.idEle
3068 int num2 = ((setting.filterLv == -1) ? num : setting.filterLv);
3071 num2 = ((num - 1) % 50 + 5) * 150 / 100;
3072 if (num2 >= 20 &&
EClass.
rnd(100) < num2)
3083 if (cardRow ==
null)
3085 Debug.LogError(
"SpawnMob: no spawn row list/" + spawnList?.
id +
"/biome/" + biome.name +
"/zone/" + Name);
3088 long num3 = ((setting.fixedLv == -1) ? cardRow.
LV : setting.fixedLv);
3089 bool flag = setting.fixedLv != -1 || setting.addLv > 0 || DangerLvBoost > 0;
3090 num3 += setting.addLv;
3093 num3 = (50L + (long)cardRow.
LV) * Mathf.Max(1, (num - 1) / 50);
3096 num3 += DangerLvBoost;
3097 if (flag && num3 <= Mathf.Max(50, cardRow.
LV))
3101 if (setting.rarity ==
Rarity.Random && cardRow.
quality == 0)
3105 cardBlueprint.rarity =
Rarity.Legendary;
3106 num3 = num3 * 125 / 100;
3111 cardBlueprint.rarity = setting.rarity;
3115 num3 = num3 * 150 / 100;
3117 if (setting.isEvolved)
3119 num3 = num3 * 2 + 20;
3121 if (num3 != cardRow.
LV)
3123 cardBlueprint.lv = (int)Mathf.Min(num3, 100000000f);
3129 chara.isScaled =
false;
3131 AddCard(chara, pos);
3132 if (setting.forcedHostility.HasValue)
3134 Hostility c_originalHostility = (chara.hostility = setting.forcedHostility.Value);
3135 chara.c_originalHostility = c_originalHostility;
3166 if (setting.isEvolved)
3168 chara.c_bossType =
BossType.Evolved;
3170 if (DangerLv >= 20 && !IsPCFaction && !IsTown &&
EClass.
rnd(200) == 0)
3179 return fieldElements.
Has(idEle);
3184 fieldElements.
SetBase(idEle, a, duration);
3189 fieldElements.
Remove(idEle);
3194 dirtyElectricity =
false;
3195 bool flag = GetSoilCost() > MaxSoil;
3196 base.electricity = elements.
Value(2201) * 10 + BaseElectricity;
3210 base.electricity += 20;
3225 bool flag = GetSoilCost() > MaxSoil;
3247 sum += elements.
Value(2201) * 10 + BaseElectricity;
3262 public void SetBGM(List<int> ids,
bool refresh =
true,
float fadeDuration = 0f)
3267 foreach (
int id in ids)
3275 UnityEngine.Object.DestroyImmediate(map.
plDay);
3282 if (fadeDuration > 0f)
3284 EClass.
Sound.StopBGM(fadeDuration, playLastBGM:
false, delegate
3299 public void SetBGM(
int id = -1,
bool refresh =
true,
float fadeDuration = 0f)
3301 SetBGM(
new List<int> {
id }, refresh, fadeDuration);
3306 if (map.
plDay ==
null)
3308 map.plDay = CreatePlaylist(ref map.
_plDay,
EClass.
Sound.GetPlaylist(IDPlayList));
3316 UnityEngine.Object.DestroyImmediate(map.
plDay);
3328 Playlist playlist = map.
plDay;
3331 if (
item.playlist !=
null)
3333 playlist =
item.playlist;
3336 if (IDPlaylistOverwrite !=
null)
3338 playlist =
EClass.
Sound.GetPlaylist(IDPlaylistOverwrite);
3343 if (room !=
null && room.
lot !=
null && room.
lot.
idBGM != 0)
3346 if (playlist.list[0].data?.id != room.
lot.
idBGM)
3363 return ModUtil.CreatePlaylist(ref list, mold);
3384 return GetDeepestLv(ref max);
3389 if (Mathf.Abs(base.lv) > Mathf.Abs(max))
3393 foreach (
Spatial child
in children)
3395 (child as
Zone).GetDeepestLv(ref max);
3402 if (base.source.costSkyTravel > 0)
3404 return base.source.costSkyTravel;
3408 return Mathf.Clamp(10 +
EClass.
curve(DangerLv, 50, 10), 1, 200);
3415 if (landFeats ==
null)
3417 landFeats =
new List<int>();
3419 string[] listBase = IDBaseLandFeat.Split(
',');
3420 string[] array = listBase;
3421 foreach (
string text
in array)
3423 if (!text.IsEmpty())
3428 if (listBase.Length == 1)
3432 if (e.category !=
"landfeat" || e.chance == 0)
3437 string[] tag = e.tag;
3438 foreach (
string text2 in tag)
3440 if (text2.StartsWith(
"bf"))
3443 if (listBase[0] == text2)
3450 return flag ? true :
false;
3453 landFeats.Add(row.
id);
3456 landFeats.Add(row.
id);
3460 List<Element> list2 =
new List<Element>();
3461 foreach (
int landFeat
in landFeats)
3470 ZipFile zipFile = ZipFile.Read(path);
3471 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3472 zipFile.ExtractAll(pathTemp);
3491 IO.CreateTempDirectory();
3496 map.
Save(IO.TempPath +
"/", zoneExportData, partial);
3497 map.
ExportMetaData(IO.TempPath +
"/", Path.GetFileNameWithoutExtension(path), partial);
3498 if (partial ==
null)
3500 IO.CopyDir(base.pathSave +
"Texture Replace", IO.TempPath +
"/Texture Replace");
3502 IO.SaveFile(IO.TempPath +
"/export", zoneExportData, compress:
true);
3503 using (ZipFile zipFile =
new ZipFile())
3505 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3506 zipFile.AddDirectory(IO.TempPath);
3510 IO.DeleteTempDirectory();
3512 catch (Exception ex)
3514 EClass.
ui.Say(ex.Message +
":" + path);
3523 if (!
string.IsNullOrEmpty(text))
3536 if (array.Length != 0)
3538 Zone_User zone_User = SpatialGen.Create(
"user", EClass.world.region, register: true) as Zone_User;
3539 zone_User.path = array[0];
3540 Thing thing = ThingGen.Create(
"teleporter");
3541 thing.c_uidZone = zone_User.uid;
3542 EClass._zone.AddCard(thing, EClass.pc.pos);
3553 catch (Exception ex)
3563 string text = pathExport;
3566 Msg.
Say(
"Exported Map:" + text);
3581 return -10000000 + base.uid;
3585 return -8000000 + base.uid;
3589 return -9000000 + base.uid;
3593 return -7000000 + base.uid;
3597 return 1000000 + base.uid;
3617 AddCard(chara, point);
3618 Msg.
Say(
"guestArrive", chara);
3625 AddCard(chara, point);
3633 if (base.IsPlayerFaction)
3653 foreach (
Thing sucker
in Suckers)
3658 if (RespawnRate != 0f)
3668 if (num < MaxRespawn)
3670 for (
int num2 = 0; num2 < RespawnPerHour; num2++)
3676 if (!date.IsRealTime &&
EClass.
rnd(24) == 0)
3688 if (base.IsPlayerFaction)
3696 if (base.IsPlayerFaction)
3735 HashSet<int> hashSet =
new HashSet<int>();
3742 foreach (
Point item in traitSpotFarm.ListPoints(
null, onlyPassable:
false))
3744 hashSet.Add(
item.index);
3748 EClass.player.isAutoFarming =
false;
3755 void Perform(HashSet<int> farmMap)
3760 if (farmMap !=
null)
3764 if (!farmMap.Contains(c.index))
3769 else if (farmMap.Contains(c.
index))
3783 if (!EClass.player.isAutoFarming && c.growth.HaltGrowth() && (c.IsFarmField || c.IsTopWater) && (!isWinter || !date.IsRealTime))
3788 if (!flag && (plantData ==
null || plantData.fert >= 0))
3794 if (date.sunMap == null)
3804 else if (c.detail !=
null)
3806 c.Things.ForeachReverse(delegate(Thing t)
3808 if (t.IsInstalled && t.trait is TraitSeed && !t.isSale)
3810 (t.trait as TraitSeed).TrySprout(force: false, sucker: false, date);
3814 else if (
EClass.
rnd(20) == 0 && GrowWeed && c.CanGrowWeed &&
EClass.
rnd(weedChance) == 0)
3817 if (c.growth !=
null)
3819 c.growth.SetStage(0);
3823 c.isWatered =
false;
3832 foreach (
Spatial child
in children)
3834 if (!(child is
Zone_Field) && _x == child.
x && _y == child.
y)
3836 return child as
Zone;
3840 foreach (
Spatial child2
in children)
3842 if (_x == child2.
x && _y == child2.
y)
3844 return child2 as
Zone;
3861 bool flag = EClass.player.IsCriminal && HasLaw && !AllowCriminal && !IsPCFaction;
3867 chara.hostility = hostility;
3882 dictCitizen.Clear();
3885 if (
item.trait.IsCitizen && !
item.IsGlobal && !
item.isSubsetCard)
3894 base.isAlarmSet = enable;
3920 base.influence += a;
3923 Msg.
Say(
"gainInfluence", Name, a.ToString() ??
"");
3930 base.development += a;
3933 Msg.
Say(
"gainDevelopment", Name, a.ToString() ??
"");
3939 if (!IsPCFaction && (!(
this is
Zone_Town) || base.lv != 0))
3943 Debug.Log(
"Updating Quest:" + force);
3950 if (
item.quest.IsExpired || completedQuests.Contains(
item.quest.uid) || force)
3968 maxQuest = 4 + EClass.rnd(4);
3970 completedQuests.Clear();
3972 List<Tuple<string, int>> listTag =
new List<Tuple<string, int>>();
3976 array =
new string[9] {
"supply/8",
"deliver/7",
"food/8",
"escort/4",
"deliver/4",
"monster/0",
"war/0",
"farm/0",
"music/0" };
3978 string[] array2 = array;
3979 for (
int num2 = 0; num2 < array2.Length; num2++)
3981 string[] array3 = array2[num2].Split(
'/');
3982 listTag.Add(
new Tuple<string, int>(array3[0], array3[1].ToInt()));
3984 for (
int num3 = 0; num3 < map.charas.Count * 2; num3++)
4002 foreach (Tuple<string, int> item2
in listTag)
4004 if (a.tags.Contains(item2.Item1))
4014 return a.chance * num4;
4026 List<Chara> list =
new List<Chara>();
4062 for (
int i = 0; i < 2 +
EClass.
rnd(4); i++)
4064 Point point = GetPos();
4072 thing.isLostProperty =
true;
4074 int num = (thing.c_lockLv =
EClass.
rndHalf(Mathf.Min(base.development / 10 + 10, 50)));
4091 static Point GetPos()
4093 for (
int j = 0; j < 10; j++)
4107 bool flag =
this is
Zone_Yowyn && base.lv == -1;
4114 if (EClass.player.doneBackers.Contains(a.id))
4132 if (chara.
id !=
"follower")
4143 if (
item.chara == chara.
id)
4155 if (fortuneRoll ==
null)
4160 if (refresh || fortuneRoll.
count == 0)
virtual void OnSimulatePosition()
void SimulateZone(int days)
void Add(Act a, string s="")
virtual bool IsHostileAct
BaseArea.AccessType accessType
void WaitForEndOfFrame(Action action)
List< SpawnListChara > chara
string GetRandomCharaId()
void Populate(Point point, bool interior=false, float mtpDensity=1f)
static void Set(CardBlueprint _bp=null)
GlobalCharaList globalCharas
List< Chara > ListGlobalChara(Zone z)
override void OnLeaveScreen()
virtual void OnSimulateHour(VirtualDate date)
void SetPlaceState(PlaceState newState, bool byPlayer=false)
SourceBacker.Row sourceBacker
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Thing AddThing(string id, int lv=-1)
void AddEditorTag(EditorTag tag)
void DecayNatural(int hour=1)
virtual void HealHP(long a, HealSource origin=HealSource.None)
Window.SaveData GetWindowSaveData()
bool HasEditorTag(EditorTag tag)
bool TryStackTo(Thing to)
void ApplyBacker(int bid)
Thing Add(string id, int num=1, int lv=1)
SourceCategory.Row category
bool HasElement(int ele, bool includeNagative=false)
void Say(string lang, string ref1=null, string ref2=null)
static Chara CreateFromFilter(string id, int lv=-1, int levelRange=-1)
static Chara Create(string id, int lv=-1)
BaseCondition GetCondition(string idCon)
Hostility OriginalHostility
Condition AddCondition(string id, int p=100, bool force=false)
bool HasCondition(string alias)
override bool IsPCFaction
void TryRestock(bool onCreate)
void Revive(Point p=null, bool msg=false)
Thing MakeGene(DNA.Type? type=null)
override void SetDir(int d)
Chara SetEnemy(Chara c=null)
void Cure(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Chara SetHostility(Hostility h)
void MoveZone(string alias)
bool ignoreBackerDestoryFlag
Dictionary< int, BGMData > dictBGM
static Crawler Create(string id)
bool CrawlUntil(Map map, Func< Point > onStart, int tries, Func< Result, bool > canComplete, Action onFail=null)
int GetElapsedHour(int rawDate)
int GetRaw(int offsetHours=0)
int GetElapsedMins(int rawDate)
int GetRemainingHours(int rawDeadLine)
static int curve(long _a, int start, int step, int rate=75)
static SourceManager sources
static float rndf(float a)
static FactionBranch Branch
static int rndHalf(int a)
static SoundManager Sound
static GameSetting setting
static Effect Get(Effect original)
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Element SetBase(string alias, int v, int potential=0)
static Element Create(int id, int v=0)
void Initialize(EloMap _elomap)
void SetZone(int gx, int gy, Zone z, bool updateMesh=false)
TileInfo GetTileInfo(int gx, int gy)
void OnSimulateMonth(VirtualDate date)
void OnSimulateDay(VirtualDate date)
void OnSimulateHour(VirtualDate date)
string Log(string idLang, string ref1=null, string ref2=null, string ref3=null, string ref4=null)
ElementContainerZone elements
List< GodStatueData > godStatues
ReligionManager religions
ZoneTransition transition
void SetStage(int idx, bool renewHarvest=false)
virtual bool NeedSunlight
bool CanGrow(VirtualDate date)
void RefreshDevelopment()
static Guild GetCurrentGuild()
static string[] GetList(string id)
static SourceMaterial.Row GetRandomMaterial(int lv, string group=null, bool tryLevelMatTier=false)
Point GetLeftPos(float rate=-1f)
void ForeachCell(Action< Cell > action)
Point GetBottomPos(float rate=-1f)
Point GetRandomSurface(int x, int z, int radius, bool walkable=true, bool allowWater=false)
Point GetTopPos(float rate=-1f)
Point GetRandomSpace(int width, int height, int tries=100)
Point GetRightPos(float rate=-1f)
static MapSubset Load(string id)
new void ForeachCell(Action< Cell > action)
PlantData TryGetPlant(Point p)
void ExportMetaData(string _path, string id, PartialMap partial=null)
Chara FindChara(string id)
IEnumerable< Card > Cards
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
void Save(string path, ZoneExportData export=null, PartialMap partial=null)
void AddCardOnActivate(Card c)
void OnCardRemovedFromZone(Card t)
byte[] TryLoadFile(string path, string s, int size)
Dictionary< int, int > backerObjs
void SetFloor(int x, int z, int idMat=0, int idFloor=0)
PlantData AddPlant(Point pos, Thing seed)
void OnImport(ZoneExportData data)
List< Chara > serializedCharas
static MapMetaData GetMetaData(string pathZip)
void OnCardAddedToZone(Card t, int x, int z)
void Load(string path, bool import=false, PartialMap partial=null)
void RevealAll(bool reveal=true)
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
static string SayRaw(string text)
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Cell GetCenterCell(int radius=1)
void OccyupyPOI(Point p, int radius=0)
static PathManager Instance
bool IsPathClear(Point origin, Point dest, IPathfindWalker walker, int radius)
List< Chara > listCarryoverMap
HashSet< int > doneBackers
void SetObj(int id=0, int value=1, int dir=0)
override string ToString()
Point Set(int _x, int _z)
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
bool Equals(int _x, int _z)
Point GetRandomPointInRadius(int minRadius, int maxRadius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=2000)
Point Clamp(bool useBounds=false)
Thing FindThing(Func< Thing, bool > func)
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
bool IsActive(int id, int days=-1)
static List< Zone > ListDeliver()
static Quest Create(string _id, string _idPerson=null, Chara c=null, bool assignQuest=true)
static int Range(int min, int max)
static void InitBytes(int a)
static void UseSeed(int seed, Action action)
static void SetSeed(int a=-1)
Dictionary< string, Religion > dictAll
Religion GetRandomReligion(bool onlyJoinable=true, bool includeMinor=false)
static string[] OpenFilePanel(string title, string directory, string extension, bool multiselect)
static string SaveFilePanel(string title, string directory, string defaultName, string extension)
static SceneProfile Load(string id)
void RemoveActorEx(Card c)
Dictionary< string, CardRow > map
SourceZoneAffix zoneAffixes
static Spatial Create(string id, Spatial parent, bool register, int x=-99999, int y=-99999, int icon=0)
void SetInt(int id, int value=0)
virtual int DangerLvBoost
int GetInt(int id, int? defaultInt=null)
static SpawnList Get(string id, Func< SourceChara.Row, bool > func)
static SpawnList Get(string id, string parent=null, CardFilter filter=null)
static SpawnSetting Default
static SpawnSetting Fish()
static SpawnSetting HomeGuest(int lv)
static SpawnSetting Evolved(int fixedLv=-1)
void ApplyLocalReplace(string path)
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
void DestroyAll(Func< Thing, bool > funcExclude=null)
Thing CanStack(Thing target, int destInvX=-1, int destInvY=-1)
static Thing CreateFromCategory(string idCat, int lv=-1)
static Thing Create(string id, int idMat=-1, int lv=-1)
override string GetName(NameStyle style, int _num=-1)
virtual bool CanGiveRandomQuest
virtual bool CanAutoRevive
TraitSet GetTraitSet(Type t)
virtual bool IsFor(Zone z)
static bool CanTagSale(Card t, bool insideContainer=false)
static Thing MakeSeed(string idSource)
static void LevelSeed(Thing t, SourceObj.Row obj, int num)
Point GetRandomPoint(Func< Point, bool > func=null, Chara accessChara=null)
virtual ShopType ShopType
string GetParam(int i, string def=null)
virtual List< Point > ListPoints(Point center=null, bool onlyPassable=true, bool allowChara=true)
static void Reserve(string idStep, Action onBeforePlay=null)
FilterResult IsFilterPass(string text)
void GenerateMap(Zone zone)
EloMap.TileInfo[,] surrounding
List< ZonePreEnterEvent > listPreEnter
virtual void OnGenerateMap()
virtual bool ShowEnemyOnMinimap
static ZoneProfile Load(string id)
virtual string GetNewZoneID(int level)
void OnChildNumChange(Card c)
virtual bool CanDigUnderground
virtual int BaseElectricity
virtual string IDPlayList
Dictionary< int, string > dictCitizen
override string ToString()
List< Chara > ListMinions(Chara c)
void RefreshElectricity()
ZoneExportData Import(string path)
virtual string IDBaseLandFeat
static string string int zoneLv ParseZoneFullName(string zoneFullName)
virtual string GetDungenID()
virtual bool BlockBorderExit
void RefreshDeathSentense()
static string forceSubset
virtual float PrespawnRate
FortuneRollData GetOrCreateFortuneRollData(bool refresh=true)
virtual bool RegenerateOnEnter
virtual void OnAfterSimulate()
void OnSimulateDay(VirtualDate date)
Playlist CreatePlaylist(ref List< int > list, Playlist mold=null)
static bool IsImportValid(string path)
virtual string IDGenerator
int CountMinions(Chara c)
virtual bool MakeTownProperties
Thing TryGetThingFromSharedContainer(Func< Thing, bool > func)
void WriteNote(UINote n, Action< UINote > onWriteNote=null, IInspect.NoteMode mode=IInspect.NoteMode.Default, Recipe recipe=null)
virtual void OnRegenerate()
virtual bool CountDeepestLevel
virtual ZoneScaleType ScaleType
virtual bool SetAlarmOnBreakLaw
virtual string pathExport
virtual void OnBeforeDeactivate()
virtual ZoneTransition.EnterState RegionEnterState
virtual bool ShouldAutoRevive
HashSet< int > completedQuests
virtual bool DisableRooms
Chara TryGenerateEvolved(bool force=false, Point p=null)
void ImportDialog(string dir=null)
void ClaimZone(bool debug=false, Point pos=null)
Chara AddChara(string id, int x, int z)
Card AddThing(string id, int x, int z)
ElementContainerField fieldElements
virtual bool ShouldScaleImportedChara(Chara c)
ElementContainerZone elements
virtual bool IsReturnLocation
Chara AddRandomVisitor(bool guest=false)
void ExportDialog(string dir=null)
virtual void OnBeforeSimulate()
int GetElectricity(bool cost=false)
virtual FlockController.SpawnType FlockType
Chara SpawnMob(Point pos=null, SpawnSetting setting=null)
virtual bool CanUnlockExit
int GetDeepestLv(ref int max)
virtual int RespawnPerHour
virtual float RespawnRate
Chara FindDeadChara(string id)
void ApplyBackerPet(bool draw)
bool CanEnterBuildModeAnywhere
Card AddCardSplinkle(Card t, Point center, int radius=4)
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
override string NameSuffix
virtual string TextWidgetDate
void AddGlobalCharasOnActivate()
void OnSimulateMonth(VirtualDate date)
Thing FindSharedContainer(Thing t, List< Thing > containers=null, bool sharedOnly=true)
virtual float ChanceSpawnNeutral
virtual string IDSceneTemplate
virtual int SightRadiusBonus
virtual bool CanBeDeliverDestination
void ClearZones(Zone current=null)
bool TryAddThingInSharedContainer(Thing t, List< Thing > containers=null, bool add=true, bool msg=false, Chara chara=null, bool sharedOnly=true)
virtual void OnDeactivate()
virtual ActionMode DefaultActionMode
virtual void OnActivate()
Card AddCard(Card t, int x, int z)
void OnSimulateHour(VirtualDate date)
override void _OnBeforeSave()
override void OnAfterCreate()
static List< Thing > Suckers
Card AddThing(string id, Point p)
Zone FindOrCreateLevel(int destLv, string subId="")
virtual string IDAmbience
Chara SpawnMob(string id, Point pos=null)
virtual string IDPlaylistOverwrite
Point GetSpawnPos(SpawnPosition type, int tries=100)
bool TryAddThing(Thing target, Point p, bool destroyIfFail=false)
void GrowPlants(VirtualDate date)
Chara FindChara(string id)
void SetBGM(int id=-1, bool refresh=true, float fadeDuration=0f)
virtual bool ShouldMakeExit
virtual bool AllowCriminal
virtual bool AlwaysLowblock
virtual bool AllowNewZone
virtual bool RestrictBuild
virtual void OnGenerateRooms(BaseMapGen gen)
Point GetRandomVisitPos(Chara c)
virtual void OnGenerateMap()
static string string zoneId
List< Element > ListLandFeats()
static bool forceRegenerate
virtual bool MakeEnemiesNeutral
virtual bool IsUnderwater
virtual void OnCreateBP()
void Export(string path, PartialMap partial=null, bool usermap=false)
virtual bool ShouldRegenerate
void RemoveFieldEffect(int idEle)
virtual float BigDaddyChance
void TryGenerateBigDaddy()
virtual float EvolvedChance
static bool ignoreSpawnAnime
virtual void SetAlarm(bool enable)
virtual void OnAdvanceHour()
FortuneRollData fortuneRoll
void ModDevelopment(int a)
virtual bool WillAutoSave
virtual bool IsExplorable
void UpdateQuests(bool force=false)
virtual bool KeepAllyDistance
virtual bool HiddenInRegionMap
bool IsCrime(Chara c, Act act)
void RefreshListCitizen()
Zone GetZoneAt(int _x, int _y)
Card AddCard(Card t, Point point)
string TextLevel(int _lv)
void SetFieldEffect(int idEle, int a, int duration=0)
Chara AddChara(string id, Point p)
virtual ZoneFeatureType FeatureType
virtual float ShrineChance
Point GetSpawnPos(Chara c, ZoneTransition.EnterState destState=ZoneTransition.EnterState.Auto)
virtual void OnVisitNewMapOrRegenerate()
bool IsBelow(int _major, int _minor, int _batch)