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 <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 current in this.loadedFullThings.Concat(list)) { list2.Add(current); } this.loadedFullThings.Clear(); DeepProfiler.End(); DeepProfiler.Start("Spawn everything into the map"); BackCompatibility.PreCheckSpawnBackCompatibleThingAfterLoading(this); foreach (Thing current2 in list2) { if (!(current2 is Building)) { try { if (!BackCompatibility.CheckSpawnBackCompatibleThingAfterLoading(current2, this)) { GenSpawn.Spawn(current2, current2.Position, this, current2.Rotation, WipeMode.FullRefund, true); } } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception spawning loaded thing ", current2.ToStringSafe <Thing>(), ": ", ex }), false); } } } foreach (Building current3 in from t in list2.OfType <Building>() orderby t.def.size.Magnitude select t) { try { GenSpawn.SpawnBuildingAsPossible(current3, this, true); } catch (Exception ex2) { Log.Error(string.Concat(new object[] { "Exception spawning loaded thing ", current3.ToStringSafe <Building>(), ": ", ex2 }), false); } } BackCompatibility.PostCheckSpawnBackCompatibleThingAfterLoading(this); DeepProfiler.End(); this.FinalizeInit(); }