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