Elin Decompiled Documentation EA 23.332 Nightly Patch 1
Loading...
Searching...
No Matches
Zone.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using Dungen;
6using Ionic.Zip;
7using Newtonsoft.Json;
8using SFB;
9using UnityEngine;
10
12{
13 public class PortalReturnData
14 {
15 [JsonProperty]
16 public int uidZone;
17
18 [JsonProperty]
19 public int x;
20
21 [JsonProperty]
22 public int z;
23 }
24
25 public static bool forceRegenerate;
26
27 public static string forceSubset;
28
29 public static CardRow sourceHat;
30
31 public static int okaerinko = 0;
32
33 [JsonProperty]
35
36 [JsonProperty]
37 public HashSet<int> completedQuests = new HashSet<int>();
38
39 [JsonProperty]
41
42 [JsonProperty]
44
45 [JsonProperty]
47
48 [JsonProperty]
50
51 [JsonProperty]
52 public Dictionary<int, string> dictCitizen = new Dictionary<int, string>();
53
54 [JsonProperty]
56
57 [JsonProperty]
58 public List<int> landFeats;
59
60 [JsonProperty]
62
63 public Map map;
64
66
68
69 public int fileVariation;
70
71 public bool dirtyElectricity;
72
73 public bool isStarted;
74
75 public bool isSimulating;
76
77 public int tempDist;
78
80
81 public static bool ignoreSpawnAnime;
82
83 public static List<Thing> Suckers = new List<Thing>();
84
85 public string ZoneFullName => $"Zone_{id}@{base.lv}";
86
87 public Chara Boss
88 {
89 get
90 {
91 return EClass._map.FindChara(base.uidBoss);
92 }
93 set
94 {
95 base.uidBoss = value?.uid ?? 0;
96 }
97 }
98
99 public override int ContentLv
100 {
101 get
102 {
103 if (branch == null)
104 {
105 return DangerLv;
106 }
107 return branch.ContentLV;
108 }
109 }
110
111 public override int DangerLv
112 {
113 get
114 {
115 if (GetTopZone() != this)
116 {
117 return GetTopZone().DangerLv + Mathf.Abs(base.lv) - 1;
118 }
119 return (int)Mathf.Max(1f, (branch != null) ? ((float)branch.DangerLV) : ((float)base._dangerLv + MathF.Abs(base.lv) + (float)DangerLvFix));
120 }
121 }
122
123 public virtual bool DisableRooms => false;
124
125 public int HourSinceLastActive => EClass.world.date.GetElapsedHour(base.lastActive);
126
127 public int MinsSinceLastActive => EClass.world.date.GetElapsedMins(base.lastActive);
128
129 public virtual string pathExport => CorePath.ZoneSave + idExport.IsEmpty("_new") + ".z";
130
132
133 public virtual string IdBiome => map.config.idBiome.IsEmpty(base.source.idBiome);
134
135 public virtual int SightRadiusBonus => 0;
136
137 public virtual string IDGenerator => null;
138
139 public virtual string TextWidgetDate => "";
140
141 public MapGenerator Generator => ResourceCache.Load<MapGenerator>("DunGenProfile/Generator_" + GetDungenID());
142
143 public virtual string IdProfile => idProfile.IsEmpty(base.source.idProfile);
144
145 public virtual string IDPlayList => base.source.idPlaylist.IsEmpty((base.lv != 0) ? "Underground" : null);
146
147 public virtual string IDPlaylistOverwrite => null;
148
149 public virtual string IDHat => null;
150
151 public virtual string IDBaseLandFeat => base.Tile.source.trait[0];
152
153 public virtual string idExport
154 {
155 get
156 {
157 if (base.source.idFile.Length != 0)
158 {
159 return base.source.idFile[fileVariation] + ((base.lv == 0) ? "" : ("_F" + base.lv));
160 }
161 return "";
162 }
163 }
164
165 public string pathTemp => GameIO.pathTemp + base.uid + "/";
166
167 public Region Region => (this as Region) ?? (parent as Region);
168
170
172
173 public virtual bool BlockBorderExit => base.lv != 0;
174
176
178
179 public virtual ZoneFeatureType FeatureType => ZoneFeatureType.Default;
180
181 public virtual string IDAmbience
182 {
183 get
184 {
185 if (!IsRegion && !map.IsIndoor)
186 {
187 if (!IsTown)
188 {
189 return "forest";
190 }
191 return "town";
192 }
193 return null;
194 }
195 }
196
197 public virtual string IDSceneTemplate
198 {
199 get
200 {
201 if (!EClass._map.IsIndoor)
202 {
203 if (!IsSnowZone)
204 {
205 return "Default";
206 }
207 return "Snow";
208 }
209 return "Indoor";
210 }
211 }
212
213 public virtual bool IsFestival => false;
214
215 public virtual string IDSubset
216 {
217 get
218 {
219 if (!IsFestival)
220 {
221 return null;
222 }
223 return "festival";
224 }
225 }
226
227 public virtual bool IsTown => false;
228
229 public virtual bool CanBeDeliverDestination => IsTown;
230
231 public virtual bool CountDeepestLevel => false;
232
233 public virtual bool HasLaw => false;
234
235 public virtual bool SetAlarmOnBreakLaw => false;
236
237 public virtual bool MakeEnemiesNeutral
238 {
239 get
240 {
241 if (!IsTown)
242 {
243 return HasLaw;
244 }
245 return true;
246 }
247 }
248
249 public virtual bool MakeTownProperties => HasLaw;
250
251 public virtual bool AllowCriminal => !HasLaw;
252
253 public virtual bool AllowInvest
254 {
255 get
256 {
257 if (!IsTown && !IsPCFaction)
258 {
259 return Guild.GetCurrentGuild() != null;
260 }
261 return true;
262 }
263 }
264
265 public virtual bool AllowNewZone => true;
266
267 public virtual bool WillAutoSave => true;
268
269 public virtual bool RegenerateOnEnter => false;
270
271 public virtual bool IsSkyLevel => base.lv > 0;
272
273 public virtual bool IsUnderwater => false;
274
275 public virtual bool IsUserZone => false;
276
277 public virtual bool CanDigUnderground => false;
278
279 public virtual bool LockExit => true;
280
281 public virtual bool CanUnlockExit => !LockExit;
282
283 public virtual int MaxLv => 99999999;
284
285 public virtual int MinLv => -99999999;
286
287 public virtual bool AddPrefix => false;
288
289 public virtual bool IsNefia => false;
290
291 public virtual bool PetFollow => true;
292
293 public virtual bool RestrictBuild
294 {
295 get
296 {
297 if (this is Zone_Civilized)
298 {
299 return !IsPCFaction;
300 }
301 return false;
302 }
303 }
304
305 public virtual bool KeepAllyDistance
306 {
307 get
308 {
309 if (!HasLaw)
310 {
311 return IsPCFaction;
312 }
313 return true;
314 }
315 }
316
317 public virtual int MaxSpawn => map.bounds.Width * map.bounds.Height / 175 + 2;
318
319 public int MaxRespawn => (int)((float)MaxSpawn * RespawnRate) + 1;
320
321 public virtual float RuinChance => 0.1f;
322
323 public virtual float OreChance => 1f;
324
325 public virtual float BigDaddyChance => 0f;
326
327 public virtual float EvolvedChance => 0f;
328
329 public virtual float ShrineChance => 0f;
330
331 public virtual float PrespawnRate => 0f;
332
333 public virtual float RespawnRate => PrespawnRate * 0.5f;
334
336 {
337 get
338 {
339 if (instance != null)
340 {
342 }
343 return false;
344 }
345 }
346
347 public virtual int RespawnPerHour => MaxSpawn / 5 + 1;
348
349 public virtual float ChanceSpawnNeutral => 0.05f;
350
351 public virtual bool GrowPlant => base.mainFaction == EClass.pc.faction;
352
353 public virtual bool GrowWeed => GrowPlant;
354
355 public virtual bool IsExplorable => !base.isRandomSite;
356
357 public virtual bool IsReturnLocation
358 {
359 get
360 {
361 if (EClass.pc.homeZone != this)
362 {
363 return base.source.tag.Contains("return");
364 }
365 return true;
366 }
367 }
368
369 public virtual bool ShouldMakeExit
370 {
371 get
372 {
373 if (base.lv > MinLv)
374 {
375 return base.lv < MaxLv;
376 }
377 return false;
378 }
379 }
380
381 public virtual bool ShouldRegenerate => false;
382
383 public virtual bool ShouldAutoRevive
384 {
385 get
386 {
387 if (!ShouldRegenerate)
388 {
389 return IsPCFaction;
390 }
391 return true;
392 }
393 }
394
395 public virtual bool UseFog => base.lv < 0;
396
397 public virtual bool RevealRoom => false;
398
399 public virtual bool AlwaysLowblock => map.IsIndoor;
400
401 public virtual bool UseLight
402 {
403 get
404 {
405 if (base.mainFaction != EClass.pc.faction)
406 {
407 return base.source.tag.Contains("light");
408 }
409 return true;
410 }
411 }
412
413 public virtual int StartLV => 0;
414
415 public virtual ZoneScaleType ScaleType => ZoneScaleType.None;
416
417 public virtual bool HiddenInRegionMap => false;
418
419 public virtual FlockController.SpawnType FlockType => FlockController.SpawnType.Default;
420
421 public override string NameSuffix
422 {
423 get
424 {
425 if (!IsNefia || !GetTopZone().isConquered)
426 {
427 return "";
428 }
429 return "conquered".lang();
430 }
431 }
432
433 public string NameWithLevel => Name + TextLevel(base.lv);
434
435 public string TextDangerLv => "dangerLv".lang(DangerLv.ToFormat() + ((DangerLvBoost == 0) ? "" : ("<size=15> +" + DangerLvBoost + "</size>")));
436
437 public string TextDeepestLv
438 {
439 get
440 {
441 if (GetDeepestLv() != 0)
442 {
443 return "zoneLevelMax".lang(TextLevel(GetDeepestLv()));
444 }
445 return "";
446 }
447 }
448
450 {
451 get
452 {
454 {
455 return base.mainFaction == EClass.pc.faction;
456 }
457 return true;
458 }
459 }
460
462 {
463 get
464 {
466 {
467 if (base.mainFaction == EClass.pc.faction)
468 {
469 return EClass.Branch.elements.Has(4003);
470 }
471 return false;
472 }
473 return true;
474 }
475 }
476
477 public bool IsPCFaction => base.mainFaction == EClass.pc.faction;
478
480 {
481 get
482 {
483 if (base.mainFaction != EClass.pc.faction)
484 {
485 return EClass._zone is Zone_Tent;
486 }
487 return true;
488 }
489 }
490
491 public bool IsStartZone => this == EClass.game.StartZone;
492
493 public bool IsInstance => instance != null;
494
495 public bool IsLoaded => map != null;
496
497 public virtual int BaseElectricity => 0;
498
499 public bool IsActiveZone => EClass.game.activeZone == this;
500
501 public bool CanInspect
502 {
503 get
504 {
505 if (!IsInstance)
506 {
507 return !HiddenInRegionMap;
508 }
509 return false;
510 }
511 }
512
513 public string InspectName => Name + ((IsTown || IsPCFaction || this is Zone_Civilized) ? "" : TextDangerLv);
514
515 public Point InspectPoint => null;
516
517 public Vector3 InspectPosition => default(Vector3);
518
519 public virtual int MaxSoil
520 {
521 get
522 {
523 if (branch == null)
524 {
525 return 99999;
526 }
527 return branch.MaxSoil;
528 }
529 }
530
531 public Zone FindOrCreateLevel(int destLv, string subId = "")
532 {
533 if (destLv == base.lv)
534 {
535 return this;
536 }
537 Zone zone = FindZone(destLv);
538 if (zone != null)
539 {
540 return zone;
541 }
542 if (!(SpatialGen.Create(subId.IsEmpty(GetNewZoneID(destLv)), this, register: true) is Zone zone2))
543 {
544 return null;
545 }
546 zone2.lv = destLv;
547 zone2.x = base.x;
548 zone2.y = base.y;
549 return zone2;
550 }
551
552 public static (string zoneType, string zoneId, int zoneLv) ParseZoneFullName(string zoneFullName)
553 {
554 int item = 0;
555 zoneFullName = zoneFullName.Replace('/', '@');
556 int num = zoneFullName.LastIndexOf('@');
557 string text;
558 if (num > 0 && num < zoneFullName.Length - 1)
559 {
560 text = zoneFullName[..num];
561 item = zoneFullName[(num + 1)..].ToInt();
562 }
563 else
564 {
565 text = zoneFullName.Replace("@", "");
566 }
567 string text2 = text.Replace("Zone_", "");
568 text = "Zone_" + text2;
569 return (zoneType: text, zoneId: text2, zoneLv: item);
570 }
571
572 public int Evalue(int ele)
573 {
574 return elements.Value(ele);
575 }
576
577 public int Evalue(string alias)
578 {
579 return elements.Value(EClass.sources.elements.alias[alias].id);
580 }
581
582 public virtual string GetDungenID()
583 {
584 return null;
585 }
586
587 public virtual bool ShouldScaleImportedChara(Chara c)
588 {
589 return false;
590 }
591
592 public virtual string GetNewZoneID(int level)
593 {
594 return base.source.id;
595 }
596
597 public override string ToString()
598 {
599 return Name + "(" + base.uid + ")(" + RegionPos?.ToString() + ") instance?" + IsInstance + "/" + EClass.world.date.GetRemainingHours(base.dateExpire) + "h";
600 }
601
602 public string TextLevel(int _lv)
603 {
604 if (_lv != 0)
605 {
606 if (base.lv <= 0)
607 {
608 return " " + "zoneLevelB".lang((_lv * -1).ToString() ?? "");
609 }
610 return " " + "zoneLevel".lang((_lv + 1).ToString() ?? "");
611 }
612 return "";
613 }
614
615 public override void OnCreate()
616 {
617 events.zone = this;
618 base.lv = StartLV;
619 }
620
621 public override void OnAfterCreate()
622 {
623 if (AddPrefix)
624 {
625 if (GetTopZone() == this)
626 {
627 base.idPrefix = EClass.sources.zoneAffixes.rows.RandomItem().id;
628 }
629 else
630 {
631 base.idPrefix = GetTopZone().idPrefix;
632 }
633 }
634 }
635
636 public void Activate()
637 {
638 if (IsRegion)
639 {
641 }
642 isStarted = (isSimulating = false);
643 base.isKnown = true;
644 EClass.game.config.reverseSnow = false;
646 {
647 Msg.Say("regenerateZone", Name);
648 ClearZones();
649 if (EClass.pc.global.transition != null)
650 {
651 EClass.pc.global.transition.uidLastZone = 0;
652 }
653 }
655 if (EClass.game.activeZone != null)
656 {
658 }
659 EClass.game.activeZone = this;
660 ZoneExportData zoneExportData = null;
661 Debug.Log(NameWithLevel + "/" + id + "/" + base.uid + "/" + base.isGenerated + "/" + IsLoaded + "/" + File.Exists(base.pathSave + "map"));
662 if (base.isGenerated && !IsLoaded && !File.Exists(base.pathSave + "map"))
663 {
664 Debug.Log("(Bug) File does not exist:" + destryoed + "/" + base.pathSave);
665 base.isGenerated = false;
666 }
667 bool flag = false;
668 Debug.Log(idCurrentSubset + "/" + IDSubset);
669 bool flag2 = idCurrentSubset != IDSubset || forceSubset != null;
670 if (flag2 && map != null)
671 {
672 UnloadMap();
673 }
674 string fullName = pathExport;
675 string lhs = CorePath.ZoneSave + "_new.z";
676 bool flag3 = File.Exists(fullName) && !PathComparer.Default.Equals(lhs, fullName);
677 bool flag4 = !idExport.IsEmpty();
678 Debug.Log(idExport + "/" + flag3 + "/" + fullName);
679 if (!flag3 && (base.source.tag.Contains("addMap") || flag4))
680 {
681 string[] array = new string[4]
682 {
683 "Maps/" + idExport + ".z",
684 "Maps/" + ZoneFullName + ".z",
685 "Map/" + idExport + ".z",
686 "Map/" + ZoneFullName + ".z"
687 };
688 for (int i = 0; i < array.Length; i++)
689 {
690 FileInfo fileInfo = PackageIterator.GetFiles(array[i]).LastOrDefault();
691 if (fileInfo != null)
692 {
693 fullName = fileInfo.FullName;
694 flag3 = true;
695 flag4 = true;
696 break;
697 }
698 }
699 }
700 if (!base.isGenerated && (!flag4 || !flag3))
701 {
702 Debug.Log("generating random map");
703 flag = true;
704 base.dateExpire = EClass.world.date.GetRaw() + 1440 * ExpireDays;
705 Generate();
707 if (instance != null)
708 {
710 }
711 if (!UseFog)
712 {
713 map.ForeachCell(delegate(Cell c)
714 {
715 c.isSeen = true;
716 });
717 }
718 if (!(bp is GameBlueprint))
719 {
721 }
722 }
723 else if (IsLoaded)
724 {
725 Debug.Log("zone is already loaded");
726 map.SetZone(this);
727 EClass.core.textures.ApplyLocalReplace(base.isMapSaved ? base.pathSave : pathTemp);
729 }
730 else
731 {
732 subset = null;
733 bool flag5 = (base.isGenerated && flag2) || (base.isGenerated && !IsInstance && !IsPCFaction && ShouldRegenerate && EClass.world.date.IsExpired(base.dateRegenerate)) || forceRegenerate;
735 {
736 flag5 = false;
737 flag2 = false;
738 }
739 Debug.Log(base.isGenerated + "/" + flag5 + "/" + flag2 + "/" + IDSubset);
740 if (!base.isGenerated || flag5 || flag2)
741 {
742 Debug.Log("importing map:" + fullName);
743 flag = true;
744 base.dateRegenerate = EClass.world.date.GetRaw() + 1440 * EClass.setting.balance.dateRegenerateZone;
745 if (!flag5)
746 {
747 IO.DeleteDirectory(pathTemp + "Texture Replace");
748 Debug.Log(pathTemp);
749 }
750 try
751 {
752 zoneExportData = Import(fullName);
753 base.isGenerated = true;
754 isImported = true;
755 if (flag5)
756 {
757 zoneExportData.orgMap = GameIO.LoadFile<Map>(base.pathSave + "map");
758 }
759 }
760 catch (Exception message)
761 {
762 Debug.Log(message);
763 zoneExportData = Import(CorePath.ZoneSave + "fail.z");
764 base.isGenerated = true;
765 isImported = true;
766 }
767 }
769 Debug.Log("loading map: imported? " + isImported + " regenerate? " + flag5);
770 string text = (isImported ? pathTemp : base.pathSave) + "map";
771 try
772 {
773 map = GameIO.LoadFile<Map>(text);
774 }
775 catch (Exception message2)
776 {
777 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);
778 Debug.LogError(message2);
779 return;
780 }
781 map.SetZone(this);
782 map.Load(isImported ? pathTemp : base.pathSave, isImported);
784 EClass.core.textures.ApplyLocalReplace(base.isMapSaved ? base.pathSave : pathTemp);
785 if (isImported)
786 {
787 map.deadCharas.Clear();
788 map.OnImport(zoneExportData);
789 if (UseFog && !flag5)
790 {
791 map.ForeachCell(delegate(Cell c)
792 {
793 c.isSeen = false;
794 });
795 }
796 if (zoneExportData.orgMap != null)
797 {
798 Map orgMap = zoneExportData.orgMap;
799 List<Chara> serializedCharas = map.serializedCharas;
800 map.charas = orgMap.charas;
801 map.serializedCharas = orgMap.serializedCharas;
802 map.deadCharas = orgMap.deadCharas;
803 byte[] array2 = orgMap.TryLoadFile(base.pathSave, "flags", EClass._map.Size * EClass._map.Size);
804 if (array2 != null && array2.Length == EClass._map.Size * EClass._map.Size)
805 {
806 for (int j = 0; j < EClass._map.Size; j++)
807 {
808 for (int k = 0; k < EClass._map.Size; k++)
809 {
810 map.cells[j, k].isSeen = array2[j * EClass._map.Size + k].GetBit(1);
811 }
812 }
813 }
814 foreach (Chara item in serializedCharas)
815 {
816 Debug.Log("Importing New Chara:" + item.id + "/" + item.Name + "/" + item.orgPos);
818 }
819 map.things.ForeachReverse(delegate(Thing t)
820 {
821 if (t.trait is TraitNewZone || t.trait is TraitPowerStatue)
822 {
823 foreach (Thing thing in orgMap.things)
824 {
825 if (t.id == thing.id && t.pos.Equals(thing.pos))
826 {
827 if (t.trait is TraitNewZone)
828 {
829 RemoveCard(t);
830 map.things.Insert(0, thing);
831 thing.stackOrder = 0;
832 }
833 else
834 {
835 t.ChangeMaterial(thing.material);
836 t.isOn = thing.isOn;
837 }
838 break;
839 }
840 }
841 return;
842 }
843 if (t.trait is TraitStairsLocked)
844 {
845 foreach (Thing thing2 in orgMap.things)
846 {
847 if (thing2.trait is TraitNewZone && t.pos.Equals(thing2.pos))
848 {
849 RemoveCard(t);
850 map.things.Add(thing2);
851 break;
852 }
853 }
854 return;
855 }
856 if (t.id == "medal" || t.id == "856")
857 {
858 foreach (Thing thing3 in orgMap.things)
859 {
860 if (t.id == thing3.id && t.pos.Equals(thing3.pos))
861 {
862 return;
863 }
864 }
865 RemoveCard(t);
866 }
867 });
868 foreach (KeyValuePair<int, int> item2 in EClass._map.backerObjs.ToList())
869 {
870 EClass._map.GetCell(item2.Key);
871 SourceBacker.Row row = EClass.sources.backers.map[item2.Value];
873 {
874 map.backerObjs.Remove(item2.Key);
875 }
876 }
877 foreach (Chara serializedChara in map.serializedCharas)
878 {
879 if (serializedChara.orgPos != null && serializedChara.orgPos.IsValid)
880 {
881 serializedChara.pos.Set(serializedChara.orgPos);
882 }
883 }
884 foreach (Thing thing4 in orgMap.things)
885 {
886 if (thing4.trait is TraitTent && !thing4.isNPCProperty)
887 {
888 thing4.AddEditorTag(EditorTag.NoNpcProperty);
889 thing4.isSubsetCard = false;
890 map.things.Add(thing4);
891 Debug.Log(thing4);
892 }
893 }
894 }
895 }
896 foreach (Thing thing5 in map.things)
897 {
898 map.AddCardOnActivate(thing5);
899 }
900 foreach (Chara c3 in map.serializedCharas)
901 {
902 if (c3.c_uidMaster == 0 || EClass.player.listCarryoverMap.Find((Chara c2) => c2.uid == c3.uid) == null)
903 {
904 map.charas.Add(c3);
906 }
907 }
908 map.serializedCharas.Clear();
909 if (isImported && IsTown)
910 {
912 }
915 map.OnLoad();
916 if (flag5)
917 {
918 foreach (Card item3 in map.Cards.ToList())
919 {
920 if (item3.isSubsetCard)
921 {
922 item3.Destroy();
923 }
924 }
925 }
926 if (isImported)
927 {
929 if (idCurrentSubset != null)
930 {
932 subset.Apply();
933 }
934 }
935 if (isImported)
936 {
938 {
939 foreach (Thing thing6 in map.things)
940 {
941 thing6.isNPCProperty = !thing6.isHidden && !thing6.HasEditorTag(EditorTag.NoNpcProperty);
942 }
943 }
944 else
945 {
946 foreach (Thing thing7 in map.things)
947 {
948 thing7.isNPCProperty = false;
949 }
950 }
952 if (instance != null)
953 {
955 }
956 }
957 if (isImported && !flag5 && !RevealRoom)
958 {
959 foreach (Room item4 in map.rooms.listRoom)
960 {
961 if (!item4.HasRoof || item4.data.atrium)
962 {
963 continue;
964 }
965 foreach (Point point2 in item4.points)
966 {
967 point2.cell.isSeen = false;
968 }
969 }
970 }
971 if (flag5)
972 {
973 OnRegenerate();
974 }
975 }
976 PathManager.Instance._pathfinder.PunishChangeDirection = false;
977 isImported = false;
978 if (this is Zone_Tent && IsUnderwater)
979 {
980 EClass._map.config.idSceneProfile = "indoor_water";
981 EClass.scene.profile = SceneProfile.Load(EClass._map.config.idSceneProfile);
982 }
983 if (flag && IsTown && base.lv == 0)
984 {
986 }
987 if (base.visitCount == 0)
988 {
989 base.dateRevive = EClass.world.date.GetRaw() + 1440 * EClass.setting.balance.dateRevive;
990 }
991 map.ForeachCell(delegate(Cell c)
992 {
993 if (c.HasFire)
994 {
995 map.effectManager.GetOrCreate(c.GetSharedPoint());
996 }
997 if (IsRegion)
998 {
999 c.decal = 0;
1000 }
1001 });
1003 {
1004 RainWater();
1005 }
1007 {
1008 map.ForeachCell(delegate(Cell c)
1009 {
1010 c.isSeen = true;
1011 });
1012 }
1013 isStarted = true;
1014 Map.isDirtySunMap = true;
1016 if (events.listPreEnter.Count > 0)
1017 {
1018 foreach (ZonePreEnterEvent item5 in events.listPreEnter)
1019 {
1020 item5.Execute();
1021 }
1022 events.listPreEnter.Clear();
1023 }
1024 foreach (Card card in map.Cards)
1025 {
1026 card.CalculateFOV();
1027 if (card.isChara)
1028 {
1029 Chara chara = card.Chara;
1030 chara.dirtySpeed = true;
1031 if (!card.isDyed && card.HasTag(CTAG.random_color))
1032 {
1033 card.DyeRandom();
1034 }
1035 if (card.IsUnique && !card.IsPCFaction && !card.IsPCParty)
1036 {
1037 Point point = chara.orgPos ?? card.pos;
1038 card.c_uniqueData = new UniqueData
1039 {
1040 x = point.x,
1041 y = point.z,
1042 uidZone = base.uid
1043 };
1044 }
1045 int @int = card.GetInt(55);
1046 if (@int != 0)
1047 {
1048 foreach (Chara chara2 in map.charas)
1049 {
1050 if (chara2.uid == @int)
1051 {
1052 if (chara.IsHostile(chara2))
1053 {
1054 chara.enemy = chara2;
1055 chara.SetAI(new GoalCombat());
1056 chara.calmCheckTurn = 20 + EClass.rnd(30);
1057 }
1058 break;
1059 }
1060 }
1061 card.SetInt(55);
1062 }
1063 chara.SyncRide();
1064 if (card.c_uidMaster != 0 && chara.master == null)
1065 {
1066 chara.FindMaster();
1067 }
1068 if (!EClass.game.isLoading)
1069 {
1070 chara.enemy = null;
1071 if (chara.IsInCombat)
1072 {
1073 chara.SetNoGoal();
1074 }
1075 }
1076 }
1077 else if (card.IsInstalled && card.trait is TraitDoor traitDoor && card.pos.HasChara && !traitDoor.IsOpen())
1078 {
1079 traitDoor.ToggleDoor(sound: false, refresh: false);
1080 }
1081 }
1082 RefreshHat();
1083 forceRegenerate = false;
1084 forceSubset = null;
1085 EClass.ui.OnActivateZone();
1087 EClass.Sound.LoadAmbience(IDAmbience);
1088 if (EClass.Branch != null)
1089 {
1091 }
1092 OnVisit();
1093 if (flag)
1094 {
1096 }
1098 if (IsPCFaction)
1099 {
1100 EClass.player.uidLastTown = 0;
1101 }
1102 else if (IsTown && base.lv == 0)
1103 {
1104 EClass.player.uidLastTown = base.uid;
1105 }
1106 RefreshBGM();
1107 Rand.InitBytes(map.seed + 1);
1109 okaerinko = 0;
1110 if (EClass.debug.enable)
1111 {
1112 ModInfluence(2000);
1113 }
1114 if (this is Zone_TinkerCamp)
1115 {
1116 Tutorial.Reserve("tinker");
1117 }
1118 else if (this is Zone_Town && !(this is Zone_SubTown))
1119 {
1120 Tutorial.Reserve("town");
1121 }
1122 }
1123
1124 public void RefreshHat()
1125 {
1126 if (idHat != null && EClass.world.date.IsExpired(base.dateHat))
1127 {
1128 idHat = null;
1129 base.dateHat = 0;
1130 }
1131 sourceHat = ((idHat != null) ? EClass.sources.cards.map[idHat] : ((IDHat != null) ? EClass.sources.cards.map[IDHat] : null));
1132 }
1133
1134 public void OnVisit()
1135 {
1136 if (EClass.world.date.IsExpired(base.dateRevive))
1137 {
1139 Revive();
1140 List<Chara> list = new List<Chara>();
1141 foreach (Chara chara in EClass._map.charas)
1142 {
1143 chara.TryRestock(onCreate: false);
1144 if (!chara.IsPCFaction)
1145 {
1146 chara.c_fur = 0;
1147 }
1148 if (chara.IsMinion && chara.master != null && !chara.master.IsPCParty)
1149 {
1150 list.Add(chara);
1151 }
1152 }
1153 foreach (Chara item in list)
1154 {
1155 item.Destroy();
1156 }
1157 }
1158 if (!EClass.game.isLoading)
1159 {
1161 }
1164 events.OnVisit();
1165 OnActivate();
1166 UpdateQuests();
1168 isSimulating = true;
1169 Simulate();
1170 isSimulating = false;
1172 if (EClass.Branch != null)
1173 {
1175 }
1176 base.lastActive = EClass.world.date.GetRaw();
1177 if (!EClass.game.isLoading)
1178 {
1179 base.visitCount++;
1180 }
1181 base.version = EClass.core.version.GetInt();
1182 if (HasField(10000))
1183 {
1184 Tutorial.Reserve("field");
1185 }
1186 }
1187
1189 {
1190 foreach (Chara chara in EClass._map.charas)
1191 {
1192 if (chara.HasCondition<ConDeathSentense>())
1193 {
1194 chara.GetCondition<ConDeathSentense>().TryRemove();
1195 }
1196 }
1197 }
1198
1199 public void Revive()
1200 {
1201 base.dateRevive = EClass.world.date.GetRaw() + 1440 * EClass.setting.balance.dateRevive;
1202 if (ShouldAutoRevive)
1203 {
1204 foreach (Chara deadChara in map.deadCharas)
1205 {
1206 if (deadChara.trait.CanAutoRevive && deadChara.CanRevive())
1207 {
1208 deadChara.Revive();
1210 {
1211 deadChara.RemoveBacker();
1212 }
1213 EClass._zone.AddCard(deadChara, (deadChara.orgPos != null && deadChara.orgPos.IsInBounds) ? deadChara.orgPos : deadChara.pos);
1214 }
1215 }
1216 }
1217 foreach (Chara value in EClass.game.cards.globalCharas.Values)
1218 {
1219 if (value.isDead && value.CanRevive() && value.homeZone == this)
1220 {
1221 value.Revive();
1222 Point point = GetSpawnPos(value);
1223 if (value.orgPos != null && value.orgPos.IsInBounds)
1224 {
1225 point = value.orgPos.GetNearestPoint() ?? point;
1226 }
1227 EClass._zone.AddCard(value, point);
1228 }
1229 }
1230 map.deadCharas.Clear();
1231 }
1232
1233 public virtual void OnRegenerate()
1234 {
1235 }
1236
1237 public virtual void OnActivate()
1238 {
1239 if (!(id == "startVillage2"))
1240 {
1241 return;
1242 }
1243 if (EClass._map.version.IsBelow(0, 23, 226))
1244 {
1245 SetBGM(121, refresh: false);
1246 }
1247 int num = 0;
1248 foreach (Chara chara in EClass._map.charas)
1249 {
1250 if (chara.id == "cat_silver" && !chara.IsPCFaction)
1251 {
1252 num++;
1253 }
1254 }
1255 if (num > 0)
1256 {
1257 Msg.Say("num_silvercat", num.ToString() ?? "");
1258 }
1259 }
1260
1261 public virtual void OnBeforeDeactivate()
1262 {
1263 }
1264
1265 public virtual void OnDeactivate()
1266 {
1267 }
1268
1269 public virtual void OnBeforeSimulate()
1270 {
1271 }
1272
1273 public virtual void OnVisitNewMapOrRegenerate()
1274 {
1275 }
1276
1277 public virtual void OnAfterSimulate()
1278 {
1279 }
1280
1281 public virtual void OnAdvanceHour()
1282 {
1283 }
1284
1285 public void Simulate()
1286 {
1287 if (!EClass.game.isLoading && base.visitCount > 0)
1288 {
1289 if (Boss != null && IsNefia)
1290 {
1291 Msg.Say("bossLeave", Boss.Name.ToTitleCase(), EClass._zone.Name);
1294 }
1295 int num = Mathf.Clamp(MinsSinceLastActive, 1, 10000);
1296 foreach (Chara chara2 in EClass._map.charas)
1297 {
1298 if (chara2.hp < 0)
1299 {
1300 chara2.hp = 0;
1301 }
1302 if (!chara2.IsPCParty)
1303 {
1304 if (chara2.mana.value < 0)
1305 {
1306 chara2.mana.value = 0;
1307 }
1308 if (chara2.stamina.value < 0)
1309 {
1310 chara2.stamina.value = 0;
1311 }
1312 }
1313 if (num > 60)
1314 {
1315 chara2.resistCon = null;
1316 }
1317 if (chara2.rarity >= Rarity.Legendary && !chara2.IsPCFaction && num > 0)
1318 {
1319 Msg.ignoreAll = true;
1320 chara2.Cure(CureType.Boss, 20 + num * 10);
1321 chara2.HealHP((int)((long)Mathf.Max(1, chara2.MaxHP) * (long)Mathf.Min(num, 20) / 20));
1322 chara2.mana.Mod(Mathf.Max(1, chara2.mana.max) * Mathf.Min(num, 20) / 20);
1323 chara2.stamina.Mod(Mathf.Max(1, chara2.stamina.max) * Mathf.Min(num, 20) / 20);
1324 Msg.ignoreAll = false;
1325 }
1326 }
1327 }
1328 Debug.Log("Last Active:" + base.lastActive);
1329 if (base.lastActive == 0 || HourSinceLastActive <= 1 || IsRegion)
1330 {
1331 return;
1332 }
1333 Debug.Log(Name + " Simulate:" + HourSinceLastActive + " hours");
1334 VirtualDate virtualDate = new VirtualDate(HourSinceLastActive);
1335 List<Chara> list = EClass._map.charas.ToList();
1336 int num2 = HourSinceLastActive / 24;
1337 int num3 = 0;
1338 if (num2 > 0)
1339 {
1340 foreach (Chara item in list)
1341 {
1342 if (!item.IsPCParty)
1343 {
1344 item.OnSleep(200, num2);
1345 if (item.conSleep != null)
1346 {
1347 item.conSleep.Kill();
1348 }
1349 if (EClass.rnd(EClass.world.date.IsNight ? 20 : 200) == 0 && !item.IsPCFaction)
1350 {
1351 item.AddCondition<ConSleep>(1000 + EClass.rnd(1000), force: true);
1352 }
1353 if (item.things.Count > 20)
1354 {
1355 item.ClearInventory(ClearInventoryType.Purge);
1356 }
1357 }
1358 }
1359 }
1360 VirtualDate.current = virtualDate;
1361 for (int i = 0; i < HourSinceLastActive; i++)
1362 {
1363 virtualDate.SimulateHour();
1364 if (!virtualDate.IsWinter)
1365 {
1366 num3++;
1367 }
1368 }
1369 EClass._map.things.ForeachReverse(delegate(Thing t)
1370 {
1372 });
1373 VirtualDate.current = null;
1374 if (!IsPCFaction)
1375 {
1376 return;
1377 }
1378 int num4 = 0;
1379 foreach (Chara item2 in list)
1380 {
1381 if (item2.IsPCParty)
1382 {
1383 continue;
1384 }
1385 if (!item2.IsHomeMember())
1386 {
1387 if (item2.id == "bee")
1388 {
1389 num4++;
1390 }
1391 if (num2 > 0 && item2.IsGuest())
1392 {
1393 item2.ChooseNewGoal();
1394 item2.ai.SimulateZone(num2);
1395 }
1396 continue;
1397 }
1398 if (num2 > 0)
1399 {
1400 Goal goalWork = item2.GetGoalWork();
1401 item2.SetAI(goalWork);
1402 if (goalWork is GoalWork)
1403 {
1404 (goalWork as GoalWork).FindWork(item2);
1405 }
1406 item2.ai.SimulateZone(num2);
1407 goalWork = item2.GetGoalHobby();
1408 item2.SetAI(goalWork);
1409 if (goalWork is GoalWork)
1410 {
1411 (goalWork as GoalWork).FindWork(item2);
1412 }
1413 item2.ai.SimulateZone(num2);
1414 }
1415 item2.ChooseNewGoal();
1416 if (item2.conSuspend == null)
1417 {
1418 item2.ai.OnSimulatePosition();
1419 }
1420 }
1421 List<Thing> list2 = new List<Thing>();
1422 foreach (Thing thing in map.things)
1423 {
1424 if (thing.IsInstalled && thing.trait is TraitBeekeep)
1425 {
1426 list2.Add(thing);
1427 }
1428 }
1429 if (num4 >= list2.Count)
1430 {
1431 return;
1432 }
1433 for (int j = num4; j < list2.Count; j++)
1434 {
1435 if (EClass.rnd(200) <= HourSinceLastActive)
1436 {
1437 Chara chara = CharaGen.Create("bee");
1438 AddCard(chara, list2.RandomItem().pos);
1439 Hostility c_originalHostility = (chara.hostility = Hostility.Neutral);
1440 chara.c_originalHostility = c_originalHostility;
1441 }
1442 }
1443 }
1444
1446 {
1447 ZoneTransition zoneTransition = c.global?.transition;
1448 Zone zone = zoneTransition?.lastZone;
1449 ZoneTransition.EnterState enterState = zoneTransition?.state ?? destState;
1450 bool flag = zone == null || zone.lv > base.lv;
1451 if (IsRegion)
1452 {
1453 if (zone != null && !EClass.player.simulatingZone)
1454 {
1455 Zone topZone = zone.GetTopZone();
1456 if (GetZoneAt(topZone.x, topZone.y) != null)
1457 {
1458 return new Point(topZone.mapX, topZone.mapY);
1459 }
1460 }
1461 }
1462 else if (c.IsPC && EClass.player.lastZonePos != null && zone != null && zone.IsRegion && (enterState == ZoneTransition.EnterState.Left || enterState == ZoneTransition.EnterState.Right || enterState == ZoneTransition.EnterState.Top || enterState == ZoneTransition.EnterState.Bottom))
1463 {
1464 return EClass.player.lastZonePos;
1465 }
1466 if (enterState == ZoneTransition.EnterState.Region)
1467 {
1468 enterState = RegionEnterState;
1469 }
1470 if (this is Zone_Kapul && enterState == ZoneTransition.EnterState.Left)
1471 {
1472 enterState = ZoneTransition.EnterState.Right;
1473 }
1474 float rate = zoneTransition?.ratePos ?? (-1f);
1475 if (IsPCFaction)
1476 {
1477 if ((uint)(enterState - 3) <= 4u || enterState == ZoneTransition.EnterState.Return)
1478 {
1480 if (spot != null)
1481 {
1482 Point nearestPoint = (spot.trait as TraitSpotGuidePC).GetRandomPoint((Point p) => !p.IsBlocked && !p.Equals(spot.pos)).GetNearestPoint();
1483 if (nearestPoint != null && nearestPoint.IsValid)
1484 {
1485 return nearestPoint;
1486 }
1487 }
1488 }
1489 }
1490 while (true)
1491 {
1492 switch (enterState)
1493 {
1494 case ZoneTransition.EnterState.UndergroundOrSky:
1495 return new Point(zoneTransition.x, zoneTransition.z);
1496 case ZoneTransition.EnterState.Teleport:
1497 {
1498 foreach (Thing thing2 in map.things)
1499 {
1500 if (thing2.IsInstalled)
1501 {
1502 TraitTeleporter traitTeleporter = thing2.trait as TraitTeleporter;
1503 if (traitTeleporter != null)
1504 {
1505 Debug.Log(zoneTransition.idTele + "/" + traitTeleporter.id.IsEmpty(traitTeleporter.GetParam(3)) + "/" + traitTeleporter.GetParam(3));
1506 }
1507 if (traitTeleporter != null && !zoneTransition.idTele.IsEmpty() && zoneTransition.idTele == traitTeleporter.id.IsEmpty(traitTeleporter.GetParam(3)))
1508 {
1509 return thing2.pos.GetNearestPoint();
1510 }
1511 }
1512 }
1513 foreach (Thing thing3 in map.things)
1514 {
1515 if (thing3.IsInstalled && thing3.trait is TraitTeleporter traitTeleporter2 && traitTeleporter2.IsFor(zoneTransition.lastZone))
1516 {
1517 return thing3.pos.GetNearestPoint();
1518 }
1519 }
1520 Thing randomThing2 = EClass._map.props.installed.traits.GetRandomThing<TraitTeleporter>();
1521 if (randomThing2 != null)
1522 {
1523 return randomThing2.pos.GetNearestPoint();
1524 }
1525 goto case ZoneTransition.EnterState.Return;
1526 }
1527 case ZoneTransition.EnterState.Return:
1528 case ZoneTransition.EnterState.Elevator:
1529 case ZoneTransition.EnterState.Moongate:
1530 {
1531 if (enterState == ZoneTransition.EnterState.Elevator)
1532 {
1533 foreach (Thing thing4 in map.things)
1534 {
1535 if (thing4.IsInstalled && thing4.trait is TraitElevator traitElevator && traitElevator.IsFor(zoneTransition.lastZone))
1536 {
1537 return thing4.pos.GetNearestPoint();
1538 }
1539 }
1540 Thing randomThing = EClass._map.props.installed.traits.GetRandomThing<TraitElevator>();
1541 if (randomThing != null)
1542 {
1543 return randomThing.pos.GetNearestPoint();
1544 }
1545 }
1546 Thing thing = null;
1547 thing = map.props.installed.traits.GetRandomThing<TraitWaystone>();
1548 if (thing != null)
1549 {
1550 return thing.pos.GetNearestPoint();
1551 }
1552 thing = map.props.installed.traits.GetRandomThing<TraitCoreZone>();
1553 if (thing != null)
1554 {
1555 return thing.pos.GetNearestPoint();
1556 }
1557 if (base.lv == 0)
1558 {
1559 goto IL_04a1;
1560 }
1561 flag = base.lv <= 0;
1562 break;
1563 }
1564 case ZoneTransition.EnterState.Center:
1565 case ZoneTransition.EnterState.Encounter:
1566 if (map.config.embarkX != 0)
1567 {
1568 return new Point(map.config.embarkX, map.config.embarkY);
1569 }
1570 return map.GetCenterPos().GetNearestPoint(allowBlock: false, allowChara: false);
1571 case ZoneTransition.EnterState.Top:
1572 return map.bounds.GetTopPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1573 case ZoneTransition.EnterState.Right:
1574 return map.bounds.GetRightPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1575 case ZoneTransition.EnterState.Bottom:
1576 return map.bounds.GetBottomPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1577 case ZoneTransition.EnterState.Left:
1578 return map.bounds.GetLeftPos(rate).GetNearestPoint(allowBlock: false, allowChara: false);
1579 case ZoneTransition.EnterState.Dead:
1580 case ZoneTransition.EnterState.Exact:
1581 case ZoneTransition.EnterState.PortalReturn:
1582 case ZoneTransition.EnterState.Fall:
1583 if (zoneTransition.x == 0 && EClass._map.bounds.x != 0)
1584 {
1585 return new Point(map.config.embarkX, map.config.embarkY);
1586 }
1587 return new Point(zoneTransition.x, zoneTransition.z);
1588 case ZoneTransition.EnterState.RandomVisit:
1589 return GetRandomVisitPos(c);
1590 case ZoneTransition.EnterState.Down:
1591 flag = true;
1592 break;
1593 case ZoneTransition.EnterState.Up:
1594 flag = false;
1595 break;
1596 }
1597 break;
1598 IL_04a1:
1599 enterState = ZoneTransition.EnterState.Center;
1600 }
1601 foreach (Thing thing5 in map.things)
1602 {
1603 if (thing5.trait is TraitNewZone { zone: not null } traitNewZone && zone != null && traitNewZone.zone.uid == zone.uid)
1604 {
1605 if (c != null && enterState != 0)
1606 {
1607 c.SetDir(traitNewZone.owner.dir);
1608 }
1609 return traitNewZone.GetExitPos();
1610 }
1611 }
1612 foreach (Thing thing6 in map.things)
1613 {
1614 if (thing6.trait is TraitNewZone traitNewZone2 && ((flag && traitNewZone2.IsUpstairs) || (!flag && traitNewZone2.IsDownstairs)))
1615 {
1616 if (c != null && enterState != 0)
1617 {
1618 c.SetDir(traitNewZone2.owner.dir);
1619 }
1620 return traitNewZone2.GetExitPos();
1621 }
1622 }
1623 return GetRandomVisitPos(c);
1624 }
1625
1627 {
1628 Point point = null;
1629 if (EClass.rnd(3) == 0 && map.rooms.listRoom.Count > 0)
1630 {
1631 point = map.rooms.listRoom.RandomItem().points.RandomItem();
1632 }
1633 if (point == null && EClass.rnd(4) != 0)
1634 {
1635 IEnumerable<Chara> ie = map.charas.Where((Chara t) => t.trait.ShopType != 0 && t.pos != null && t.pos.IsValid);
1636 if (ie.Count() > 0)
1637 {
1638 point = ie.RandomItem().pos.GetRandomPoint(3);
1639 }
1640 }
1641 if (point == null)
1642 {
1643 point = map.bounds.GetRandomSurface(centered: false, walkable: true, !IsPCFaction && !(this is Zone_Civilized)) ?? map.bounds.GetRandomPoint();
1644 }
1645 return point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false) ?? EClass._map.GetCenterPos().GetNearestPoint();
1646 }
1647
1649 {
1650 Point spawnPosPC = null;
1651 if (EClass.pc.currentZone == this)
1652 {
1653 spawnPosPC = GetSpawnPos(EClass.pc);
1654 }
1655 if (spawnPosPC == null)
1656 {
1657 spawnPosPC = map.GetCenterPos();
1658 }
1659 if (spawnPosPC.IsValid && EClass.pc.global.transition != null && spawnPosPC.HasBlock)
1660 {
1661 spawnPosPC = spawnPosPC.GetNearestPoint();
1662 }
1663 spawnPosPC = spawnPosPC.Clamp(useBounds: true).GetNearestPoint();
1664 foreach (Chara c in EClass.game.cards.globalCharas.Values)
1665 {
1666 if (c.currentZone != this)
1667 {
1668 continue;
1669 }
1670 if (c.parent is Chara)
1671 {
1672 Chara chara = c.parent as Chara;
1673 c.currentZone = chara.currentZone;
1674 }
1675 else
1676 {
1677 if (c.isDead)
1678 {
1679 continue;
1680 }
1681 if (c.isRestrained && c.currentZone == EClass.pc.currentZone && (!c.pos.IsValid || c.pos.FindThing<TraitShackle>() == null))
1682 {
1683 c.isRestrained = false;
1684 }
1685 if (c.global.transition != null)
1686 {
1687 Point pos = (c.IsPC ? spawnPosPC : (c.IsPCParty ? spawnPosPC.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: true, ignoreCenter: true) : GetSpawnPos(c)));
1688 if (c.IsPCParty && !c.IsPC)
1689 {
1690 if (c.host == EClass.pc)
1691 {
1692 pos.Set(spawnPosPC);
1693 }
1694 else if (pos.Equals(spawnPosPC) || !PathManager.Instance.IsPathClear(spawnPosPC, pos, c, 5))
1695 {
1696 c.pos.Set(spawnPosPC);
1697 if (!spawnPosPC.ForeachNearestPoint(delegate(Point p)
1698 {
1699 if (PathManager.Instance.IsPathClear(spawnPosPC, p, c, 10) && !p.Equals(spawnPosPC))
1700 {
1701 pos.Set(p);
1702 return true;
1703 }
1704 return false;
1705 }, allowBlock: false, EClass.pc.party.members.Count >= 12, allowInstalled: true, ignoreCenter: true, EClass._zone.IsRegion ? 2 : 6))
1706 {
1707 pos.Set(spawnPosPC);
1708 }
1709 }
1710 }
1711 c.pos.Set(pos);
1712 c.global.transition = null;
1713 }
1714 map.charas.Add(c);
1716 }
1717 }
1719 {
1720 Point nearestPoint = spawnPosPC.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: true, ignoreCenter: true);
1721 item.enemy = null;
1722 item.pos.Set(nearestPoint);
1723 map.charas.Add(item);
1725 }
1727 }
1728
1729 public void Deactivate()
1730 {
1731 if (!IsUserZone && !IsPCFaction && map != null)
1732 {
1733 List<Thing> list = new List<Thing>();
1734 foreach (Thing thing in map.things)
1735 {
1736 if (thing.rarity >= Rarity.Artifact && thing.HasTag(CTAG.godArtifact))
1737 {
1738 list.Add(thing);
1739 }
1740 }
1741 if (this is Zone_Tent)
1742 {
1743 foreach (Thing item in map.props.stocked.Things.Concat(map.props.roaming.Things))
1744 {
1745 if (item.IsContainer)
1746 {
1747 foreach (Thing thing2 in item.things)
1748 {
1749 if (thing2.trait is TraitTent)
1750 {
1751 list.Add(thing2);
1752 }
1753 }
1754 }
1755 if (item.trait is TraitTent)
1756 {
1757 list.Add(item);
1758 }
1759 }
1760 }
1761 if (list.Count > 0)
1762 {
1763 Msg.Say("pick_valuable");
1764 foreach (Thing item2 in list)
1765 {
1766 Msg.Say("pick_valuable2", item2);
1767 EClass.pc.AddCard(item2);
1768 }
1769 }
1770 }
1772 {
1773 base.isPeace = false;
1774 }
1776 if (IsPCFaction)
1777 {
1778 foreach (Chara member in branch.members)
1779 {
1780 member.ValidateWorks();
1781 }
1782 }
1783 EClass.game.lastActiveZone = EClass.game.activeZone;
1784 base.lastActive = EClass.world.date.GetRaw();
1785 map.OnDeactivate();
1786 EClass.scene.Clear();
1787 EClass.game.activeZone = null;
1788 if (IsInstance)
1789 {
1790 UnloadMap();
1791 base.isGenerated = false;
1792 }
1793 if (forceRegenerate)
1794 {
1795 UnloadMap();
1796 }
1797 OnDeactivate();
1798 }
1799
1800 public void OnKillGame()
1801 {
1802 foreach (Thing thing in map.things)
1803 {
1804 if (thing.renderer.hasActor)
1805 {
1806 thing.renderer.KillActor();
1807 }
1808 }
1809 }
1810
1811 public void UnloadMap()
1812 {
1813 map = null;
1814 if (bp != null)
1815 {
1816 bp.map = null;
1817 }
1818 if (branch != null)
1819 {
1821 }
1822 Debug.Log("Unloaded Map:" + this);
1823 }
1824
1825 public void ClaimZone(bool debug = false, Point pos = null)
1826 {
1829 branch = new FactionBranch();
1830 branch.OnCreate(this);
1831 if (base.icon == 0)
1832 {
1833 base.icon = 332;
1834 }
1835 instance = null;
1836 base.dateExpire = 0;
1838 Register();
1839 foreach (Thing thing in map.things)
1840 {
1841 thing.isNPCProperty = false;
1842 }
1845 if (debug)
1846 {
1847 for (int i = 0; i < 7; i++)
1848 {
1849 Chara chara = CharaGen.CreateFromFilter("c_neutral");
1850 EClass._zone.AddCard(chara, EClass._map.bounds.GetRandomPoint().GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false));
1851 branch.AddMemeber(chara);
1852 }
1853 }
1854 else
1855 {
1856 Msg.Say("claimedZone");
1857 EClass.Branch.Log("claimedZone");
1858 EClass.Sound.Play("jingle_embark");
1859 EClass.pc.PlaySound("build");
1860 if (pos == null)
1861 {
1862 pos = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: true, allowInstalled: false);
1863 }
1864 Effect.Get("aura_heaven").Play(pos);
1865 EClass._zone.AddCard(ThingGen.Create("core_zone"), pos).SetPlaceState(PlaceState.installed);
1866 }
1867 base.idPrefix = 0;
1869 {
1870 EClass.player.spawnZone = EClass._zone;
1871 }
1873 {
1874 EClass._zone.SetBGM(new List<int> { 41, 90, 44, 43 });
1876 }
1877 }
1878
1879 public void AbandonZone()
1880 {
1881 FactionBranch destBranch = ((EClass.pc.homeBranch == branch) ? EClass.game.StartZone.branch : EClass.pc.homeBranch);
1882 branch.members.ForeachReverse(delegate(Chara m)
1883 {
1884 destBranch.AddMemeber(m);
1885 if (!m.IsPCParty)
1886 {
1887 m.MoveZone(destBranch.owner);
1888 }
1889 });
1891 SetMainFaction(null);
1892 base.dateExpire = EClass.world.date.GetRaw() + 10080;
1893 }
1894
1895 public bool CanDestroy()
1896 {
1898 {
1899 return false;
1900 }
1901 if (IsInstance)
1902 {
1903 return true;
1904 }
1905 bool flag = false;
1906 switch (id)
1907 {
1908 case "cave_dragon":
1909 if (!(this is Zone_DungeonDragon))
1910 {
1911 flag = true;
1912 }
1913 break;
1914 case "cave_yeek":
1915 if (!(this is Zone_DungeonYeek))
1916 {
1917 flag = true;
1918 }
1919 break;
1920 case "cave_mino":
1921 if (!(this is Zone_DungeonMino))
1922 {
1923 flag = true;
1924 }
1925 break;
1926 case "cave_dead":
1927 if (!(this is Zone_DungeonDead))
1928 {
1929 flag = true;
1930 }
1931 break;
1932 }
1933 Zone topZone = GetTopZone();
1934 if (!flag)
1935 {
1936 if (base.dateExpire == 0 || !EClass.world.date.IsExpired(base.dateExpire))
1937 {
1938 return false;
1939 }
1940 if (!base.isRandomSite && !(this is Zone_Field) && (topZone == null || topZone == this || topZone.FindDeepestZone() == this))
1941 {
1942 return false;
1943 }
1944 }
1945 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()))
1946 {
1947 return false;
1948 }
1950 {
1952 if (zone != null && zone.GetTopZone() == this)
1953 {
1954 return false;
1955 }
1956 }
1957 return true;
1958 }
1959
1960 public override void _OnBeforeSave()
1961 {
1962 if (CanDestroy())
1963 {
1964 Debug.Log("Deleting Zone:" + this);
1965 if (!destryoed)
1966 {
1967 Destroy();
1968 }
1969 }
1970 else if (map != null)
1971 {
1972 Debug.Log("Saving Zone:" + this);
1973 map.Save(base.pathSave);
1974 if (!base.isMapSaved)
1975 {
1976 base.isMapSaved = true;
1977 IO.DeleteDirectory(base.pathSave + "Texture Replace");
1978 IO.CopyDir(pathTemp + "Texture Replace", base.pathSave + "/Texture Replace");
1979 }
1980 if (!IsActiveZone)
1981 {
1982 UnloadMap();
1983 }
1984 }
1985 }
1986
1987 public override void OnLoad()
1988 {
1989 if (branch != null)
1990 {
1991 branch.SetOwner(this);
1992 }
1993 events.OnLoad(this);
1994 }
1995
1996 public override void Destroy()
1997 {
1998 children.ForeachReverse(delegate(Spatial z)
1999 {
2000 z.Destroy();
2001 });
2002 if (map != null)
2003 {
2004 UnloadMap();
2005 }
2006 if (parent != null && parent.IsRegion && instance == null)
2007 {
2008 EClass.scene.elomap.SetZone(base.x, base.y, null, updateMesh: true);
2009 }
2010 EClass.game.spatials.Remove(this);
2011 destryoed = true;
2012 base.isGenerated = false;
2013 }
2014
2015 public void ClearZones(Zone current = null)
2016 {
2017 if (map != null)
2018 {
2019 UnloadMap();
2020 }
2021 base.isGenerated = false;
2022 Zone topZone = GetTopZone();
2023 if (topZone != this)
2024 {
2025 topZone.ClearZones(this);
2026 return;
2027 }
2028 children.ForeachReverse(delegate(Spatial c)
2029 {
2030 if (c != current)
2031 {
2032 c.Destroy();
2033 }
2034 });
2035 }
2036
2037 public void OnChildNumChange(Card c)
2038 {
2039 }
2040
2042 {
2043 return this;
2044 }
2045
2047 {
2048 if (parent == null || parent.IsRegion)
2049 {
2050 return this;
2051 }
2052 return parent as Zone;
2053 }
2054
2055 public Card AddCardSplinkle(Card t, Point center, int radius = 4)
2056 {
2057 Point point = new Point(center);
2058 for (int i = 0; i < 1000; i++)
2059 {
2060 point.x = center.x + EClass.rnd(radius) - EClass.rnd(radius);
2061 point.z = center.z + EClass.rnd(radius) - EClass.rnd(radius);
2062 if (point.IsValid && !point.IsBlocked && !point.HasChara)
2063 {
2064 return AddCard(t, point);
2065 }
2066 }
2067 return AddCard(t, center);
2068 }
2069
2070 public Chara AddChara(string id, int x, int z)
2071 {
2072 return AddCard(CharaGen.Create(id), x, z) as Chara;
2073 }
2074
2075 public Chara AddChara(string id, Point p)
2076 {
2077 return AddChara(id, p.x, p.z);
2078 }
2079
2080 public Card AddThing(string id, int x, int z)
2081 {
2082 return AddCard(ThingGen.Create(id), x, z);
2083 }
2084
2085 public Card AddThing(string id, Point p)
2086 {
2087 return AddThing(id, p.x, p.z);
2088 }
2089
2090 public Card AddCard(Card t, Point point)
2091 {
2092 return AddCard(t, point.x, point.z);
2093 }
2094
2096 {
2097 return AddCard(t, 0, 0);
2098 }
2099
2100 public Card AddCard(Card t, int x, int z)
2101 {
2102 if (t.parent != null)
2103 {
2104 t.parent.RemoveCard(t);
2105 }
2106 t.parent = this;
2107 Chara chara = t.Chara;
2108 if (chara != null)
2109 {
2110 chara.currentZone = this;
2111 chara.SetAI(new NoGoal());
2112 }
2113 if (IsActiveZone)
2114 {
2115 map.OnCardAddedToZone(t, x, z);
2116 if (isStarted && t.isThing && t.placeState == PlaceState.roaming && !ignoreSpawnAnime)
2117 {
2118 t.PlayAnimeLoot();
2119 }
2120 ignoreSpawnAnime = false;
2121 }
2122 if (chara != null && EClass.player != null && !chara.hasSpawned)
2123 {
2124 EClass.player.codex.AddSpawn(chara.id);
2125 chara.hasSpawned = true;
2126 }
2127 return t;
2128 }
2129
2130 public void RemoveCard(Card t)
2131 {
2132 if (IsActiveZone)
2133 {
2135 }
2136 t.parent = null;
2137 if (t.isChara)
2138 {
2139 t.Chara.currentZone = null;
2140 }
2141 if (t.isThing && !t.trait.IDActorEx.IsEmpty())
2142 {
2144 }
2145 if (t.renderer.hasActor)
2146 {
2148 }
2149 }
2150
2151 public T GetRandomSpot<T>() where T : Trait
2152 {
2153 return EClass._map.props.installed.traits.GetRandomThing<T>() as T;
2154 }
2155
2156 public bool TryAddThingInSpot<T>(Thing t, bool useContainer = true) where T : Trait
2157 {
2158 Thing randomThing = EClass._map.props.installed.traits.GetRandomThing<T>();
2159 if (randomThing == null)
2160 {
2162 return false;
2163 }
2164 if (useContainer && (!t.IsContainer || t.things.Count == 0))
2165 {
2166 List<Thing> list = new List<Thing>();
2167 foreach (Point item in randomThing.trait.ListPoints(null, onlyPassable: false))
2168 {
2169 foreach (Card item2 in item.ListCards())
2170 {
2171 if (item2.IsContainer && !(item2.trait is TraitDeliveryChest))
2172 {
2173 list.Add(item2.Thing);
2174 }
2175 }
2176 }
2177 if (TryAddThingInSharedContainer(t, list, add: true, msg: false, null, sharedOnly: false))
2178 {
2179 return true;
2180 }
2181 }
2182 AddCard(t, randomThing.trait.GetRandomPoint());
2183 return true;
2184 }
2185
2186 public List<Thing> TryListThingsInSpot<T>(Func<Thing, bool> func = null) where T : TraitSpot
2187 {
2188 List<T> list = new List<T>();
2189 List<Thing> list2 = new List<Thing>();
2190 foreach (Thing thing in EClass._map.things)
2191 {
2192 if (thing.IsInstalled && thing.trait is T)
2193 {
2194 list.Add(thing.trait as T);
2195 }
2196 }
2197 foreach (T item in list)
2198 {
2199 foreach (Point item2 in item.ListPoints(null, onlyPassable: false))
2200 {
2201 foreach (Thing thing2 in item2.Things)
2202 {
2203 if (!thing2.IsInstalled)
2204 {
2205 continue;
2206 }
2207 if (thing2.things.Count == 0)
2208 {
2209 if (IsValid(thing2))
2210 {
2211 list2.Add(thing2);
2212 }
2213 continue;
2214 }
2215 foreach (Thing item3 in thing2.things.List((Thing _t) => IsValid(_t)))
2216 {
2217 list2.Add(item3);
2218 }
2219 }
2220 }
2221 }
2222 return list2;
2223 bool IsValid(Thing t)
2224 {
2225 if (func != null && !func(t))
2226 {
2227 return false;
2228 }
2229 return true;
2230 }
2231 }
2232
2233 public bool TryAddThingInSharedContainer(Thing t, List<Thing> containers = null, bool add = true, bool msg = false, Chara chara = null, bool sharedOnly = true)
2234 {
2235 Thing dest = null;
2236 int priority = -1;
2237 ContainerFlag flag = t.category.GetRoot().id.ToEnum<ContainerFlag>();
2238 if (flag == ContainerFlag.none)
2239 {
2240 flag = ContainerFlag.other;
2241 }
2242 if (containers == null)
2243 {
2244 containers = EClass._map.props.installed.containers;
2245 }
2246 if (SearchDest() != null)
2247 {
2248 return true;
2249 }
2250 if (dest == null)
2251 {
2252 return false;
2253 }
2254 if (add)
2255 {
2256 if (msg)
2257 {
2258 chara.Say("putSharedItem", chara, t, dest.GetName(NameStyle.Full));
2259 }
2260 dest.AddThing(t);
2261 }
2262 return true;
2263 Thing SearchDest()
2264 {
2265 foreach (Thing container in containers)
2266 {
2267 Thing thing = container;
2268 if (thing.trait is TraitShippingChest)
2269 {
2271 }
2272 if ((!sharedOnly || thing.IsSharedContainer) && thing.c_lockLv <= 0 && (thing.things.Count < thing.things.MaxCapacity || thing.things.CanStack(t) != t))
2273 {
2274 Window.SaveData windowSaveData = thing.GetWindowSaveData();
2275 if (windowSaveData != null)
2276 {
2277 if (windowSaveData.priority <= priority || (windowSaveData.noRotten && t.IsDecayed) || (windowSaveData.onlyRottable && t.trait.Decay == 0))
2278 {
2279 continue;
2280 }
2282 if (windowSaveData.userFilter)
2283 {
2284 filterResult = windowSaveData.IsFilterPass(t.GetName(NameStyle.Full, 1));
2285 if (filterResult == Window.SaveData.FilterResult.Block)
2286 {
2287 continue;
2288 }
2289 }
2290 if (filterResult != Window.SaveData.FilterResult.PassWithoutFurtherTest)
2291 {
2292 if (windowSaveData.advDistribution)
2293 {
2294 bool flag2 = false;
2295 foreach (int cat in windowSaveData.cats)
2296 {
2297 if (t.category.uid == cat)
2298 {
2299 flag2 = true;
2300 break;
2301 }
2302 }
2303 if (!flag2)
2304 {
2305 continue;
2306 }
2307 }
2308 else if (windowSaveData.flag.HasFlag(flag))
2309 {
2310 continue;
2311 }
2312 }
2313 priority = windowSaveData.priority;
2314 }
2315 else
2316 {
2317 if (priority != -1)
2318 {
2319 continue;
2320 }
2321 priority = 0;
2322 }
2323 dest = thing;
2324 }
2325 }
2326 return null;
2327 }
2328 }
2329
2330 public bool TryAddThing(Thing target, Point p, bool destroyIfFail = false)
2331 {
2332 int num = 0;
2333 if (p.cell.detail != null)
2334 {
2335 foreach (Thing thing in p.cell.detail.things)
2336 {
2337 if (thing.placeState == PlaceState.roaming)
2338 {
2339 if (target.TryStackTo(thing))
2340 {
2341 return true;
2342 }
2343 num++;
2344 }
2345 }
2346 }
2347 if (num == 0 || !destroyIfFail)
2348 {
2349 EClass._zone.AddCard(target, p);
2350 return true;
2351 }
2352 target.Destroy();
2353 return false;
2354 }
2355
2356 public Thing TryGetThingFromSharedContainer(Func<Thing, bool> func)
2357 {
2358 foreach (Thing container in EClass._map.props.installed.containers)
2359 {
2360 if (container.IsSharedContainer)
2361 {
2362 Thing thing = container.things.Find(func);
2363 if (thing != null)
2364 {
2365 return thing;
2366 }
2367 }
2368 }
2369 return null;
2370 }
2371
2372 public Thing TryGetRestock<T>(string idCat) where T : TraitSpot
2373 {
2374 List<T> list = new List<T>();
2375 foreach (Thing thing2 in EClass._map.things)
2376 {
2377 if (thing2.IsInstalled && thing2.trait is T)
2378 {
2379 list.Add(thing2.trait as T);
2380 }
2381 }
2382 foreach (T item in list)
2383 {
2384 foreach (Point item2 in item.ListPoints(null, onlyPassable: false))
2385 {
2386 foreach (Thing thing3 in item2.Things)
2387 {
2388 if (!thing3.IsInstalled || thing3.isSale)
2389 {
2390 continue;
2391 }
2392 if (thing3.things.Count == 0)
2393 {
2394 if (IsValid(thing3, insideContainer: false))
2395 {
2396 return thing3;
2397 }
2398 continue;
2399 }
2400 Thing thing = thing3.things.Find((Thing _t) => IsValid(_t, insideContainer: true));
2401 if (thing != null)
2402 {
2403 return thing;
2404 }
2405 }
2406 }
2407 }
2408 return null;
2409 bool IsValid(Thing t, bool insideContainer)
2410 {
2411 if (t.category.id != idCat || !TraitSalesTag.CanTagSale(t, insideContainer))
2412 {
2413 return false;
2414 }
2415 return true;
2416 }
2417 }
2418
2420 {
2421 string text = IdProfile;
2422 if (text.IsEmpty())
2423 {
2424 Region region = parent as Region;
2425 if (base.lv != 0)
2426 {
2427 text = ((base.lv < 0) ? "Underground" : "Sky");
2428 }
2429 else if (region != null)
2430 {
2432 text = EClass.scene.elomapActor.elomap.GetTileInfo(base.x, base.y).idZoneProfile;
2433 if (bp != null)
2434 {
2435 name = Lang.GetList("zone_" + text.Split('/')[1]).RandomItem();
2436 bp.surrounding = new EloMap.TileInfo[3, 3];
2437 for (int i = 0; i < 3; i++)
2438 {
2439 for (int j = 0; j < 3; j++)
2440 {
2441 bp.surrounding[j, i] = EClass.scene.elomapActor.elomap.GetTileInfo(base.x - 1 + j, base.y - 1 + i);
2442 }
2443 }
2444 if (text == "Random/R_Shore")
2445 {
2446 base.isBeach = true;
2447 }
2448 }
2449 }
2450 else
2451 {
2452 text = "Random";
2453 }
2454 idProfile = text;
2455 }
2456 return ZoneProfile.Load(text);
2457 }
2458
2459 public void CreateBP()
2460 {
2461 bp = new ZoneBlueprint();
2462 bp.Create();
2463 bp.genSetting.seed = base.Seed;
2464 OnCreateBP();
2465 }
2466
2467 public virtual void OnCreateBP()
2468 {
2469 }
2470
2471 public void Generate()
2472 {
2473 base.isGenerated = true;
2474 if (bp == null)
2475 {
2476 CreateBP();
2477 }
2478 if (bp.map == null)
2479 {
2480 bp.GenerateMap(this);
2481 }
2482 map.SetZone(this);
2483 Zone_Field zone_Field = this as Zone_Field;
2484 bool flag = IdBiome == "Sand" || IdBiome == "Water" || IsUnderwater;
2485 if (flag)
2486 {
2487 int num = 1 + EClass.rnd((IdBiome == "Water") ? 3 : 2);
2488 for (int i = 0; i < num; i++)
2489 {
2490 Point randomSurface = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2491 if (!randomSurface.HasObj && !randomSurface.HasThing)
2492 {
2493 Thing t = ThingGen.Create("pearl_oyster", new string[3] { "wood_birch", "poplar", "coralwood" }.RandomItem(), ContentLv);
2494 EClass._zone.AddCard(t, randomSurface).Install();
2495 }
2496 }
2497 num = 4 + EClass.rnd(5);
2498 for (int j = 0; j < num; j++)
2499 {
2500 Point randomSurface2 = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2501 if (!randomSurface2.HasObj && !randomSurface2.HasThing && (IsUnderwater || randomSurface2.cell.IsTopWaterAndNoSnow || EClass.rnd(6) == 0))
2502 {
2503 EClass._zone.AddCard(ThingGen.Create("70", -1, ContentLv), randomSurface2);
2504 }
2505 }
2506 for (int k = 0; k < EClass.rnd(EClass.rnd(base.isBeach ? 5 : 3) + 1); k++)
2507 {
2508 Point randomSurface3 = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2509 if (!randomSurface3.HasObj)
2510 {
2511 EClass._zone.AddCard(ThingGen.Create("bottle_message"), randomSurface3);
2512 }
2513 }
2514 }
2515 if (IsUnderwater)
2516 {
2517 for (int l = 0; l < 30 + EClass.rnd(30); l++)
2518 {
2519 SpawnMob(null, SpawnSetting.Fish());
2520 }
2521 Crawler crawler = Crawler.Create("pasture");
2522 int num2 = (EClass.debug.enable ? 3 : EClass.rnd(EClass.rnd(EClass.rnd(EClass.rnd(5) + 1) + 1) + 1));
2523 bool flag2 = this is Zone_Field;
2524 Thing seed = null;
2525 if (IsNefia)
2526 {
2527 int num3 = Mathf.Min(EClass._zone.DangerLv, EClass.pc.Evalue(286) * 2 / 3);
2528 if (num3 > 0)
2529 {
2531 Rand.SetSeed(EClass._zone.uid * 10 + num3);
2532 TraitSeed.LevelSeed(seed, (seed.trait as TraitSeed).row, num3);
2533 Rand.SetSeed();
2534 seed.elements.SetBase(2, EClass.curve(seed.encLV, 50, 10, 80));
2535 }
2536 }
2537 crawler.CrawlUntil(EClass._map, () => EClass._map.GetRandomPoint(), num2 + (flag2 ? 4 : 0), delegate(Crawler.Result r)
2538 {
2539 int num6 = 137;
2540 foreach (Point point in r.points)
2541 {
2542 if (!point.cell.isModified && !point.HasThing && !point.HasBlock && !point.HasObj)
2543 {
2544 map.SetObj(point.x, point.z, num6);
2545 int idx = 3 + ((EClass.rnd(3) == 0) ? 1 : 0) + ((EClass.rnd(3) == 0) ? (-1) : 0) + ((EClass.rnd(3) == 0) ? (-1) : 0);
2546 point.growth.SetStage(idx);
2547 if (seed != null)
2548 {
2549 EClass._map.AddPlant(point, seed);
2550 }
2551 }
2552 }
2553 return false;
2554 });
2555 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)
2556 {
2557 int num5 = 136;
2558 foreach (Point point2 in r.points)
2559 {
2560 if (!point2.cell.isModified && !point2.HasThing && !point2.HasBlock && !point2.HasObj)
2561 {
2562 map.SetObj(point2.x, point2.z, num5, 1, EClass.rnd(4));
2563 }
2564 }
2565 return false;
2566 });
2567 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)
2568 {
2569 int idFloor = 121;
2570 foreach (Point point3 in r.points)
2571 {
2572 map.SetFloor(point3.x, point3.z, 97, idFloor, Mathf.Clamp(4 - r.startPos.Distance(point3) + EClass.rnd(3) - EClass.rnd(3), 0, 3));
2573 }
2574 return false;
2575 });
2576 }
2577 if (zone_Field != null)
2578 {
2579 if (EClass.rnd(3) == 0)
2580 {
2581 int num4 = EClass.rnd(2);
2582 for (int m = 0; m < num4; m++)
2583 {
2584 Point randomSurface4 = EClass._map.bounds.GetRandomSurface();
2585 if (!randomSurface4.HasObj && !randomSurface4.HasThing)
2586 {
2588 EClass._zone.AddCard(t2, randomSurface4).Install();
2589 }
2590 }
2591 }
2592 if (EClass.rnd(8) == 0)
2593 {
2594 SpawnAltar();
2595 }
2597 if (!flag && EClass.rnd(EClass.debug.enable ? 1 : 10) == 0)
2598 {
2599 Point randomSurface5 = EClass._map.bounds.GetRandomSurface();
2600 if (randomSurface5.IsValid)
2601 {
2602 EClass._zone.AddCard(CharaGen.Create("priest"), randomSurface5);
2603 }
2604 }
2605 if (base.Tile.isRoad)
2606 {
2607 for (int n = 0; n < EClass.rnd(4); n++)
2608 {
2609 EClass._zone.SpawnMob(map.GetCenterPos().GetRandomPointInRadius(2, 6, requireLos: false, allowChara: false), SpawnSetting.HomeGuest(EClass._zone.DangerLv));
2610 }
2611 }
2612 }
2613 map.plDay = CreatePlaylist(ref map._plDay, EClass.Sound.GetPlaylist(IDPlayList) ?? EClass.Sound.GetPlaylist("Day"));
2614 }
2615
2616 public void TrySpawnFollower()
2617 {
2618 bool flag = EClass.pc.HasCondition<ConDrawBacker>();
2619 if (!EClass.debug.enable && EClass.rnd(flag ? 3 : 20) != 0)
2620 {
2621 return;
2622 }
2623 Point randomSurface = EClass._map.bounds.GetRandomSurface();
2624 if (!randomSurface.IsValid)
2625 {
2626 return;
2627 }
2628 Chara c = CharaGen.Create("follower");
2629 EClass._zone.AddCard(c, randomSurface);
2630 (EClass._zone.AddThing("gallows", randomSurface).Install().trait as TraitShackle).Restrain(c);
2631 c.c_rescueState = RescueState.WaitingForRescue;
2632 if (EClass.rnd(flag ? 1 : 2) == 0 || EClass.debug.enable)
2633 {
2635 if (row != null)
2636 {
2637 c.ApplyBacker(row.id);
2638 }
2639 }
2640 Religion faith = EClass.game.religions.dictAll.Values.Where((Religion a) => a != c.faith).RandomItem();
2641 for (int i = 0; i < 3 + EClass.rnd(4); i++)
2642 {
2643 Chara chara = CharaGen.Create("fanatic");
2644 chara.SetFaith(faith);
2645 Point point = randomSurface.GetRandomPoint(4) ?? randomSurface.GetNearestPoint();
2646 EClass._zone.AddCard(chara, point);
2647 }
2648 }
2649
2650 public void SpawnAltar()
2651 {
2653 {
2654 if (r.points.Count <= 4)
2655 {
2656 return false;
2657 }
2658 map.poiMap.OccyupyPOI(r.points[0]);
2659 List<Point> points = r.points;
2660 Religion randomReligion = EClass.game.religions.GetRandomReligion();
2661 "altarPoint".lang(randomReligion.NameDomain.lang());
2662 Thing thing = ThingGen.Create("altar");
2663 (thing.trait as TraitAltar).SetDeity(randomReligion.id);
2664 Chara t = CharaGen.Create("twintail");
2665 EClass._zone.AddCard(t, points.RandomItem());
2666 for (int i = 0; i < 2 + EClass.rnd(2); i++)
2667 {
2668 Chara t2 = CharaGen.Create("twintail");
2669 EClass._zone.AddCard(t2, points.RandomItem());
2670 }
2671 if (points[0].Installed == null)
2672 {
2673 EClass._zone.AddCard(thing, points[0]).Install();
2674 }
2675 foreach (Point item in points)
2676 {
2677 if (item.x % 3 == 0 && item.z % 2 == 0 && item != points[0] && !item.Equals(points[0].Front) && item.Installed == null)
2678 {
2679 thing = ThingGen.Create("pillar1");
2680 EClass._zone.AddCard(thing, item).Install();
2681 }
2682 item.SetObj();
2683 item.SetFloor(3, 6);
2684 }
2685 return true;
2686 });
2687 }
2688
2689 public virtual void OnGenerateMap()
2690 {
2691 if (MakeEnemiesNeutral)
2692 {
2693 foreach (Chara chara in EClass._map.charas)
2694 {
2695 if (!chara.IsGlobal && chara.hostility < Hostility.Neutral && chara.OriginalHostility < Hostility.Friend)
2696 {
2697 Hostility hostility2 = (chara.c_originalHostility = Hostility.Neutral);
2698 chara.hostility = hostility2;
2699 }
2700 }
2701 }
2702 if (PrespawnRate != 0f && !IsSkyLevel)
2703 {
2704 for (int i = 0; i < (int)((float)MaxSpawn * PrespawnRate); i++)
2705 {
2706 SpawnMob();
2707 }
2708 }
2709 TryGenerateOre();
2710 TryGenerateBigDaddy();
2711 TryGenerateEvolved();
2712 TryGenerateShrine();
2713 }
2714
2715 public void TryGenerateOre()
2716 {
2717 if (OreChance <= 0f)
2718 {
2719 return;
2720 }
2721 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)
2722 {
2723 byte b = 18;
2724 string group = "ore";
2725 if (EClass.rnd(5) == 0)
2726 {
2727 b++;
2728 group = "gem";
2729 }
2730 SourceMaterial.Row randomMaterial = MATERIAL.GetRandomMaterial(DangerLv, group);
2731 foreach (Point point in r.points)
2732 {
2733 if (point.sourceBlock.ContainsTag("ore"))
2734 {
2735 map.SetObj(point.x, point.z, randomMaterial.id, b, 1, 0);
2736 }
2737 }
2738 return false;
2739 });
2740 }
2741
2742 public Chara TryGenerateEvolved(bool force = false, Point p = null)
2743 {
2744 float num = EvolvedChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f);
2745 if (!force && num <= EClass.rndf(1f))
2746 {
2747 return null;
2748 }
2749 Chara chara = SpawnMob(p, SpawnSetting.Evolved());
2750 for (int i = 0; i < 2 + EClass.rnd(2); i++)
2751 {
2752 chara.ability.AddRandom();
2753 }
2754 chara.AddThing(chara.MakeGene(DNA.Type.Default));
2755 if (EClass.rnd(2) == 0)
2756 {
2757 chara.AddThing(chara.MakeGene(DNA.Type.Superior));
2758 }
2759 return chara;
2760 }
2761
2763 {
2764 if (!(BigDaddyChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f) <= EClass.rndf(1f)))
2765 {
2766 Point spawnPos = GetSpawnPos(SpawnPosition.Random, 10000);
2767 List<string> list = new List<string> { "big_daddy", "big_daddy2" };
2768 list.Shuffle();
2769 Spawn(list[0], spawnPos);
2770 if (EClass.rnd(EClass.debug.enable ? 2 : 20) == 0)
2771 {
2772 Spawn(list[1], spawnPos.GetNearestPoint(allowBlock: false, allowChara: false));
2773 }
2774 Msg.Say("sign_bigdaddy");
2775 }
2776 void Spawn(string id, Point pos)
2777 {
2778 int num = (int)((long)DangerLv * 125L / 100);
2779 if (num >= 30)
2780 {
2782 {
2783 lv = num
2784 });
2785 }
2786 Chara chara = CharaGen.Create(id);
2787 if (EClass.pc.HasElement(1270))
2788 {
2789 chara.SetHostility(Hostility.Friend);
2790 }
2791 else if (EClass.pc.HasElement(1271))
2792 {
2793 chara.SetHostility(Hostility.Enemy);
2794 }
2795 EClass._zone.AddCard(chara, pos);
2796 }
2797 }
2798
2799 public void TryGenerateShrine()
2800 {
2801 float num = ShrineChance * (EClass.pc.HasElement(1270) ? 1.1f : 1f);
2802 for (int i = 0; i < 3; i++)
2803 {
2804 Rand.SetSeed(base.uid + i);
2805 if (num <= EClass.rndf(1f))
2806 {
2807 continue;
2808 }
2809 Point randomSpace = EClass._map.GetRandomSpace(3, 3);
2810 if (randomSpace == null)
2811 {
2812 continue;
2813 }
2814 randomSpace.x++;
2815 randomSpace.z++;
2816 if (randomSpace.HasThing || randomSpace.HasChara)
2817 {
2818 continue;
2819 }
2820 randomSpace.SetObj();
2823 if (EClass.rnd(EClass.debug.test ? 2 : 15) == 0)
2824 {
2825 EClass._zone.AddCard(ThingGen.Create("pedestal_power"), randomSpace).Install();
2826 EClass._zone.AddCard(ThingGen.Create(EClass.gamedata.godStatues.RandomItemWeighted((GodStatueData a) => a.chance).idThing, -1, DangerLv), randomSpace).Install();
2827 }
2828 else
2829 {
2830 EClass._zone.AddCard(ThingGen.Create("statue_power", -1, DangerLv), randomSpace).Install().SetRandomDir();
2831 }
2832 }
2833 Rand.SetSeed();
2834 }
2835
2836 public void ResetHostility()
2837 {
2838 foreach (Chara chara in EClass._map.charas)
2839 {
2840 if (!chara.source.hostility.IsEmpty() && chara.source.hostility.ToEnum<Hostility>() >= Hostility.Friend && !chara.IsPCFactionOrMinion)
2841 {
2842 chara.c_originalHostility = (Hostility)0;
2843 }
2844 chara.hostility = chara.OriginalHostility;
2845 if (chara.enemy != null && (chara.enemy.IsPCFaction || chara.IsPCFaction))
2846 {
2847 chara.SetEnemy();
2848 }
2849 }
2850 }
2851
2852 public virtual void OnGenerateRooms(BaseMapGen gen)
2853 {
2854 }
2855
2856 public Point GetSpawnPos(SpawnPosition type, int tries = 100)
2857 {
2858 Point point = new Point();
2859 for (int i = 0; i < tries; i++)
2860 {
2861 point = EClass._map.bounds.GetRandomSurface(centered: false, walkable: true, allowWater: true);
2862 if (!point.IsValid || point.cell.hasDoor || point.IsSync)
2863 {
2864 continue;
2865 }
2866 switch (type)
2867 {
2868 case SpawnPosition.Guest:
2869 {
2870 List<TraitSpotGuest> list = EClass._map.props.installed.traits.List<TraitSpotGuest>();
2871 if (list.Count > 0)
2872 {
2873 list.Shuffle();
2874 foreach (TraitSpotGuest item in list)
2875 {
2876 List<Point> list2 = item.ListPoints(null, onlyPassable: true, allowChara: false);
2877 if (list2.Count > 0)
2878 {
2879 return list2.RandomItem();
2880 }
2881 }
2882 }
2883 Room room = point.cell.room;
2884 if (room != null && room.data.accessType != 0)
2885 {
2886 continue;
2887 }
2888 break;
2889 }
2890 case SpawnPosition.Outside:
2891 if (point.cell.HasRoof || point.cell.light > 0)
2892 {
2893 continue;
2894 }
2895 break;
2896 }
2897 return point;
2898 }
2899 return null;
2900 }
2901
2902 public Chara SpawnMob(string id, Point pos = null)
2903 {
2904 return SpawnMob(pos, new SpawnSetting
2905 {
2906 id = id
2907 });
2908 }
2909
2910 public Chara SpawnMob(Point pos = null, SpawnSetting setting = null)
2911 {
2912 if (setting == null)
2913 {
2914 setting = SpawnSetting.Default;
2915 }
2916 if (pos == null)
2917 {
2918 pos = GetSpawnPos(setting.position, setting.tries);
2919 if (pos == null)
2920 {
2921 pos = GetSpawnPos(SpawnPosition.Random, setting.tries);
2922 if (pos == null)
2923 {
2924 return null;
2925 }
2926 }
2927 }
2928 BiomeProfile biome = pos.cell.biome;
2929 if (IsUnderwater && EClass.rnd(15) != 0)
2930 {
2931 biome = ((EClass.rnd(4) != 0) ? EClass.core.refs.biomes.Water : EClass.core.refs.biomes.Sand);
2932 }
2933 SpawnList spawnList = null;
2934 if (setting.idSpawnList != null)
2935 {
2936 spawnList = SpawnList.Get(setting.idSpawnList);
2937 }
2938 else if (EClass._zone is Zone_DungeonYeek && EClass.rnd(5) != 0)
2939 {
2940 spawnList = SpawnListChara.Get("dungeon_yeek", (SourceChara.Row r) => r.race == "yeek" && r.quality == 0);
2941 }
2942 else if (EClass._zone is Zone_DungeonDragon && EClass.rnd(5) != 0)
2943 {
2944 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);
2945 }
2946 else if (EClass._zone is Zone_DungeonMino && EClass.rnd(5) != 0)
2947 {
2948 spawnList = SpawnListChara.Get("dungeon_mino", (SourceChara.Row r) => r.race == "minotaur" && r.quality == 0);
2949 }
2950 else if (setting.hostility == SpawnHostility.Neutral || (setting.hostility != SpawnHostility.Enemy && Rand.Range(0f, 1f) < ChanceSpawnNeutral))
2951 {
2952 spawnList = SpawnList.Get(IsInstance ? "c_neutral_war" : "c_neutral");
2953 }
2954 else if (biome.spawn.chara.Count > 0)
2955 {
2956 string randomCharaId = biome.spawn.GetRandomCharaId();
2957 spawnList = ((!IsInstance) ? SpawnList.Get(randomCharaId) : SpawnList.Get("instance_" + randomCharaId, randomCharaId, new CharaFilter
2958 {
2959 ShouldPass = (SourceChara.Row s) => (!(s.hostility != "") || (!s.tag.Contains("cat") && !s.race_row.tag.Contains("cat"))) ? true : false
2960 }));
2961 }
2962 else
2963 {
2964 spawnList = SpawnList.Get(biome.name, "chara", new CharaFilter
2965 {
2966 ShouldPass = delegate(SourceChara.Row s)
2967 {
2968 if (s.hostility != "")
2969 {
2970 return false;
2971 }
2972 return s.biome == biome.name || s.biome.IsEmpty();
2973 }
2974 });
2975 }
2976 int num = ((setting.dangerLv == -1) ? DangerLv : setting.dangerLv);
2977 CardBlueprint cardBlueprint = new CardBlueprint
2978 {
2979 rarity = Rarity.Normal,
2980 idEle = setting.idEle
2981 };
2982 int num2 = ((setting.filterLv == -1) ? num : setting.filterLv);
2983 if (ScaleType == ZoneScaleType.Void)
2984 {
2985 num2 = ((num - 1) % 50 + 5) * 150 / 100;
2986 if (num2 >= 20 && EClass.rnd(100) < num2)
2987 {
2988 num2 = num;
2989 }
2990 }
2991 CardRow cardRow = (setting.id.IsEmpty() ? spawnList.Select(num2, setting.levelRange) : EClass.sources.cards.map[setting.id]);
2992 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)
2993 {
2994 cardRow = EClass.sources.cards.map["santa"];
2996 }
2997 long num3 = ((setting.fixedLv == -1) ? cardRow.LV : setting.fixedLv);
2998 bool flag = setting.fixedLv != -1 || DangerLvBoost > 0;
2999 num3 += setting.addLv;
3000 if (ScaleType == ZoneScaleType.Void)
3001 {
3002 num3 = (50L + (long)cardRow.LV) * Mathf.Max(1, (num - 1) / 50);
3003 flag = true;
3004 }
3005 num3 += DangerLvBoost;
3006 if (setting.rarity == Rarity.Random && cardRow.quality == 0)
3007 {
3008 if (EClass.rnd(EClass.pc.HasElement(1271) ? 80 : 100) == 0)
3009 {
3010 cardBlueprint.rarity = Rarity.Legendary;
3011 num3 = num3 * 125 / 100;
3012 }
3013 }
3014 else
3015 {
3016 cardBlueprint.rarity = setting.rarity;
3017 }
3018 if (setting.isBoss)
3019 {
3020 num3 = num3 * 150 / 100;
3021 }
3022 if (setting.isEvolved)
3023 {
3024 num3 = num3 * 2 + 20;
3025 }
3026 if (num3 != cardRow.LV)
3027 {
3028 cardBlueprint.lv = (int)Mathf.Min(num3, 100000000f);
3029 }
3030 CardBlueprint.Set(cardBlueprint);
3031 Chara chara = CharaGen.Create(cardRow.id, num2);
3032 if (!flag)
3033 {
3034 chara.isScaled = false;
3035 }
3036 AddCard(chara, pos);
3037 if (setting.forcedHostility.HasValue)
3038 {
3039 Hostility c_originalHostility = (chara.hostility = setting.forcedHostility.Value);
3040 chara.c_originalHostility = c_originalHostility;
3041 }
3042 else
3043 {
3044 switch (chara.id)
3045 {
3046 case "unicorn":
3047 if (EClass.pc.HasElement(1216) && EClass.pc.Evalue(418) < 1)
3048 {
3049 chara.SetHostility(Hostility.Enemy);
3050 }
3051 break;
3052 case "santa":
3053 case "silverwolf":
3054 case "twintail":
3055 case "test17":
3056 if (EClass.pc.HasElement(1270))
3057 {
3058 chara.SetHostility(Hostility.Friend);
3059 }
3060 else if (EClass.pc.HasElement(1271))
3061 {
3062 chara.SetHostility(Hostility.Enemy);
3063 }
3064 break;
3065 }
3066 }
3067 if (setting.isBoss)
3068 {
3069 chara.c_bossType = BossType.Boss;
3070 }
3071 if (setting.isEvolved)
3072 {
3073 chara.c_bossType = BossType.Evolved;
3074 }
3075 if (DangerLv >= 20 && !IsPCFaction && !IsTown && EClass.rnd(200) == 0)
3076 {
3078 }
3079 return chara;
3080 }
3081
3082 public bool HasField(int idEle)
3083 {
3084 return fieldElements.Has(idEle);
3085 }
3086
3087 public void SetFieldEffect(int idEle, int a, int duration = 0)
3088 {
3089 fieldElements.SetBase(idEle, a, duration);
3090 }
3091
3092 public void RemoveFieldEffect(int idEle)
3093 {
3094 fieldElements.Remove(idEle);
3095 }
3096
3098 {
3099 dirtyElectricity = false;
3100 bool flag = GetSoilCost() > MaxSoil;
3101 base.electricity = elements.Value(2201) * 10 + BaseElectricity;
3102 foreach (Thing thing in EClass._map.things)
3103 {
3104 if (thing.IsInstalled && thing.trait.Electricity != 0 && (thing.isOn || thing.trait.Electricity > 0))
3105 {
3106 base.electricity += thing.trait.Electricity;
3107 }
3108 }
3109 if (!flag)
3110 {
3111 EClass._map.bounds.ForeachCell(delegate(Cell c)
3112 {
3113 if (c.sourceObj.id == 118 && c.growth.IsMature)
3114 {
3115 base.electricity += 20;
3116 }
3117 });
3118 }
3119 foreach (Thing thing2 in EClass._map.things)
3120 {
3121 if (thing2.IsInstalled)
3122 {
3123 thing2.trait.TryToggle();
3124 }
3125 }
3126 }
3127
3128 public int GetElectricity(bool cost = false)
3129 {
3130 bool flag = GetSoilCost() > MaxSoil;
3131 int sum = 0;
3132 foreach (Thing thing in EClass._map.things)
3133 {
3134 if (!thing.IsInstalled || thing.trait.Electricity == 0)
3135 {
3136 continue;
3137 }
3138 if (cost)
3139 {
3140 if (thing.trait.Electricity < 0)
3141 {
3142 sum += -thing.trait.Electricity;
3143 }
3144 }
3145 else if (thing.trait.Electricity > 0)
3146 {
3147 sum += thing.trait.Electricity;
3148 }
3149 }
3150 if (!cost)
3151 {
3152 sum += elements.Value(2201) * 10 + BaseElectricity;
3153 if (!flag)
3154 {
3155 EClass._map.bounds.ForeachCell(delegate(Cell c)
3156 {
3157 if (c.sourceObj.id == 118 && c.growth.IsMature)
3158 {
3159 sum += 20;
3160 }
3161 });
3162 }
3163 }
3164 return sum;
3165 }
3166
3167 public void SetBGM(List<int> ids, bool refresh = true, float fadeDuration = 0f)
3168 {
3169 map._plDay.Clear();
3170 if (ids.Count > 0)
3171 {
3172 foreach (int id in ids)
3173 {
3174 if (id != -1)
3175 {
3176 map._plDay.Add(id);
3177 }
3178 }
3179 }
3180 UnityEngine.Object.DestroyImmediate(map.plDay);
3181 map.plDay = null;
3182 RefreshPlaylist();
3183 if (!refresh)
3184 {
3185 return;
3186 }
3187 if (fadeDuration > 0f)
3188 {
3189 EClass.Sound.StopBGM(fadeDuration, playLastBGM: false, delegate
3190 {
3192 {
3193 RefreshBGM();
3194 }
3195 });
3196 }
3197 else
3198 {
3199 EClass.Sound.StopBGM();
3200 RefreshBGM();
3201 }
3202 }
3203
3204 public void SetBGM(int id = -1, bool refresh = true, float fadeDuration = 0f)
3205 {
3206 SetBGM(new List<int> { id }, refresh, fadeDuration);
3207 }
3208
3209 public void RefreshPlaylist()
3210 {
3211 if (map.plDay == null)
3212 {
3213 map.plDay = CreatePlaylist(ref map._plDay, EClass.Sound.GetPlaylist(IDPlayList));
3214 }
3215 }
3216
3217 public void ResetPlaylist()
3218 {
3219 map._plDay.Clear();
3220 UnityEngine.Object.DestroyImmediate(map.plDay);
3221 map.plDay = null;
3222 RefreshPlaylist();
3223 }
3224
3225 public void RefreshBGM()
3226 {
3228 {
3229 return;
3230 }
3231 RefreshPlaylist();
3232 Playlist playlist = map.plDay;
3233 foreach (ZoneEvent item in events.list)
3234 {
3235 if (item.playlist != null)
3236 {
3237 playlist = item.playlist;
3238 }
3239 }
3240 if (IDPlaylistOverwrite != null)
3241 {
3242 playlist = EClass.Sound.GetPlaylist(IDPlaylistOverwrite);
3243 }
3245 {
3246 Room room = EClass.pc.pos.cell.room;
3247 if (room != null && room.lot != null && room.lot.idBGM != 0)
3248 {
3249 playlist = EClass.Sound.plLot;
3250 if (playlist.list[0].data?.id != room.lot.idBGM)
3251 {
3252 playlist.list[0].data = EClass.core.refs.dictBGM.TryGetValue(room.lot.idBGM);
3253 playlist.Reset();
3254 if (!LayerDrama.keepBGM)
3255 {
3256 EClass.Sound.StopBGM(1f);
3257 }
3258 }
3259 }
3260 }
3262 EClass.Sound.SwitchPlaylist(playlist, !LayerDrama.keepBGM);
3263 }
3264
3265 public Playlist CreatePlaylist(ref List<int> list, Playlist mold = null)
3266 {
3267 return ModUtil.CreatePlaylist(ref list, mold);
3268 }
3269
3270 public Chara FindChara(string id)
3271 {
3272 return map.charas.Find((Chara c) => c.id == id);
3273 }
3274
3275 public Chara FindChara(int uid)
3276 {
3277 return map.charas.Find((Chara c) => c.uid == uid);
3278 }
3279
3280 public Chara FindDeadChara(string id)
3281 {
3282 return map.deadCharas.Find((Chara c) => c.id == id);
3283 }
3284
3285 public int GetDeepestLv()
3286 {
3287 int max = base.lv;
3288 return GetDeepestLv(ref max);
3289 }
3290
3291 public int GetDeepestLv(ref int max)
3292 {
3293 if (Mathf.Abs(base.lv) > Mathf.Abs(max))
3294 {
3295 max = base.lv;
3296 }
3297 foreach (Spatial child in children)
3298 {
3299 (child as Zone).GetDeepestLv(ref max);
3300 }
3301 return max;
3302 }
3303
3304 public List<Element> ListLandFeats()
3305 {
3306 if (landFeats == null)
3307 {
3308 landFeats = new List<int>();
3310 string[] listBase = IDBaseLandFeat.Split(',');
3311 string[] array = listBase;
3312 foreach (string text in array)
3313 {
3314 if (!text.IsEmpty())
3315 {
3316 landFeats.Add(EClass.sources.elements.alias[text].id);
3317 }
3318 }
3319 if (listBase.Length == 1)
3320 {
3321 List<SourceElement.Row> list = EClass.sources.elements.rows.Where(delegate(SourceElement.Row e)
3322 {
3323 if (e.category != "landfeat" || e.chance == 0)
3324 {
3325 return false;
3326 }
3327 bool flag = true;
3328 string[] tag = e.tag;
3329 foreach (string text2 in tag)
3330 {
3331 if (text2.StartsWith("bf"))
3332 {
3333 flag = false;
3334 if (listBase[0] == text2)
3335 {
3336 flag = true;
3337 break;
3338 }
3339 }
3340 }
3341 return flag ? true : false;
3342 }).ToList();
3343 SourceElement.Row row = list.RandomItemWeighted((SourceElement.Row e) => e.chance);
3344 landFeats.Add(row.id);
3345 list.Remove(row);
3346 row = list.RandomItemWeighted((SourceElement.Row e) => e.chance);
3347 landFeats.Add(row.id);
3348 }
3349 Rand.SetSeed();
3350 }
3351 List<Element> list2 = new List<Element>();
3352 foreach (int landFeat in landFeats)
3353 {
3354 list2.Add(Element.Create(landFeat, 1));
3355 }
3356 return list2;
3357 }
3358
3359 public ZoneExportData Import(string path)
3360 {
3361 ZipFile zipFile = ZipFile.Read(path);
3362 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3363 zipFile.ExtractAll(pathTemp);
3364 zipFile.Dispose();
3365 return IO.LoadFile<ZoneExportData>(pathTemp + "export") ?? new ZoneExportData();
3366 }
3367
3368 public void Export(string path, PartialMap partial = null, bool usermap = false)
3369 {
3370 if (subset != null)
3371 {
3372 SE.Beep();
3373 return;
3374 }
3375 try
3376 {
3377 ZoneExportData zoneExportData = new ZoneExportData
3378 {
3379 name = name,
3380 usermap = usermap
3381 };
3382 IO.CreateTempDirectory();
3383 if (!map.config.retainDecal)
3384 {
3385 map.ClearRainAndDecal();
3386 }
3387 map.Save(IO.TempPath + "/", zoneExportData, partial);
3388 map.ExportMetaData(IO.TempPath + "/", Path.GetFileNameWithoutExtension(path), partial);
3389 if (partial == null)
3390 {
3391 IO.CopyDir(base.pathSave + "Texture Replace", IO.TempPath + "/Texture Replace");
3392 }
3393 IO.SaveFile(IO.TempPath + "/export", zoneExportData, compress: true);
3394 using (ZipFile zipFile = new ZipFile())
3395 {
3396 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
3397 zipFile.AddDirectory(IO.TempPath);
3398 zipFile.Save(path);
3399 zipFile.Dispose();
3400 }
3401 IO.DeleteTempDirectory();
3402 }
3403 catch (Exception ex)
3404 {
3405 EClass.ui.Say(ex.Message + ":" + path);
3406 }
3407 }
3408
3409 public void ExportDialog(string dir = null)
3410 {
3412 {
3413 string text = StandaloneFileBrowser.SaveFilePanel("Export Zone", dir ?? CorePath.ZoneSave, "new zone", "z");
3414 if (!string.IsNullOrEmpty(text))
3415 {
3416 Export(text);
3417 Msg.SayRaw("Exported Zone");
3418 }
3419 });
3420 }
3421
3422 public void ImportDialog(string dir = null)
3423 {
3425 {
3426 string[] array = StandaloneFileBrowser.OpenFilePanel("Import Zone", dir ?? CorePath.ZoneSave, "z", multiselect: false);
3427 if (array.Length != 0)
3428 {
3429 Zone_User zone_User = SpatialGen.Create("user", EClass.world.region, register: true) as Zone_User;
3430 zone_User.path = array[0];
3431 Thing thing = ThingGen.Create("teleporter");
3432 thing.c_uidZone = zone_User.uid;
3433 EClass._zone.AddCard(thing, EClass.pc.pos);
3434 }
3435 });
3436 }
3437
3438 public static bool IsImportValid(string path)
3439 {
3440 try
3441 {
3442 return Map.GetMetaData(path)?.IsValidVersion() ?? false;
3443 }
3444 catch (Exception ex)
3445 {
3446 EClass.ui.Say(ex.Message);
3447 return false;
3448 }
3449 }
3450
3451 public void Export()
3452 {
3454 string text = pathExport;
3455 IO.Copy(text, CorePath.ZoneSave + "Backup/");
3456 Export(text);
3457 Msg.Say("Exported Map:" + text);
3458 }
3459
3460 public void WriteNote(UINote n, Action<UINote> onWriteNote = null, IInspect.NoteMode mode = IInspect.NoteMode.Default, Recipe recipe = null)
3461 {
3462 }
3463
3464 public void OnInspect()
3465 {
3466 }
3467
3468 public int GetSortVal()
3469 {
3470 if (IsPCFaction)
3471 {
3472 return -10000000 + base.uid;
3473 }
3474 if (this is Zone_SubTown)
3475 {
3476 return -8000000 + base.uid;
3477 }
3478 if (this is Zone_Town)
3479 {
3480 return -9000000 + base.uid;
3481 }
3482 if (this is Zone_Civilized)
3483 {
3484 return -7000000 + base.uid;
3485 }
3486 if (this is Zone_RandomDungeon)
3487 {
3488 return 1000000 + base.uid;
3489 }
3490 return base.uid;
3491 }
3492
3493 public Chara AddRandomVisitor(bool guest = false)
3494 {
3495 Trait random = map.Installed.traits.GetTraitSet<TraitSpotExit>().GetRandom();
3496 if (random == null)
3497 {
3498 return null;
3499 }
3500 Point point = random.GetPoint();
3501 Chara chara = null;
3502 if (guest)
3503 {
3504 Zone z = EClass.world.FindZone("wilds");
3505 chara = EClass.game.cards.ListGlobalChara(z).RandomItem();
3506 if (chara != null)
3507 {
3508 AddCard(chara, point);
3509 Msg.Say("guestArrive", chara);
3510 chara.visitorState = VisitorState.Arrived;
3511 }
3512 }
3513 else
3514 {
3515 chara = CharaGen.CreateFromFilter("c_wilds");
3516 AddCard(chara, point);
3517 chara.goalListType = GoalListType.Enemy;
3518 }
3519 return chara;
3520 }
3521
3522 public void OnSimulateHour(VirtualDate date)
3523 {
3524 if (base.IsPlayerFaction)
3525 {
3526 branch.OnSimulateHour(date);
3527 }
3528 events.OnSimulateHour();
3529 if (date.IsRealTime)
3530 {
3531 foreach (Thing thing in EClass._map.things)
3532 {
3533 if (thing.IsInstalled)
3534 {
3535 thing.trait.TryToggle();
3536 }
3537 }
3539 }
3540 EClass._map.things.ForeachReverse(delegate(Thing t)
3541 {
3542 t.OnSimulateHour(date);
3543 });
3544 foreach (Thing sucker in Suckers)
3545 {
3546 sucker.Destroy();
3547 }
3548 Suckers.Clear();
3549 if (RespawnRate != 0f)
3550 {
3551 int num = 0;
3552 foreach (Chara chara in map.charas)
3553 {
3554 if (!chara.IsGlobal)
3555 {
3556 num++;
3557 }
3558 }
3559 if (num < MaxRespawn)
3560 {
3561 for (int i = 0; i < RespawnPerHour; i++)
3562 {
3563 SpawnMob();
3564 }
3565 }
3566 }
3567 if (!date.IsRealTime && EClass.rnd(24) == 0)
3568 {
3569 RainWater();
3570 }
3571 if (date.hour == 6)
3572 {
3573 GrowPlants(date);
3574 }
3575 }
3576
3577 public void OnSimulateDay(VirtualDate date)
3578 {
3579 if (base.IsPlayerFaction)
3580 {
3581 branch.OnSimulateDay(date);
3582 }
3583 }
3584
3586 {
3587 if (base.IsPlayerFaction)
3588 {
3589 branch.OnSimulateMonth(date);
3590 }
3591 if (date.IsRealTime)
3592 {
3594 }
3595 }
3596
3597 public void RainWater()
3598 {
3599 if (EClass._map.IsIndoor || !IsPCFaction)
3600 {
3601 return;
3602 }
3603 EClass._map.bounds.ForeachCell(delegate(Cell c)
3604 {
3605 if (c.IsFarmField && !c.HasRoof)
3606 {
3607 c.isWatered = true;
3608 }
3609 });
3610 }
3611
3612 public void GrowPlants(VirtualDate date)
3613 {
3614 bool num = (EClass.player.isAutoFarming = IsPCFaction && EClass.Branch.policies.IsActive(2707));
3615 int weedChance = 1;
3616 if (IsPCFaction && EClass.Branch.policies.IsActive(2703))
3617 {
3618 weedChance += (EClass.debug.enable ? 100000 : 20) + EClass.Branch.Evalue(2703) * 10;
3619 }
3620 if (date.sunMap == null)
3621 {
3622 date.BuildSunMap();
3623 }
3624 if (num)
3625 {
3626 HashSet<int> hashSet = new HashSet<int>();
3627 foreach (Thing thing in EClass._map.things)
3628 {
3629 if (!thing.IsInstalled || !(thing.trait is TraitSpotFarm traitSpotFarm))
3630 {
3631 continue;
3632 }
3633 foreach (Point item in traitSpotFarm.ListPoints(null, onlyPassable: false))
3634 {
3635 hashSet.Add(item.index);
3636 }
3637 }
3638 Perform(hashSet);
3639 EClass.player.isAutoFarming = false;
3640 Perform(hashSet);
3641 }
3642 else
3643 {
3644 Perform(null);
3645 }
3646 void Perform(HashSet<int> farmMap)
3647 {
3648 bool isWinter = date.IsWinter;
3649 EClass._map.bounds.ForeachCell(delegate(Cell c)
3650 {
3651 if (farmMap != null)
3652 {
3654 {
3655 if (!farmMap.Contains(c.index))
3656 {
3657 return;
3658 }
3659 }
3660 else if (farmMap.Contains(c.index))
3661 {
3662 return;
3663 }
3664 }
3665 if (c.decal != 0 && EClass.rnd(3) == 0)
3666 {
3667 c.decal = 0;
3668 }
3669 if (GrowPlant)
3670 {
3671 if (c.growth != null)
3672 {
3673 bool flag = false;
3674 if (!EClass.player.isAutoFarming && c.growth.HaltGrowth() && (c.IsFarmField || c.IsTopWater) && (!isWinter || !date.IsRealTime))
3675 {
3676 flag = true;
3677 }
3678 PlantData plantData = map.TryGetPlant(c);
3679 if (!flag && (plantData == null || plantData.fert >= 0))
3680 {
3681 c.TryGrow(date);
3682 }
3683 if (isWinter && plantData != null && c.growth != null && c.growth.NeedSunlight && plantData.fert >= 0 && (EClass.rnd(4) == 0 || c.growth.stage.idx == 0))
3684 {
3685 if (date.sunMap == null)
3686 {
3687 date.BuildSunMap();
3688 }
3689 if (!date.sunMap.Contains(c.index) && !c.growth.CanGrow(date))
3690 {
3691 c.growth.Perish();
3692 }
3693 }
3694 }
3695 else if (c.detail != null)
3696 {
3697 c.Things.ForeachReverse(delegate(Thing t)
3698 {
3699 if (t.IsInstalled && t.trait is TraitSeed && !t.isSale)
3700 {
3701 (t.trait as TraitSeed).TrySprout(force: false, sucker: false, date);
3702 }
3703 });
3704 }
3705 else if (EClass.rnd(20) == 0 && GrowWeed && c.CanGrowWeed && EClass.rnd(weedChance) == 0)
3706 {
3707 biome.Populate(c.GetPoint());
3708 if (c.growth != null)
3709 {
3710 c.growth.SetStage(0);
3711 }
3712 }
3713 }
3714 c.isWatered = false;
3715 });
3716 }
3717 }
3718
3719 public Zone GetZoneAt(int _x, int _y)
3720 {
3721 if (IsRegion)
3722 {
3723 foreach (Spatial child in children)
3724 {
3725 if (!(child is Zone_Field) && _x == child.x && _y == child.y)
3726 {
3727 return child as Zone;
3728 }
3729 }
3730 }
3731 foreach (Spatial child2 in children)
3732 {
3733 if (_x == child2.x && _y == child2.y)
3734 {
3735 return child2 as Zone;
3736 }
3737 }
3738 return null;
3739 }
3740
3741 public bool IsCrime(Chara c, Act act)
3742 {
3743 if (act.IsHostileAct && HasLaw && !IsPCFaction && c.IsPC)
3744 {
3745 return true;
3746 }
3747 return false;
3748 }
3749
3750 public void RefreshCriminal()
3751 {
3752 bool flag = EClass.player.IsCriminal && HasLaw && !AllowCriminal && !IsPCFaction;
3753 Hostility hostility = (flag ? Hostility.Neutral : Hostility.Friend);
3754 foreach (Chara chara in EClass._map.charas)
3755 {
3756 if (chara.trait is TraitGuard)
3757 {
3758 chara.hostility = hostility;
3759 if (!flag && chara.enemy != null && chara.enemy.IsPCParty)
3760 {
3761 chara.SetEnemy();
3762 }
3763 }
3764 }
3765 }
3766
3768 {
3769 if (base.lv != 0)
3770 {
3771 return;
3772 }
3773 dictCitizen.Clear();
3774 foreach (Chara item in map.charas.Concat(map.deadCharas))
3775 {
3776 if (item.trait.IsCitizen && !item.IsGlobal && !item.isSubsetCard)
3777 {
3778 dictCitizen[item.uid] = item.Name;
3779 }
3780 }
3781 }
3782
3783 public virtual void SetAlarm(bool enable)
3784 {
3785 base.isAlarmSet = enable;
3786 if (enable)
3787 {
3788 foreach (Chara chara in EClass._map.charas)
3789 {
3790 if (!chara.IsPCFactionOrMinion)
3791 {
3792 chara.SetHostility(Hostility.Enemy);
3793 }
3794 }
3795 Msg.Say("alarm");
3796 Msg.Say("alarm2");
3797 SE.Play("alarm");
3798 return;
3799 }
3800 foreach (Chara chara2 in EClass._map.charas)
3801 {
3802 if (!chara2.IsPCFactionOrMinion)
3803 {
3804 chara2.SetHostility(Hostility.Neutral);
3805 }
3806 }
3807 }
3808
3809 public void ModInfluence(int a)
3810 {
3811 base.influence += a;
3812 if (a > 0)
3813 {
3814 Msg.Say("gainInfluence", Name, a.ToString() ?? "");
3815 }
3816 Tutorial.Reserve("influence");
3817 }
3818
3819 public void ModDevelopment(int a)
3820 {
3821 base.development += a;
3822 if (a > 0)
3823 {
3824 Msg.Say("gainDevelopment", Name, a.ToString() ?? "");
3825 }
3826 }
3827
3828 public void UpdateQuests(bool force = false)
3829 {
3830 if (!IsPCFaction && (!(this is Zone_Town) || base.lv != 0))
3831 {
3832 return;
3833 }
3834 Debug.Log("Updating Quest:" + force);
3835 List<SourceQuest.Row> list = EClass.sources.quests.rows.Where((SourceQuest.Row a) => a.group == "random").ToList();
3836 int num = 0;
3837 foreach (Chara item in map.charas.Concat(map.deadCharas))
3838 {
3839 if (item.quest != null && !EClass.game.quests.list.Contains(item.quest))
3840 {
3841 if (item.quest.IsExpired || completedQuests.Contains(item.quest.uid) || force)
3842 {
3843 item.quest = null;
3844 }
3845 else
3846 {
3847 num++;
3848 }
3849 }
3850 }
3851 if (EClass._zone.dateQuest > EClass.world.date.GetRaw() && !force)
3852 {
3853 return;
3854 }
3855 EClass._zone.dateQuest = EClass.world.date.GetRaw() + 1440;
3856 int maxQuest = 3;
3857 Rand.UseSeed(base.uid + EClass.player.stats.days / 7 % 100, delegate
3858 {
3859 maxQuest = 4 + EClass.rnd(4);
3860 });
3861 completedQuests.Clear();
3862 List<Zone> list2 = Quest.ListDeliver();
3863 List<Tuple<string, int>> listTag = new List<Tuple<string, int>>();
3864 string[] array = EClass._zone.source.questTag;
3866 {
3867 array = new string[9] { "supply/8", "deliver/7", "food/8", "escort/4", "deliver/4", "monster/0", "war/0", "farm/0", "music/0" };
3868 }
3869 string[] array2 = array;
3870 for (int i = 0; i < array2.Length; i++)
3871 {
3872 string[] array3 = array2[i].Split('/');
3873 listTag.Add(new Tuple<string, int>(array3[0], array3[1].ToInt()));
3874 }
3875 for (int j = 0; j < map.charas.Count * 2; j++)
3876 {
3877 if (num > maxQuest)
3878 {
3879 break;
3880 }
3881 if (num > 15)
3882 {
3883 break;
3884 }
3885 Chara chara = map.charas.RandomItem();
3886 if (!chara.trait.CanGiveRandomQuest || chara.isSubsetCard || chara.homeZone != EClass._zone || chara.IsGuest() || chara.memberType == FactionMemberType.Livestock || (chara.quest != null && !force))
3887 {
3888 continue;
3889 }
3890 SourceQuest.Row row = list.RandomItemWeighted(delegate(SourceQuest.Row a)
3891 {
3892 int num2 = 1;
3893 foreach (Tuple<string, int> item2 in listTag)
3894 {
3895 if (a.tags.Contains(item2.Item1))
3896 {
3897 num2 = item2.Item2;
3898 break;
3899 }
3900 }
3901 if (!EClass._zone.IsPCFaction && a.tags.Contains("bulk"))
3902 {
3903 num2 = 0;
3904 }
3905 return a.chance * num2;
3906 });
3907 if ((!row.tags.Contains("needDestZone") || list2.Count >= 2) && (row.minFame <= 0 || row.minFame < EClass.player.fame || EClass.debug.enable))
3908 {
3909 Quest.Create(row.id, null, chara);
3910 num++;
3911 }
3912 }
3913 }
3914
3915 public List<Chara> ListMinions(Chara c)
3916 {
3917 List<Chara> list = new List<Chara>();
3918 foreach (Chara chara in EClass._map.charas)
3919 {
3920 if (chara.c_uidMaster == c.uid && chara.c_minionType == MinionType.Default)
3921 {
3922 list.Add(chara);
3923 }
3924 }
3925 return list;
3926 }
3927
3928 public int CountMinions(Chara c)
3929 {
3930 int num = 0;
3931 foreach (Chara chara in EClass._map.charas)
3932 {
3933 if (chara.c_uidMaster == c.uid && chara.c_minionType == MinionType.Default)
3934 {
3935 num++;
3936 }
3937 }
3938 return num;
3939 }
3940
3941 public int GetSoilCost()
3942 {
3943 int i = 0;
3944 EClass._map.bounds.ForeachCell(delegate(Cell c)
3945 {
3946 i += c.sourceObj.costSoil;
3947 });
3948 return i / 10;
3949 }
3950
3951 public void SpawnLostItems()
3952 {
3953 for (int i = 0; i < 2 + EClass.rnd(4); i++)
3954 {
3955 Point point = GetPos();
3956 if (point == null)
3957 {
3958 continue;
3959 }
3960 if (EClass.rnd(30) == 0)
3961 {
3962 Thing thing = ThingGen.Create("purse");
3963 thing.isLostProperty = true;
3964 thing.things.DestroyAll();
3965 int num2 = (thing.c_lockLv = EClass.rndHalf(Mathf.Min(base.development / 10 + 10, 50)));
3966 thing.Add("money", EClass.rndHalf(num2 * 60 + 1000));
3967 if (EClass.rnd(2) == 0)
3968 {
3969 thing.Add("plat", EClass.rnd(4));
3970 }
3971 else
3972 {
3973 thing.Add("medal", EClass.rnd(2));
3974 }
3975 EClass._zone.AddCard(thing, point);
3976 }
3977 else
3978 {
3980 }
3981 }
3982 static Point GetPos()
3983 {
3984 for (int j = 0; j < 10; j++)
3985 {
3986 Point randomPoint = EClass._zone.bounds.GetRandomPoint();
3987 if (!randomPoint.IsBlocked && !randomPoint.HasThing && !randomPoint.HasObj && !randomPoint.HasBlock)
3988 {
3989 return randomPoint;
3990 }
3991 }
3992 return null;
3993 }
3994 }
3995
3996 public void ApplyBackerPet(bool draw)
3997 {
3998 bool flag = this is Zone_Yowyn && base.lv == -1;
3999 IList<SourceBacker.Row> list = EClass.sources.backers.listPet.Copy();
4000 list.Shuffle();
4002 {
4003 list.ForeachReverse(delegate(SourceBacker.Row a)
4004 {
4005 if (EClass.player.doneBackers.Contains(a.id))
4006 {
4007 list.Remove(a);
4008 }
4009 });
4010 }
4011 foreach (Chara chara in EClass._map.charas)
4012 {
4013 if (chara.IsGlobal || chara.IsMinion)
4014 {
4015 continue;
4016 }
4017 if (chara.isBackerContent)
4018 {
4019 if (chara.sourceBacker.isStatic != 0)
4020 {
4021 continue;
4022 }
4023 if (chara.id != "follower")
4024 {
4025 chara.RemoveBacker();
4026 }
4027 }
4028 if ((flag && chara.race.id != "cat") || (!EClass.debug.enable && EClass.rnd((!flag) ? (draw ? 3 : 10) : (draw ? 1 : 2)) != 0))
4029 {
4030 continue;
4031 }
4032 foreach (SourceBacker.Row item in list)
4033 {
4034 if (item.chara == chara.id)
4035 {
4036 chara.ApplyBacker(item.id);
4037 list.Remove(item);
4038 break;
4039 }
4040 }
4041 }
4042 }
4043
4045 {
4046 if (fortuneRoll == null)
4047 {
4048 fortuneRoll = new FortuneRollData();
4049 fortuneRoll.seed = EClass._zone.uid * 100 + EClass.game.seed;
4050 }
4051 if (refresh || fortuneRoll.count == 0)
4052 {
4053 fortuneRoll.Refresh();
4054 }
4055 return fortuneRoll;
4056 }
4057}
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)
EditorTag
Definition: EditorTag.cs:2
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
ZoneFeatureType
ZoneScaleType
Definition: ZoneScaleType.cs:2
virtual void OnSimulatePosition()
Definition: AIAct.cs:604
void SimulateZone(int days)
Definition: AIAct.cs:592
void Add(Act a, string s="")
Definition: ActPlan.cs:11
Definition: ACT.cs:62
virtual bool IsHostileAct
Definition: ACT.cs:129
static AM_Adv Adv
Definition: ActionMode.cs:15
BaseArea.AccessType accessType
Definition: AreaData.cs:42
bool atrium
Definition: AreaData.cs:66
static int indexFollower
AreaData data
Definition: BaseArea.cs:29
PointList points
Definition: BaseArea.cs:26
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
bool IsPCFactionOrMinion
Definition: Card.cs:2342
bool IsDecayed
Definition: Card.cs:2357
virtual bool isThing
Definition: Card.cs:2133
virtual Chara Chara
Definition: Card.cs:2122
virtual void OnSimulateHour(VirtualDate date)
Definition: Card.cs:7048
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3921
string id
Definition: Card.cs:36
bool isNPCProperty
Definition: Card.cs:557
SourceBacker.Row sourceBacker
Definition: Card.cs:955
bool isSubsetCard
Definition: Card.cs:749
bool isRestrained
Definition: Card.cs:569
SourceMaterial.Row material
Definition: Card.cs:2103
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6617
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3210
int c_lockLv
Definition: Card.cs:991
Card AddCard(Card c)
Definition: Card.cs:3259
bool isSale
Definition: Card.cs:869
int c_uidMaster
Definition: Card.cs:1489
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3273
int hp
Definition: Card.cs:245
Rarity rarity
Definition: Card.cs:317
string Name
Definition: Card.cs:2191
ICardParent parent
Definition: Card.cs:56
bool hasSpawned
Definition: Card.cs:905
void AddEditorTag(EditorTag tag)
Definition: Card.cs:2738
PlaceState placeState
Definition: Card.cs:86
bool HasTag(CTAG tag)
Definition: Card.cs:2728
Point pos
Definition: Card.cs:60
void DecayNatural(int hour=1)
Definition: Card.cs:7057
int uid
Definition: Card.cs:125
virtual void HealHP(long a, HealSource origin=HealSource.None)
Definition: Card.cs:4181
Trait trait
Definition: Card.cs:54
Window.SaveData GetWindowSaveData()
Definition: Card.cs:2649
void RemoveBacker()
Definition: Card.cs:7508
int c_idBacker
Definition: Card.cs:1477
void PlayAnimeLoot()
Definition: Card.cs:6646
void Destroy()
Definition: Card.cs:5301
bool HasEditorTag(EditorTag tag)
Definition: Card.cs:2733
ThingContainer things
Definition: Card.cs:39
bool IsInstalled
Definition: Card.cs:2451
virtual bool isChara
Definition: Card.cs:2135
virtual Thing Thing
Definition: Card.cs:2110
int Evalue(int ele)
Definition: Card.cs:2704
bool isOn
Definition: Card.cs:545
bool TryStackTo(Thing to)
Definition: Card.cs:3571
Card Install()
Definition: Card.cs:3915
void ApplyBacker(int bid)
Definition: Card.cs:7472
void SetRandomDir()
Definition: Card.cs:6679
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:3250
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:6355
bool isBackerContent
Definition: Card.cs:952
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7295
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
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
bool isSeen
Definition: Cell.cs:290
SourceObj.Row sourceObj
Definition: Cell.cs:1084
bool HasFire
Definition: Cell.cs:684
int index
Definition: Cell.cs:122
bool hasDoor
Definition: Cell.cs:266
void AddRandom()
static Chara CreateFromFilter(string id, int lv=-1, int levelRange=-1)
Definition: CharaGen.cs:22
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
BaseCondition GetCondition(string idCon)
Definition: Chara.cs:10000
new TraitChara trait
Definition: Chara.cs:509
Hostility OriginalHostility
Definition: Chara.cs:475
AIAct ai
Definition: Chara.cs:206
void ValidateWorks()
Definition: Chara.cs:9751
ConSuspend conSuspend
Definition: Chara.cs:104
bool CanRevive()
Definition: Chara.cs:5404
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9780
Faction faction
Definition: Chara.cs:431
override bool IsPC
Definition: Chara.cs:630
Chara host
Definition: Chara.cs:33
AIAct SetNoGoal()
Definition: Chara.cs:9395
override bool IsGlobal
Definition: Chara.cs:628
override bool IsPCParty
Definition: Chara.cs:633
bool IsInCombat
Definition: Chara.cs:911
bool HasCondition(string alias)
Definition: Chara.cs:9945
AIAct SetAI(AIAct g)
Definition: Chara.cs:9400
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:9335
override int MaxHP
Definition: Chara.cs:726
Zone currentZone
Definition: Chara.cs:259
Goal GetGoalHobby()
Definition: Chara.cs:9348
SourceChara.Row source
Definition: Chara.cs:162
Stats mana
Definition: Chara.cs:1213
Stats stamina
Definition: Chara.cs:1205
void TryRestock(bool onCreate)
Definition: Chara.cs:4931
GlobalData global
Definition: Chara.cs:76
bool IsHomeMember()
Definition: Chara.cs:6926
Chara master
Definition: Chara.cs:88
void Revive(Point p=null, bool msg=false)
Definition: Chara.cs:5430
Zone homeZone
Definition: Chara.cs:271
bool IsGuest()
Definition: Chara.cs:6951
Thing MakeGene(DNA.Type? type=null)
Definition: Chara.cs:8628
Religion faith
Definition: Chara.cs:443
Chara enemy
Definition: Chara.cs:86
CharaAbility ability
Definition: Chara.cs:428
bool IsInActiveZone
Definition: Chara.cs:885
Chara FindMaster()
Definition: Chara.cs:2613
Chara SetEnemy(Chara c=null)
Definition: Chara.cs:6630
void SyncRide()
Definition: Chara.cs:4168
FactionBranch homeBranch
Definition: Chara.cs:1113
void ChooseNewGoal()
Definition: Chara.cs:9271
Hostility hostility
Definition: Chara.cs:295
bool IsHostile()
Definition: Chara.cs:6860
bool isDead
Definition: Chara.cs:393
void SetFaith(string id)
Definition: Chara.cs:1776
void Cure(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Definition: Chara.cs:10049
Chara SetHostility(Hostility h)
Definition: Chara.cs:1505
void MoveZone(string alias)
Definition: Chara.cs:3543
SourceRace.Row race
Definition: Chara.cs:468
void AddSpawn(string id)
Definition: CodexManager.cs:65
bool ignoreBackerDestoryFlag
Definition: CoreConfig.cs:570
void SetBGMInterval()
Definition: CoreConfig.cs:1022
bool test
Definition: CoreDebug.cs:185
bool revealMap
Definition: CoreDebug.cs:169
bool enable
Definition: CoreDebug.cs:301
bool godBuild
Definition: CoreDebug.cs:319
bool ignoreBuildRule
Definition: CoreDebug.cs:200
static string ZoneSave
Definition: CorePath.cs:192
UD_Biome dict
Definition: CoreRef.cs:149
BiomeProfile Water
Definition: CoreRef.cs:155
BiomeProfile Sand
Definition: CoreRef.cs:153
Crawler start
Definition: CoreRef.cs:217
Dictionary< int, BGMData > dictBGM
Definition: CoreRef.cs:388
Biomes biomes
Definition: CoreRef.cs:344
Crawlers crawlers
Definition: CoreRef.cs:346
CoreRef refs
Definition: Core.cs:51
TextureManager textures
Definition: Core.cs:45
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 GetElapsedHour(int rawDate)
Definition: Date.cs:358
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
int GetElapsedMins(int rawDate)
Definition: Date.cs:353
int GetRemainingHours(int rawDeadLine)
Definition: Date.cs:343
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
bool Has(int ele)
int Value(int ele)
Element SetBase(string alias, int v, int potential=0)
void Remove(int id)
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1130
void Initialize(EloMap _elomap)
Definition: EloMapActor.cs:28
EloMap elomap
Definition: EloMapActor.cs:7
string idZoneProfile
Definition: EloMap.cs:68
Definition: EloMap.cs:8
void SetZone(int gx, int gy, Zone z, bool updateMesh=false)
Definition: EloMap.cs:234
TileInfo GetTileInfo(int gx, int gy)
Definition: EloMap.cs:286
void OnAfterSimulate()
void OnSimulateMonth(VirtualDate date)
void OnActivateZone()
int Evalue(int ele)
void OnCreate(Zone zone)
void OnUnclaimZone()
void OnSimulateDay(VirtualDate date)
List< Chara > members
void SetOwner(Zone zone)
void OnSimulateHour(VirtualDate date)
PolicyManager policies
void OnUnloadMap()
string Log(string idLang, string ref1=null, string ref2=null, string ref3=null, string ref4=null)
ElementContainerZone elements
void AddMemeber(Chara c)
List< GodStatueData > godStatues
Definition: GameData.cs:9
Definition: GameIO.cs:11
BalanceSetting balance
Definition: GameSetting.cs:311
bool isLoading
Definition: Game.cs:242
ReligionManager religions
Definition: Game.cs:159
int countLoadedMaps
Definition: Game.cs:236
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: Guild.cs:2
void RefreshDevelopment()
Definition: Guild.cs:95
static Guild GetCurrentGuild()
Definition: Guild.cs:74
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
Point GetLeftPos(float rate=-1f)
Definition: MapBounds.cs:92
int Size
Definition: MapBounds.cs:20
void ForeachCell(Action< Cell > action)
Definition: MapBounds.cs:279
Point GetBottomPos(float rate=-1f)
Definition: MapBounds.cs:87
Point GetRandomSurface(int x, int z, int radius, bool walkable=true, bool allowWater=false)
Definition: MapBounds.cs:182
int Width
Definition: MapBounds.cs:26
int x
Definition: MapBounds.cs:8
Point GetTopPos(float rate=-1f)
Definition: MapBounds.cs:77
Point GetRandomSpace(int width, int height, int tries=100)
Definition: MapBounds.cs:246
Point GetCenterPos()
Definition: MapBounds.cs:52
int Height
Definition: MapBounds.cs:28
Point GetRightPos(float rate=-1f)
Definition: MapBounds.cs:82
Point GetRandomPoint()
Definition: MapBounds.cs:97
string idSceneProfile
Definition: MapConfig.cs:8
bool retainDecal
Definition: MapConfig.cs:44
string idBiome
Definition: MapConfig.cs:26
int embarkY
Definition: MapConfig.cs:86
int embarkX
Definition: MapConfig.cs:83
bool IsValidVersion()
Definition: MapMetaData.cs:31
void Apply()
Definition: MapSubset.cs:60
static MapSubset Load(string id)
Definition: MapSubset.cs:33
Definition: Map.cs:13
bool IsIndoor
Definition: Map.cs:131
new void ForeachCell(Action< Cell > action)
Definition: Map.cs:2405
void ResetEditorPos()
Definition: Map.cs:357
Cell GetCell(int index)
Definition: Map.cs:900
PlantData TryGetPlant(Point p)
Definition: Map.cs:1988
void ExportMetaData(string _path, string id, PartialMap partial=null)
Definition: Map.cs:732
Chara FindChara(string id)
Definition: Map.cs:2647
IEnumerable< Card > Cards
Definition: Map.cs:135
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
Definition: Map.cs:2261
void Save(string path, ZoneExportData export=null, PartialMap partial=null)
Definition: Map.cs:376
PropsInstalled Installed
Definition: Map.cs:123
void AddCardOnActivate(Card c)
Definition: Map.cs:795
void OnDeactivate()
Definition: Map.cs:205
void OnCardRemovedFromZone(Card t)
Definition: Map.cs:837
void SetZone(Zone _zone)
Definition: Map.cs:181
List< Thing > things
Definition: Map.cs:49
byte[] TryLoadFile(string path, string s, int size)
Definition: Map.cs:541
Dictionary< int, int > backerObjs
Definition: Map.cs:67
List< int > _plDay
Definition: Map.cs:55
Playlist plDay
Definition: Map.cs:77
List< Chara > deadCharas
Definition: Map.cs:46
PropsManager props
Definition: Map.cs:91
void SetFloor(int x, int z, int idMat=0, int idFloor=0)
Definition: Map.cs:970
int seed
Definition: Map.cs:19
PlantData AddPlant(Point pos, Thing seed)
Definition: Map.cs:1998
RoomManager rooms
Definition: Map.cs:31
void SetReference()
Definition: Map.cs:195
POIMap poiMap
Definition: Map.cs:97
void ClearRainAndDecal()
Definition: Map.cs:1572
void OnLoad()
Definition: Map.cs:720
void OnImport(ZoneExportData data)
Definition: Map.cs:726
List< Chara > serializedCharas
Definition: Map.cs:43
Cell[,] cells
Definition: Map.cs:85
static MapMetaData GetMetaData(string pathZip)
Definition: Map.cs:750
void OnCardAddedToZone(Card t, int x, int z)
Definition: Map.cs:818
Version version
Definition: Map.cs:28
MapConfig config
Definition: Map.cs:37
void Load(string path, bool import=false, PartialMap partial=null)
Definition: Map.cs:552
List< Chara > charas
Definition: Map.cs:81
void RevealAll(bool reveal=true)
Definition: Map.cs:918
void RefreshAllTiles()
Definition: Map.cs:2154
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
Definition: Map.cs:1581
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
Point GetCenter()
Definition: POIMap.cs:13
Cell GetCenterCell(int radius=1)
Definition: POIMap.cs:65
void OccyupyPOI(Point p, int radius=0)
Definition: POIMap.cs:99
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
override string ToString()
Definition: Point.cs:524
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
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
Point GetRandomPointInRadius(int minRadius, int maxRadius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=2000)
Definition: Point.cs:788
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
PropsRoaming roaming
Definition: PropsManager.cs:10
PropsStocked stocked
Definition: PropsManager.cs:6
TraitManager traits
Definition: Props.cs:18
List< Thing > Things
Definition: Props.cs:37
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 InitBytes(int a)
Definition: Rand.cs:13
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
List< Room > listRoom
Definition: RoomManager.cs:13
void AssignCharas()
Definition: RoomManager.cs:39
Definition: Room.cs:4
bool HasRoof
Definition: Room.cs:29
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)
static SceneProfile Load(string id)
Definition: SceneProfile.cs:18
void RebuildActorEx()
Definition: Scene.cs:993
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
SourceZoneAffix zoneAffixes
SourceBacker backers
SourceElement elements
SourceQuest quests
string[] tags
Definition: SourceQuest.cs:23
static Spatial Create(string id, Spatial parent, bool register, int x=-99999, int y=-99999, int icon=0)
Definition: SpatialGen.cs:16
void Remove(Spatial s)
Zone Find(string id)
int mapX
Definition: Spatial.cs:460
int lv
Definition: Spatial.cs:142
void SetInt(int id, int value=0)
Definition: Spatial.cs:580
bool isRandomSite
Definition: Spatial.cs:334
virtual bool IsSnowZone
Definition: Spatial.cs:542
int uid
Definition: Spatial.cs:70
Spatial parent
Definition: Spatial.cs:10
string idCurrentSubset
Definition: Spatial.cs:28
virtual int DangerLvFix
Definition: Spatial.cs:487
virtual bool IsRegion
Definition: Spatial.cs:515
string name
Definition: Spatial.cs:19
virtual string Name
Definition: Spatial.cs:509
virtual int DangerLvBoost
Definition: Spatial.cs:489
int dateQuest
Definition: Spatial.cs:286
virtual void Destroy()
Definition: Spatial.cs:690
SourceZone.Row source
Definition: Spatial.cs:453
bool destryoed
Definition: Spatial.cs:45
virtual void SetMainFaction(Faction f)
Definition: Spatial.cs:646
int idPrefix
Definition: Spatial.cs:130
void Register()
Definition: Spatial.cs:630
bool isImported
Definition: Spatial.cs:47
bool isConquered
Definition: Spatial.cs:382
string idProfile
Definition: Spatial.cs:25
int y
Definition: Spatial.cs:106
virtual Point RegionPos
Definition: Spatial.cs:560
Zone FindDeepestZone()
Definition: Spatial.cs:715
int mapY
Definition: Spatial.cs:472
int x
Definition: Spatial.cs:94
List< Spatial > children
Definition: Spatial.cs:37
Zone FindZone(int lv)
Definition: Spatial.cs:728
string idHat
Definition: Spatial.cs:31
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
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
void ApplyLocalReplace(string path)
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
void DestroyAll(Func< Thing, bool > funcExclude=null)
Thing Find(int uid)
Thing CanStack(Thing target, int destInvX=-1, int destInvY=-1)
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
override string GetName(NameStyle style, int _num=-1)
Definition: Thing.cs:532
bool IsSharedContainer
Definition: Thing.cs:110
virtual bool CanGiveRandomQuest
Definition: TraitChara.cs:119
virtual bool CanAutoRevive
Definition: TraitChara.cs:21
TraitSet GetTraitSet(Type t)
Definition: TraitManager.cs:94
virtual bool IsFor(Zone z)
static bool CanTagSale(Card t, bool insideContainer=false)
Definition: TraitSalesTag.cs:9
static Thing MakeSeed(string idSource)
Definition: TraitSeed.cs:105
static void LevelSeed(Thing t, SourceObj.Row obj, int num)
Definition: TraitSeed.cs:184
Definition: Trait.cs:7
virtual string IDActorEx
Definition: Trait.cs:187
virtual void TryToggle()
Definition: Trait.cs:1327
Point GetRandomPoint(Func< Point, bool > func=null, Chara accessChara=null)
Definition: Trait.cs:846
virtual ShopType ShopType
Definition: Trait.cs:532
string GetParam(int i, string def=null)
Definition: Trait.cs:587
Point GetPoint()
Definition: Trait.cs:841
virtual int Electricity
Definition: Trait.cs:119
virtual List< Point > ListPoints(Point center=null, bool onlyPassable=true, bool allowChara=true)
Definition: Trait.cs:864
virtual int Decay
Definition: Trait.cs:123
static void Reserve(string idStep, Action onBeforePlay=null)
Definition: Tutorial.cs:55
Definition: UINote.cs:6
bool IsRealTime
Definition: VirtualDate.cs:7
void SimulateHour()
Definition: VirtualDate.cs:66
void BuildSunMap()
Definition: VirtualDate.cs:54
HashSet< int > sunMap
Definition: VirtualDate.cs:9
bool IsRaining
Definition: Weather.cs:117
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
Weather weather
Definition: World.cs:12
void GenerateMap(Zone zone)
EloMap.TileInfo[,] surrounding
List< ZoneEvent > list
List< ZonePreEnterEvent > listPreEnter
void OnLoad(Zone _zone)
virtual void OnGenerateMap()
Definition: ZoneInstance.cs:32
virtual bool ShowEnemyOnMinimap
Definition: ZoneInstance.cs:30
virtual void Execute()
static ZoneProfile Load(string id)
Definition: ZoneProfile.cs:73
EnterState state
Definition: Zone.cs:12
virtual string GetNewZoneID(int level)
Definition: Zone.cs:592
string ZoneFullName
Definition: Zone.cs:85
string TextDangerLv
Definition: Zone.cs:435
Vector3 InspectPosition
Definition: Zone.cs:517
void OnChildNumChange(Card c)
Definition: Zone.cs:2037
int GetSortVal()
Definition: Zone.cs:3468
virtual bool CanDigUnderground
Definition: Zone.cs:277
bool isSimulating
Definition: Zone.cs:75
virtual int BaseElectricity
Definition: Zone.cs:497
virtual string IDPlayList
Definition: Zone.cs:145
Dictionary< int, string > dictCitizen
Definition: Zone.cs:52
override string ToString()
Definition: Zone.cs:597
List< Chara > ListMinions(Chara c)
Definition: Zone.cs:3915
void RefreshElectricity()
Definition: Zone.cs:3097
ZoneExportData Import(string path)
Definition: Zone.cs:3359
override int ContentLv
Definition: Zone.cs:100
virtual string IDBaseLandFeat
Definition: Zone.cs:151
virtual bool LockExit
Definition: Zone.cs:279
static string string int zoneLv ParseZoneFullName(string zoneFullName)
Definition: Zone.cs:552
void Generate()
Definition: Zone.cs:2471
virtual string GetDungenID()
Definition: Zone.cs:582
void Revive()
Definition: Zone.cs:1199
virtual bool BlockBorderExit
Definition: Zone.cs:173
void RefreshDeathSentense()
Definition: Zone.cs:1188
ZoneEventManager events
Definition: Zone.cs:40
void Simulate()
Definition: Zone.cs:1285
BiomeProfile _biome
Definition: Zone.cs:79
ZoneProfile GetProfile()
Definition: Zone.cs:2419
static string forceSubset
Definition: Zone.cs:27
virtual float PrespawnRate
Definition: Zone.cs:331
virtual int MaxSpawn
Definition: Zone.cs:317
FortuneRollData GetOrCreateFortuneRollData(bool refresh=true)
Definition: Zone.cs:4044
void SpawnAltar()
Definition: Zone.cs:2650
virtual bool UseLight
Definition: Zone.cs:402
virtual bool RegenerateOnEnter
Definition: Zone.cs:269
Thing TryGetRestock< T >(string idCat)
Definition: Zone.cs:2372
int MinsSinceLastActive
Definition: Zone.cs:127
virtual void OnAfterSimulate()
Definition: Zone.cs:1277
static int okaerinko
Definition: Zone.cs:31
override void OnLoad()
Definition: Zone.cs:1987
virtual string idExport
Definition: Zone.cs:154
void OnSimulateDay(VirtualDate date)
Definition: Zone.cs:3577
virtual int StartLV
Definition: Zone.cs:413
virtual float OreChance
Definition: Zone.cs:323
Playlist CreatePlaylist(ref List< int > list, Playlist mold=null)
Definition: Zone.cs:3265
static bool IsImportValid(string path)
Definition: Zone.cs:3438
virtual bool IsNefia
Definition: Zone.cs:289
virtual string IDGenerator
Definition: Zone.cs:137
int CountMinions(Chara c)
Definition: Zone.cs:3928
bool CanDestroy()
Definition: Zone.cs:1895
virtual bool MakeTownProperties
Definition: Zone.cs:249
Thing TryGetThingFromSharedContainer(Func< Thing, bool > func)
Definition: Zone.cs:2356
void Activate()
Definition: Zone.cs:636
void WriteNote(UINote n, Action< UINote > onWriteNote=null, IInspect.NoteMode mode=IInspect.NoteMode.Default, Recipe recipe=null)
Definition: Zone.cs:3460
virtual void OnRegenerate()
Definition: Zone.cs:1233
bool isStarted
Definition: Zone.cs:73
virtual bool CountDeepestLevel
Definition: Zone.cs:231
virtual ZoneScaleType ScaleType
Definition: Zone.cs:415
virtual bool SetAlarmOnBreakLaw
Definition: Zone.cs:235
void OnKillGame()
Definition: Zone.cs:1800
virtual string pathExport
Definition: Zone.cs:129
void RefreshCriminal()
Definition: Zone.cs:3750
virtual void OnBeforeDeactivate()
Definition: Zone.cs:1261
MapSubset subset
Definition: Zone.cs:65
int tempDist
Definition: Zone.cs:77
virtual ZoneTransition.EnterState RegionEnterState
Definition: Zone.cs:177
virtual bool ShouldAutoRevive
Definition: Zone.cs:384
Zone GetTopZone()
Definition: Zone.cs:2046
BiomeProfile biome
Definition: Zone.cs:131
HashSet< int > completedQuests
Definition: Zone.cs:37
virtual bool IsSkyLevel
Definition: Zone.cs:271
bool IsPCFactionOrTent
Definition: Zone.cs:480
virtual bool DisableRooms
Definition: Zone.cs:123
Chara TryGenerateEvolved(bool force=false, Point p=null)
Definition: Zone.cs:2742
FactionBranch branch
Definition: Zone.cs:34
void ImportDialog(string dir=null)
Definition: Zone.cs:3422
virtual string IDSubset
Definition: Zone.cs:216
void ClaimZone(bool debug=false, Point pos=null)
Definition: Zone.cs:1825
Chara AddChara(string id, int x, int z)
Definition: Zone.cs:2070
Card AddThing(string id, int x, int z)
Definition: Zone.cs:2080
ZoneBlueprint bp
Definition: Zone.cs:67
int GetDeepestLv()
Definition: Zone.cs:3285
override void OnCreate()
Definition: Zone.cs:615
void RefreshBGM()
Definition: Zone.cs:3225
ElementContainerField fieldElements
Definition: Zone.cs:46
void Deactivate()
Definition: Zone.cs:1729
virtual bool ShouldScaleImportedChara(Chara c)
Definition: Zone.cs:587
ElementContainerZone elements
Definition: Zone.cs:43
virtual bool IsReturnLocation
Definition: Zone.cs:358
void RefreshPlaylist()
Definition: Zone.cs:3209
bool HasField(int idEle)
Definition: Zone.cs:3082
void AbandonZone()
Definition: Zone.cs:1879
Chara AddRandomVisitor(bool guest=false)
Definition: Zone.cs:3493
void ExportDialog(string dir=null)
Definition: Zone.cs:3409
virtual void OnBeforeSimulate()
Definition: Zone.cs:1269
int GetElectricity(bool cost=false)
Definition: Zone.cs:3128
virtual FlockController.SpawnType FlockType
Definition: Zone.cs:419
virtual bool GrowWeed
Definition: Zone.cs:353
void SpawnLostItems()
Definition: Zone.cs:3951
virtual bool HasLaw
Definition: Zone.cs:233
Chara SpawnMob(Point pos=null, SpawnSetting setting=null)
Definition: Zone.cs:2910
virtual bool CanUnlockExit
Definition: Zone.cs:281
int GetDeepestLv(ref int max)
Definition: Zone.cs:3291
virtual int RespawnPerHour
Definition: Zone.cs:347
Chara FindChara(int uid)
Definition: Zone.cs:3275
int Evalue(string alias)
Definition: Zone.cs:577
virtual int MaxSoil
Definition: Zone.cs:520
bool IsStartZone
Definition: Zone.cs:491
virtual float RespawnRate
Definition: Zone.cs:333
virtual bool IsUserZone
Definition: Zone.cs:275
Chara FindDeadChara(string id)
Definition: Zone.cs:3280
void ApplyBackerPet(bool draw)
Definition: Zone.cs:3996
bool CanEnterBuildModeAnywhere
Definition: Zone.cs:462
List< Thing > TryListThingsInSpot< T >(Func< Thing, bool > func=null)
Definition: Zone.cs:2186
Card AddCardSplinkle(Card t, Point center, int radius=4)
Definition: Zone.cs:2055
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:3167
override string NameSuffix
Definition: Zone.cs:422
virtual string IdProfile
Definition: Zone.cs:143
void TryGenerateShrine()
Definition: Zone.cs:2799
virtual string TextWidgetDate
Definition: Zone.cs:139
void AddGlobalCharasOnActivate()
Definition: Zone.cs:1648
void OnSimulateMonth(VirtualDate date)
Definition: Zone.cs:3585
virtual float RuinChance
Definition: Zone.cs:321
virtual bool AddPrefix
Definition: Zone.cs:287
virtual float ChanceSpawnNeutral
Definition: Zone.cs:349
virtual string IDSceneTemplate
Definition: Zone.cs:198
virtual int SightRadiusBonus
Definition: Zone.cs:135
virtual bool CanBeDeliverDestination
Definition: Zone.cs:229
MapBounds bounds
Definition: Zone.cs:49
static string zoneType
Definition: Zone.cs:552
bool IsInstance
Definition: Zone.cs:493
void ClearZones(Zone current=null)
Definition: Zone.cs:2015
Chara Boss
Definition: Zone.cs:88
bool TryAddThingInSharedContainer(Thing t, List< Thing > containers=null, bool add=true, bool msg=false, Chara chara=null, bool sharedOnly=true)
Definition: Zone.cs:2233
virtual bool IsFestival
Definition: Zone.cs:213
virtual void OnDeactivate()
Definition: Zone.cs:1265
void OnVisit()
Definition: Zone.cs:1134
virtual ActionMode DefaultActionMode
Definition: Zone.cs:171
virtual bool AllowInvest
Definition: Zone.cs:254
string InspectName
Definition: Zone.cs:513
virtual string IDHat
Definition: Zone.cs:149
virtual bool IsTown
Definition: Zone.cs:227
void OnInspect()
Definition: Zone.cs:3464
void TryGenerateOre()
Definition: Zone.cs:2715
virtual void OnActivate()
Definition: Zone.cs:1237
Card AddCard(Card t, int x, int z)
Definition: Zone.cs:2100
void OnSimulateHour(VirtualDate date)
Definition: Zone.cs:3522
override void _OnBeforeSave()
Definition: Zone.cs:1960
void RainWater()
Definition: Zone.cs:3597
Point InspectPoint
Definition: Zone.cs:515
override void OnAfterCreate()
Definition: Zone.cs:621
static List< Thing > Suckers
Definition: Zone.cs:83
Card AddThing(string id, Point p)
Definition: Zone.cs:2085
Zone FindOrCreateLevel(int destLv, string subId="")
Definition: Zone.cs:531
virtual int MaxLv
Definition: Zone.cs:283
override void Destroy()
Definition: Zone.cs:1996
virtual bool UseFog
Definition: Zone.cs:395
virtual bool GrowPlant
Definition: Zone.cs:351
virtual string IDAmbience
Definition: Zone.cs:182
Chara SpawnMob(string id, Point pos=null)
Definition: Zone.cs:2902
virtual string IDPlaylistOverwrite
Definition: Zone.cs:147
virtual string IdBiome
Definition: Zone.cs:133
bool dirtyElectricity
Definition: Zone.cs:71
void RemoveCard(Card t)
Definition: Zone.cs:2130
Point GetSpawnPos(SpawnPosition type, int tries=100)
Definition: Zone.cs:2856
bool TryAddThing(Thing target, Point p, bool destroyIfFail=false)
Definition: Zone.cs:2330
void GrowPlants(VirtualDate date)
Definition: Zone.cs:3612
Chara FindChara(string id)
Definition: Zone.cs:3270
void SetBGM(int id=-1, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:3204
virtual bool ShouldMakeExit
Definition: Zone.cs:370
void RefreshHat()
Definition: Zone.cs:1124
virtual bool AllowCriminal
Definition: Zone.cs:251
virtual bool AlwaysLowblock
Definition: Zone.cs:399
static CardRow sourceHat
Definition: Zone.cs:29
MapGenerator Generator
Definition: Zone.cs:141
virtual bool AllowNewZone
Definition: Zone.cs:265
bool ShowEnemyOnMinimap
Definition: Zone.cs:336
bool IsActiveZone
Definition: Zone.cs:499
void ModInfluence(int a)
Definition: Zone.cs:3809
int HourSinceLastActive
Definition: Zone.cs:125
virtual bool RestrictBuild
Definition: Zone.cs:294
virtual void OnGenerateRooms(BaseMapGen gen)
Definition: Zone.cs:2852
Point GetRandomVisitPos(Chara c)
Definition: Zone.cs:1626
void Export()
Definition: Zone.cs:3451
void UnloadMap()
Definition: Zone.cs:1811
virtual void OnGenerateMap()
Definition: Zone.cs:2689
static string string zoneId
Definition: Zone.cs:552
List< Element > ListLandFeats()
Definition: Zone.cs:3304
int fileVariation
Definition: Zone.cs:69
virtual bool PetFollow
Definition: Zone.cs:291
override int DangerLv
Definition: Zone.cs:112
static bool forceRegenerate
Definition: Zone.cs:25
Zone ParentZone
Definition: Zone.cs:169
virtual int MinLv
Definition: Zone.cs:285
bool IsPCFaction
Definition: Zone.cs:477
void ResetHostility()
Definition: Zone.cs:2836
virtual bool MakeEnemiesNeutral
Definition: Zone.cs:238
virtual bool IsUnderwater
Definition: Zone.cs:273
virtual void OnCreateBP()
Definition: Zone.cs:2467
void Export(string path, PartialMap partial=null, bool usermap=false)
Definition: Zone.cs:3368
void TrySpawnFollower()
Definition: Zone.cs:2616
virtual bool ShouldRegenerate
Definition: Zone.cs:381
void RemoveFieldEffect(int idEle)
Definition: Zone.cs:3092
virtual float BigDaddyChance
Definition: Zone.cs:325
string NameWithLevel
Definition: Zone.cs:433
void TryGenerateBigDaddy()
Definition: Zone.cs:2762
virtual float EvolvedChance
Definition: Zone.cs:327
static bool ignoreSpawnAnime
Definition: Zone.cs:81
string TextDeepestLv
Definition: Zone.cs:438
ICardParent GetRoot()
Definition: Zone.cs:2041
int GetSoilCost()
Definition: Zone.cs:3941
void CreateBP()
Definition: Zone.cs:2459
string pathTemp
Definition: Zone.cs:165
virtual void SetAlarm(bool enable)
Definition: Zone.cs:3783
virtual void OnAdvanceHour()
Definition: Zone.cs:1281
FortuneRollData fortuneRoll
Definition: Zone.cs:61
ZoneInstance instance
Definition: Zone.cs:55
void ModDevelopment(int a)
Definition: Zone.cs:3819
virtual bool WillAutoSave
Definition: Zone.cs:267
T GetRandomSpot< T >()
Definition: Zone.cs:2151
virtual bool IsExplorable
Definition: Zone.cs:355
virtual bool RevealRoom
Definition: Zone.cs:397
void UpdateQuests(bool force=false)
Definition: Zone.cs:3828
Region Region
Definition: Zone.cs:167
virtual bool KeepAllyDistance
Definition: Zone.cs:306
virtual bool HiddenInRegionMap
Definition: Zone.cs:417
bool IsLoaded
Definition: Zone.cs:495
bool IsCrime(Chara c, Act act)
Definition: Zone.cs:3741
bool CanEnterBuildMode
Definition: Zone.cs:450
void RefreshListCitizen()
Definition: Zone.cs:3767
Card AddCard(Card t)
Definition: Zone.cs:2095
Zone GetZoneAt(int _x, int _y)
Definition: Zone.cs:3719
void ResetPlaylist()
Definition: Zone.cs:3217
bool TryAddThingInSpot< T >(Thing t, bool useContainer=true)
Definition: Zone.cs:2156
List< int > landFeats
Definition: Zone.cs:58
Card AddCard(Card t, Point point)
Definition: Zone.cs:2090
string TextLevel(int _lv)
Definition: Zone.cs:602
void SetFieldEffect(int idEle, int a, int duration=0)
Definition: Zone.cs:3087
Chara AddChara(string id, Point p)
Definition: Zone.cs:2075
int Evalue(int ele)
Definition: Zone.cs:572
virtual ZoneFeatureType FeatureType
Definition: Zone.cs:179
virtual float ShrineChance
Definition: Zone.cs:329
Map map
Definition: Zone.cs:63
Point GetSpawnPos(Chara c, ZoneTransition.EnterState destState=ZoneTransition.EnterState.Auto)
Definition: Zone.cs:1445
int MaxRespawn
Definition: Zone.cs:319
virtual int ExpireDays
Definition: Zone.cs:175
virtual void OnVisitNewMapOrRegenerate()
Definition: Zone.cs:1273
bool CanInspect
Definition: Zone.cs:502
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