public static void ReloadGame(List <int> mapsToLoad, bool changeScene, bool forceAsyncTime) { var gameDoc = GetGameDocument(mapsToLoad); LoadPatch.gameToLoad = new(gameDoc, Multiplayer.session.dataSnapshot.semiPersistentData); TickPatch.replayTimeSpeed = TimeSpeed.Paused; if (changeScene) { LongEventHandler.QueueLongEvent(() => { MemoryUtility.ClearAllMapsAndWorld(); Current.Game = new Game { InitData = new GameInitData { gameToLoad = "server" } }; LongEventHandler.ExecuteWhenFinished(() => { LongEventHandler.QueueLongEvent(() => PostLoad(forceAsyncTime), "MpSimulating", false, null); }); }, "Play", "MpLoading", true, null); } else { LongEventHandler.QueueLongEvent(() => { SaveLoad.LoadInMainThread(LoadPatch.gameToLoad); PostLoad(forceAsyncTime); }, "MpLoading", false, null); } }
public static void ReloadGame(List <int> mapsToLoad, bool async = true) { LoadPatch.gameToLoad = GetGameDocument(mapsToLoad); TickPatch.replayTimeSpeed = TimeSpeed.Paused; if (async) { LongEventHandler.QueueLongEvent(() => { MemoryUtility.ClearAllMapsAndWorld(); Current.Game = new Game(); Current.Game.InitData = new GameInitData(); Current.Game.InitData.gameToLoad = "server"; LongEventHandler.ExecuteWhenFinished(() => { LongEventHandler.QueueLongEvent(() => PostLoad(), "MpSimulating", false, null); }); }, "Play", "MpLoading", true, null); } else { LongEventHandler.QueueLongEvent(() => { SaveLoad.LoadInMainThread(LoadPatch.gameToLoad); PostLoad(); }, "MpLoading", false, null); } }