コード例 #1
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();
         }
     }
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: ehtnnd/RW-Decompile
 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);
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: SeanLeeLKY/RimWorld-Decompile
 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.");
         }
     }
 }