public void LoadGame() { if (this.maps.Any <Map>()) { Log.Error("Called LoadGame() but there already is a map. There should be 0 maps..."); return; } 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 <int>(ref num, "visibleMapIndex", -1, false); if (num < 0 && this.maps.Any <Map>()) { 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."); if (this.maps.Any <Map>()) { num = 0; } else { num = -1; } } 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(); return; } Log.Error("Could not find world XML node."); }