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