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