public void FinalizeLoading() { List <Thing> list = this.compressor.ThingsToSpawnAfterLoad().ToList <Thing>(); this.compressor = null; DeepProfiler.Start("Merge compressed and non-compressed thing lists"); List <Thing> list2 = new List <Thing>(this.loadedFullThings.Count + list.Count); foreach (Thing item in this.loadedFullThings.Concat(list)) { list2.Add(item); } this.loadedFullThings.Clear(); DeepProfiler.End(); DeepProfiler.Start("Spawn everything into the map"); foreach (Thing thing in list2) { if (!(thing is Building)) { try { GenSpawn.Spawn(thing, thing.Position, this, thing.Rotation, WipeMode.FullRefund, true); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception spawning loaded thing ", thing.ToStringSafe <Thing>(), ": ", ex }), false); } } } foreach (Building building in from t in list2.OfType <Building>() orderby t.def.size.Magnitude select t) { try { GenSpawn.SpawnBuildingAsPossible(building, this, true); } catch (Exception ex2) { Log.Error(string.Concat(new object[] { "Exception spawning loaded thing ", building.ToStringSafe <Building>(), ": ", ex2 }), false); } } DeepProfiler.End(); this.FinalizeInit(); }
public void FinalizeLoading() { List <Thing> list = compressor.ThingsToSpawnAfterLoad().ToList(); compressor = null; DeepProfiler.Start("Merge compressed and non-compressed thing lists"); List <Thing> list2 = new List <Thing>(loadedFullThings.Count + list.Count); foreach (Thing item in loadedFullThings.Concat(list)) { list2.Add(item); } loadedFullThings.Clear(); DeepProfiler.End(); DeepProfiler.Start("Spawn everything into the map"); BackCompatibility.PreCheckSpawnBackCompatibleThingAfterLoading(this); foreach (Thing item2 in list2) { if (item2 is Building) { continue; } try { if (!BackCompatibility.CheckSpawnBackCompatibleThingAfterLoading(item2, this)) { GenSpawn.Spawn(item2, item2.Position, this, item2.Rotation, WipeMode.FullRefund, respawningAfterLoad: true); } } catch (Exception ex) { Log.Error("Exception spawning loaded thing " + item2.ToStringSafe() + ": " + ex); } } foreach (Building item3 in from t in list2.OfType <Building>() orderby t.def.size.Magnitude select t) { try { GenSpawn.SpawnBuildingAsPossible(item3, this, respawningAfterLoad: true); } catch (Exception ex2) { Log.Error("Exception spawning loaded thing " + item3.ToStringSafe() + ": " + ex2); } } BackCompatibility.PostCheckSpawnBackCompatibleThingAfterLoading(this); DeepProfiler.End(); FinalizeInit(); }
public void FinalizeLoading() { List <Thing> list = this.compressor.ThingsToSpawnAfterLoad().ToList(); this.compressor = null; DeepProfiler.Start("Merge compressed and non-compressed thing lists"); List <Thing> list2 = new List <Thing>(this.loadedFullThings.Count + list.Count); foreach (Thing item in this.loadedFullThings.Concat(list)) { list2.Add(item); } this.loadedFullThings.Clear(); DeepProfiler.End(); DeepProfiler.Start("Spawn everything into the map"); foreach (Thing item2 in list2) { if (!(item2 is Building)) { try { GenSpawn.Spawn(item2, item2.Position, this, item2.Rotation, true); } catch (Exception ex) { Log.Error("Exception spawning loaded thing " + item2 + ": " + ex); } } } foreach (Building item3 in from t in list2.OfType <Building>() orderby t.def.size.Magnitude select t) { try { GenSpawn.SpawnBuildingAsPossible(item3, this, true); } catch (Exception ex2) { Log.Error("Exception spawning loaded thing " + item3 + ": " + ex2); } } DeepProfiler.End(); this.FinalizeInit(); }
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_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(string.Concat("Exception saving ", allThing, ": ", ex2)); } } } finally { Scribe.ExitNode(); } } else { Log.Error("Could not enter the things node while saving."); } compressor = null; } else { 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(); } }