public void ExposeData() { Scribe_Collections.Look <GlobalTargetInfo>(ref this.targets, "targets", LookMode.GlobalTargetInfo, new object[0]); }
public void ExposeData() { Scribe_Collections.Look(ref reservedDestinations, "reservedDestinations", LookMode.Reference, LookMode.Deep, ref reservedDestinationsKeysWorkingList, ref reservedDestinationsValuesWorkingList); }
public void ExposeData() { Scribe_Values.Look <int>(ref this.loadID, "loadID", 0, false); Scribe_Collections.Look <LogEntry>(ref this.entries, "entries", LookMode.Deep, new object[0]); }
public void LoadGame() { if (maps.Any()) { Log.Error("Called LoadGame() but there already is a map. There should be 0 maps..."); } else { MemoryUtility.UnloadUnusedUnityAssets(); Current.ProgramState = ProgramState.MapInitializing; ExposeSmallComponents(); LongEventHandler.SetCurrentEventText("LoadingWorld".Translate()); if (!Scribe.EnterNode("world")) { Log.Error("Could not find world XML node."); } else { try { World = new World(); World.ExposeData(); } finally { Scribe.ExitNode(); } World.FinalizeInit(); LongEventHandler.SetCurrentEventText("LoadingMap".Translate()); Scribe_Collections.Look(ref maps, "maps", LookMode.Deep); if (maps.RemoveAll((Map x) => x == null) != 0) { Log.Warning("Some maps were null after loading."); } int value = -1; Scribe_Values.Look(ref value, "currentMapIndex", -1); if (value < 0 && maps.Any()) { Log.Error("Current map is null after loading but there are maps available. Setting current map to [0]."); value = 0; } if (value >= maps.Count) { Log.Error("Current map index out of bounds after loading."); value = ((!maps.Any()) ? (-1) : 0); } currentMapIndex = sbyte.MinValue; CurrentMap = ((value < 0) ? null : maps[value]); LongEventHandler.SetCurrentEventText("InitializingGame".Translate()); Find.CameraDriver.Expose(); DeepProfiler.Start("FinalizeLoading"); Scribe.loader.FinalizeLoading(); DeepProfiler.End(); LongEventHandler.SetCurrentEventText("SpawningAllThings".Translate()); for (int i = 0; i < maps.Count; i++) { try { maps[i].FinalizeLoading(); } catch (Exception arg) { Log.Error("Error in Map.FinalizeLoading(): " + arg); } try { maps[i].Parent.FinalizeLoading(); } catch (Exception arg2) { Log.Error("Error in MapParent.FinalizeLoading(): " + arg2); } } FinalizeInit(); if (Prefs.PauseOnLoad) { LongEventHandler.ExecuteWhenFinished(delegate { Find.TickManager.DoSingleTick(); Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; }); } GameComponentUtility.LoadedGame(); } } }
public static void Look <T>(ref HashSet <T> valueHashSet, string label, LookMode lookMode = LookMode.Undefined) { Scribe_Collections.Look <T>(ref valueHashSet, false, label, lookMode); }
public void ExposeData() { Scribe_Collections.Look <LogEntry>(ref this.entries, "entries", LookMode.Deep, new object[0]); }
public void ExposeData() { Scribe_Values.Look <int>(ref this.uniqueID, "uniqueID", -1, false); Scribe_Deep.Look <MapInfo>(ref this.info, "mapInfo", new object[0]); if (Scribe.mode == LoadSaveMode.Saving) { this.compressor = new MapFileCompressor(this); this.compressor.BuildCompressedString(); this.ExposeComponents(); this.compressor.ExposeData(); HashSet <string> hashSet = new HashSet <string>(); if (Scribe.EnterNode("things")) { try { foreach (Thing thing in this.listerThings.AllThings) { try { if (thing.def.isSaveable && !thing.IsSaveCompressible()) { if (hashSet.Contains(thing.ThingID)) { Log.Error("Saving Thing with already-used ID " + thing.ThingID, false); } else { hashSet.Add(thing.ThingID); } Thing thing2 = thing; Scribe_Deep.Look <Thing>(ref thing2, "thing", new object[0]); } } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception saving ", thing, ": ", ex }), false); } } } finally { Scribe.ExitNode(); } } else { Log.Error("Could not enter the things node while saving.", false); } this.compressor = null; } else { if (Scribe.mode == LoadSaveMode.LoadingVars) { this.ConstructComponents(); this.regionAndRoomUpdater.Enabled = false; this.compressor = new MapFileCompressor(this); } this.ExposeComponents(); DeepProfiler.Start("Load compressed things"); this.compressor.ExposeData(); DeepProfiler.End(); DeepProfiler.Start("Load non-compressed things"); Scribe_Collections.Look <Thing>(ref this.loadedFullThings, "things", LookMode.Deep, new object[0]); DeepProfiler.End(); } }
public void ExposeData() { Scribe_Collections.Look(ref targets, "targets", LookMode.GlobalTargetInfo); }
public void ExposeData() { Scribe_Collections.Look(ref immunityList, "imList", LookMode.Deep); }
public override void ExposeData() { base.ExposeData(); Scribe_Collections.Look <IntVec3>(ref this.roadEdgeTiles, "roadEdgeTiles", LookMode.Undefined, new object[0]); }
public void ExposeData() { Scribe_Collections.Look <ImmunityRecord>(ref this.immunityList, "imList", LookMode.Deep, new object[0]); }
public void ExposeData() { Scribe_Collections.Look(ref itemsNotForSale, "itemsNotForSale", LookMode.Reference); Scribe_Deep.Look(ref innerContainer, "innerContainer", this); Scribe_Values.Look(ref unloadEverything, "unloadEverything", defaultValue: false); }
public void LoadGame() { if (this.maps.Any <Map>()) { Log.Error("Called LoadGame() but there already is a map. There should be 0 maps...", false); return; } MemoryUtility.UnloadUnusedUnityAssets(); Current.ProgramState = ProgramState.MapInitializing; this.ExposeSmallComponents(); LongEventHandler.SetCurrentEventText("LoadingWorld".Translate()); if (Scribe.EnterNode("world")) { try { this.World = new World(); this.World.ExposeData(); } finally { Scribe.ExitNode(); } this.World.FinalizeInit(); LongEventHandler.SetCurrentEventText("LoadingMap".Translate()); Scribe_Collections.Look <Map>(ref this.maps, "maps", LookMode.Deep, new object[0]); if (this.maps.RemoveAll((Map x) => x == null) != 0) { Log.Warning("Some maps were null after loading.", false); } int num = -1; Scribe_Values.Look <int>(ref num, "currentMapIndex", -1, false); if (num < 0 && this.maps.Any <Map>()) { Log.Error("Current map is null after loading but there are maps available. Setting current map to [0].", false); num = 0; } if (num >= this.maps.Count) { Log.Error("Current map index out of bounds after loading.", false); if (this.maps.Any <Map>()) { num = 0; } else { num = -1; } } this.currentMapIndex = -128; this.CurrentMap = ((num < 0) ? null : this.maps[num]); LongEventHandler.SetCurrentEventText("InitializingGame".Translate()); Find.CameraDriver.Expose(); DeepProfiler.Start("FinalizeLoading"); Scribe.loader.FinalizeLoading(); DeepProfiler.End(); LongEventHandler.SetCurrentEventText("SpawningAllThings".Translate()); for (int i = 0; i < this.maps.Count; i++) { try { this.maps[i].FinalizeLoading(); } catch (Exception arg) { Log.Error("Error in Map.FinalizeLoading(): " + arg, false); } try { this.maps[i].Parent.FinalizeLoading(); } catch (Exception arg2) { Log.Error("Error in MapParent.FinalizeLoading(): " + arg2, false); } } this.FinalizeInit(); if (Prefs.PauseOnLoad) { LongEventHandler.ExecuteWhenFinished(delegate { Find.TickManager.DoSingleTick(); Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; }); } GameComponentUtility.LoadedGame(); return; } Log.Error("Could not find world XML node.", false); }
public void ExposeData() { Scribe_Values.Look(ref uniqueID, "uniqueID", -1); Scribe_Values.Look(ref generationTick, "generationTick", 0); Scribe_Deep.Look(ref info, "mapInfo"); if (Scribe.mode == LoadSaveMode.Saving) { compressor = new MapFileCompressor(this); compressor.BuildCompressedString(); ExposeComponents(); compressor.ExposeData(); HashSet <string> hashSet = new HashSet <string>(); if (Scribe.EnterNode("things")) { try { foreach (Thing allThing in listerThings.AllThings) { try { if (allThing.def.isSaveable && !allThing.IsSaveCompressible()) { if (hashSet.Contains(allThing.ThingID)) { Log.Error("Saving Thing with already-used ID " + allThing.ThingID); } else { hashSet.Add(allThing.ThingID); } Thing target = allThing; Scribe_Deep.Look(ref target, "thing"); } } catch (OutOfMemoryException) { throw; } catch (Exception ex2) { Log.Error("Exception saving " + allThing + ": " + ex2); } } } finally { Scribe.ExitNode(); } } else { Log.Error("Could not enter the things node while saving."); } compressor = null; return; } if (Scribe.mode == LoadSaveMode.LoadingVars) { ConstructComponents(); regionAndRoomUpdater.Enabled = false; compressor = new MapFileCompressor(this); } ExposeComponents(); DeepProfiler.Start("Load compressed things"); compressor.ExposeData(); DeepProfiler.End(); DeepProfiler.Start("Load non-compressed things"); Scribe_Collections.Look(ref loadedFullThings, "things", LookMode.Deep); DeepProfiler.End(); }
public override void ExposeData() { base.ExposeData(); Scribe_Collections.Look(ref roadEdgeTiles, "roadEdgeTiles", LookMode.Undefined); }
public static void Look <K, V>(ref Dictionary <K, V> dict, string label, LookMode keyLookMode, LookMode valueLookMode, ref List <K> keysWorkingList, ref List <V> valuesWorkingList) where K : new() { if (Scribe.EnterNode(label)) { try { if (Scribe.mode == LoadSaveMode.Saving || Scribe.mode == LoadSaveMode.LoadingVars) { keysWorkingList = new List <K>(); valuesWorkingList = new List <V>(); } if (Scribe.mode == LoadSaveMode.Saving) { foreach (KeyValuePair <K, V> item in dict) { keysWorkingList.Add(item.Key); valuesWorkingList.Add(item.Value); } } Scribe_Collections.Look <K>(ref keysWorkingList, "keys", keyLookMode, new object[0]); Scribe_Collections.Look <V>(ref valuesWorkingList, "values", valueLookMode, new object[0]); if (Scribe.mode == LoadSaveMode.Saving) { if (keysWorkingList != null) { keysWorkingList.Clear(); keysWorkingList = null; } if (valuesWorkingList != null) { valuesWorkingList.Clear(); valuesWorkingList = null; } } bool flag = keyLookMode == LookMode.Reference || valueLookMode == LookMode.Reference; if (flag && Scribe.mode == LoadSaveMode.ResolvingCrossRefs) { goto IL_0118; } if (!flag && Scribe.mode == LoadSaveMode.LoadingVars) { goto IL_0118; } goto IL_0279; IL_0118: dict.Clear(); if (keysWorkingList == null) { Log.Error("Cannot fill dictionary because there are no keys."); } else if (valuesWorkingList == null) { Log.Error("Cannot fill dictionary because there are no values."); } else { if (keysWorkingList.Count != valuesWorkingList.Count) { Log.Error("Keys count does not match the values count while loading a dictionary (maybe keys and values were resolved during different passes?). Some elements will be skipped. keys=" + keysWorkingList.Count + ", values=" + valuesWorkingList.Count); } int num = Math.Min(keysWorkingList.Count, valuesWorkingList.Count); for (int i = 0; i < num; i++) { if (keysWorkingList[i] == null) { Log.Error("Null key while loading dictionary of " + typeof(K) + " and " + typeof(V) + "."); } else { try { dict.Add(keysWorkingList[i], valuesWorkingList[i]); } catch (Exception ex) { Log.Error("Exception in LookDictionary(node=" + label + "): " + ex); } } } } goto IL_0279; IL_0279: if (Scribe.mode == LoadSaveMode.PostLoadInit) { if (keysWorkingList != null) { keysWorkingList.Clear(); keysWorkingList = null; } if (valuesWorkingList != null) { valuesWorkingList.Clear(); valuesWorkingList = null; } } } finally { Scribe.ExitNode(); } } else if (Scribe.mode == LoadSaveMode.LoadingVars) { dict = null; } }
public void ExposeData() { Scribe_Collections.Look <V>(ref this.values, "vals", LookMode.Undefined, new object[0]); }
public static void Look <T>(ref List <T> list, string label, LookMode lookMode = LookMode.Undefined, params object[] ctorArgs) { Scribe_Collections.Look <T>(ref list, false, label, lookMode, ctorArgs); }
public void ExposeData() { Scribe_Collections.Look <Faction, PawnDestinationReservationManager.PawnDestinationSet>(ref this.reservedDestinations, "reservedDestinations", LookMode.Reference, LookMode.Deep, ref this.reservedDestinationsKeysWorkingList, ref this.reservedDestinationsValuesWorkingList); }
public static void Look <K, V>(ref Dictionary <K, V> dict, string label, LookMode keyLookMode, LookMode valueLookMode, ref List <K> keysWorkingList, ref List <V> valuesWorkingList) { if (Scribe.EnterNode(label)) { try { if (Scribe.mode == LoadSaveMode.Saving && dict == null) { Scribe.saver.WriteAttribute("IsNull", "True"); } else { if (Scribe.mode == LoadSaveMode.LoadingVars) { XmlAttribute xmlAttribute = Scribe.loader.curXmlParent.Attributes["IsNull"]; if (xmlAttribute != null && xmlAttribute.Value.ToLower() == "true") { dict = null; } else { dict = new Dictionary <K, V>(); } } if (Scribe.mode == LoadSaveMode.Saving || Scribe.mode == LoadSaveMode.LoadingVars) { keysWorkingList = new List <K>(); valuesWorkingList = new List <V>(); if (Scribe.mode == LoadSaveMode.Saving) { if (dict != null) { foreach (KeyValuePair <K, V> keyValuePair in dict) { keysWorkingList.Add(keyValuePair.Key); valuesWorkingList.Add(keyValuePair.Value); } } } } Scribe_Collections.Look <K>(ref keysWorkingList, "keys", keyLookMode, new object[0]); Scribe_Collections.Look <V>(ref valuesWorkingList, "values", valueLookMode, new object[0]); if (Scribe.mode == LoadSaveMode.Saving) { if (keysWorkingList != null) { keysWorkingList.Clear(); keysWorkingList = null; } if (valuesWorkingList != null) { valuesWorkingList.Clear(); valuesWorkingList = null; } } bool flag = keyLookMode == LookMode.Reference || valueLookMode == LookMode.Reference; if ((flag && Scribe.mode == LoadSaveMode.ResolvingCrossRefs) || (!flag && Scribe.mode == LoadSaveMode.LoadingVars)) { if (dict != null) { if (keysWorkingList == null) { Log.Error("Cannot fill dictionary because there are no keys. label=" + label, false); } else if (valuesWorkingList == null) { Log.Error("Cannot fill dictionary because there are no values. label=" + label, false); } else { if (keysWorkingList.Count != valuesWorkingList.Count) { Log.Error(string.Concat(new object[] { "Keys count does not match the values count while loading a dictionary (maybe keys and values were resolved during different passes?). Some elements will be skipped. keys=", keysWorkingList.Count, ", values=", valuesWorkingList.Count, ", label=", label }), false); } int num = Math.Min(keysWorkingList.Count, valuesWorkingList.Count); for (int i = 0; i < num; i++) { if (keysWorkingList[i] == null) { Log.Error(string.Concat(new object[] { "Null key while loading dictionary of ", typeof(K), " and ", typeof(V), ". label=", label }), false); } else { try { dict.Add(keysWorkingList[i], valuesWorkingList[i]); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception in LookDictionary(label=", label, "): ", ex }), false); } } } } } } if (Scribe.mode == LoadSaveMode.PostLoadInit) { if (keysWorkingList != null) { keysWorkingList.Clear(); keysWorkingList = null; } if (valuesWorkingList != null) { valuesWorkingList.Clear(); valuesWorkingList = null; } } } } finally { Scribe.ExitNode(); } } else if (Scribe.mode == LoadSaveMode.LoadingVars) { dict = null; } }
private void ExposeComponents() { Scribe_Deep.Look <WeatherManager>(ref this.weatherManager, "weatherManager", new object[] { this }); Scribe_Deep.Look <ReservationManager>(ref this.reservationManager, "reservationManager", new object[] { this }); Scribe_Deep.Look <PhysicalInteractionReservationManager>(ref this.physicalInteractionReservationManager, "physicalInteractionReservationManager", new object[0]); Scribe_Deep.Look <DesignationManager>(ref this.designationManager, "designationManager", new object[] { this }); Scribe_Deep.Look <PawnDestinationReservationManager>(ref this.pawnDestinationReservationManager, "pawnDestinationReservationManager", new object[0]); Scribe_Deep.Look <LordManager>(ref this.lordManager, "lordManager", new object[] { this }); Scribe_Deep.Look <PassingShipManager>(ref this.passingShipManager, "visitorManager", new object[] { this }); Scribe_Deep.Look <GameConditionManager>(ref this.gameConditionManager, "gameConditionManager", new object[] { this }); Scribe_Deep.Look <FogGrid>(ref this.fogGrid, "fogGrid", new object[] { this }); Scribe_Deep.Look <RoofGrid>(ref this.roofGrid, "roofGrid", new object[] { this }); Scribe_Deep.Look <TerrainGrid>(ref this.terrainGrid, "terrainGrid", new object[] { this }); Scribe_Deep.Look <ZoneManager>(ref this.zoneManager, "zoneManager", new object[] { this }); Scribe_Deep.Look <TemperatureCache>(ref this.temperatureCache, "temperatureCache", new object[] { this }); Scribe_Deep.Look <SnowGrid>(ref this.snowGrid, "snowGrid", new object[] { this }); Scribe_Deep.Look <AreaManager>(ref this.areaManager, "areaManager", new object[] { this }); Scribe_Deep.Look <VoluntarilyJoinableLordsStarter>(ref this.lordsStarter, "lordsStarter", new object[] { this }); Scribe_Deep.Look <AttackTargetReservationManager>(ref this.attackTargetReservationManager, "attackTargetReservationManager", new object[] { this }); Scribe_Deep.Look <DeepResourceGrid>(ref this.deepResourceGrid, "deepResourceGrid", new object[] { this }); Scribe_Deep.Look <WeatherDecider>(ref this.weatherDecider, "weatherDecider", new object[] { this }); Scribe_Deep.Look <DamageWatcher>(ref this.damageWatcher, "damageWatcher", new object[0]); Scribe_Deep.Look <RememberedCameraPos>(ref this.rememberedCameraPos, "rememberedCameraPos", new object[] { this }); Scribe_Deep.Look <MineStrikeManager>(ref this.mineStrikeManager, "mineStrikeManager", new object[0]); Scribe_Deep.Look <RetainedCaravanData>(ref this.retainedCaravanData, "retainedCaravanData", new object[] { this }); Scribe_Deep.Look <StoryState>(ref this.storyState, "storyState", new object[] { this }); Scribe_Deep.Look <WildPlantSpawner>(ref this.wildPlantSpawner, "wildPlantSpawner", new object[] { this }); Scribe_Collections.Look <MapComponent>(ref this.components, "components", LookMode.Deep, new object[] { this }); this.FillComponents(); if (Scribe.mode == LoadSaveMode.PostLoadInit) { BackCompatibility.MapPostLoadInit(this); } }
public void LoadGame() { if (this.maps.Any()) { Log.Error("Called LoadGame() but there already is a map. There should be 0 maps..."); } else { MemoryUtility.UnloadUnusedUnityAssets(); Current.ProgramState = ProgramState.MapInitializing; this.ExposeSmallComponents(); BackCompatibility.AfterLoadingSmallGameClassComponents(this); LongEventHandler.SetCurrentEventText("LoadingWorld".Translate()); if (Scribe.EnterNode("world")) { try { this.World = new World(); this.World.ExposeData(); } finally { Scribe.ExitNode(); } this.World.FinalizeInit(); LongEventHandler.SetCurrentEventText("LoadingMap".Translate()); Scribe_Collections.Look <Map>(ref this.maps, "maps", LookMode.Deep, new object[0]); int num = -1; Scribe_Values.Look(ref num, "visibleMapIndex", -1, false); if (num < 0 && this.maps.Any()) { Log.Error("Visible map is null after loading but there are maps available. Setting visible map to [0]."); num = 0; } if (num >= this.maps.Count) { Log.Error("Visible map index out of bounds after loading."); num = ((!this.maps.Any()) ? (-1) : 0); } this.visibleMapIndex = -128; this.VisibleMap = ((num < 0) ? null : this.maps[num]); LongEventHandler.SetCurrentEventText("InitializingGame".Translate()); Find.CameraDriver.Expose(); DeepProfiler.Start("FinalizeLoading"); Scribe.loader.FinalizeLoading(); DeepProfiler.End(); LongEventHandler.SetCurrentEventText("SpawningAllThings".Translate()); for (int i = 0; i < this.maps.Count; i++) { this.maps[i].FinalizeLoading(); } this.FinalizeInit(); if (Prefs.PauseOnLoad) { LongEventHandler.ExecuteWhenFinished(delegate { Find.TickManager.DoSingleTick(); Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; }); } GameComponentUtility.LoadedGame(); } else { Log.Error("Could not find world XML node."); } } }