private static void LoadMission(CheckpointData data) { var checkpoint = data.Checkpoint; MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success, string mismatchMods) { if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods)) { //Sandbox.Audio.MyAudio.Static.Mute = true; MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); MyGuiScreenLoadSandbox.CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val) { // May be called from gameplay, so we must make sure we unload the current game if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } //seed 0 has special meaning - please randomize at mission start. New seed will be saved and game will run with it ever since. // if you use this, YOU CANNOT HAVE ANY PROCEDURAL ASTEROIDS ALREADY SAVED if (checkpoint.Settings.ProceduralSeed == 0) { checkpoint.Settings.ProceduralSeed = MyRandom.Instance.Next(); } MyGuiScreenGamePlay.StartLoading(delegate { checkpoint.Settings.Scenario = true; MySession.LoadMission(data.SessionPath, checkpoint, data.CheckpointSize, data.PersistentEditMode); }); }); } else { MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (MyFakes.QUICK_LAUNCH != null) { MyGuiScreenMainMenu.ReturnToMainMenu(); } })); } MyLog.Default.WriteLine("LoadSession() - End"); }); }
public void LoadMission(string sessionPath, string name, string description, bool multiplayer) { MyLog.Default.WriteLine("LoadSession() - Start"); MyLog.Default.WriteLine(sessionPath); ulong checkpointSizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes); checkpoint.Settings.OnlineMode = (MyOnlineModeEnum)m_onlineMode.GetSelectedKey(); checkpoint.Settings.MaxPlayers = (short)m_maxPlayersSlider.Value; checkpoint.Settings.Scenario = true; checkpoint.Settings.GameMode = MyGameModeEnum.Survival; checkpoint.Settings.ScenarioEditMode = false; if (!MySession.IsCompatibleVersion(checkpoint)) { MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE)) { MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success) { if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods)) { //Sandbox.Audio.MyAudio.Static.Mute = true; MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); // May be called from gameplay, so we must make sure we unload the current game if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } //seed 0 has special meaning - please randomize at mission start. New seed will be saved and game will run with it ever since. // if you use this, YOU CANNOT HAVE ANY PROCEDURAL ASTEROIDS ALREADY SAVED if (checkpoint.Settings.ProceduralSeed == 0) { checkpoint.Settings.ProceduralSeed = MyRandom.Instance.Next(); } MyGuiScreenGamePlay.StartLoading(delegate { checkpoint.Settings.Scenario = true; MySession.LoadMission(sessionPath, checkpoint, checkpointSizeInBytes, name, description); }); } else { MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (MyFakes.QUICK_LAUNCH != null) { MyGuiScreenMainMenu.ReturnToMainMenu(); } })); } MyLog.Default.WriteLine("LoadSession() - End"); }); }