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