public static void LoadMultiplayerScenarioWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) { Debug.Assert(MySession.Static != null); MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - Start"); if (world.Checkpoint.BriefingVideo != null && world.Checkpoint.BriefingVideo.Length > 0) { MyGuiSandbox.OpenUrlWithFallback(world.Checkpoint.BriefingVideo, "Scenario briefing video", true); } if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false)) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); })); MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - End"); return; } MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods, onFinishedCallback : delegate(bool success, string mismatchMods) { if (success) { CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val) { MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); MyGuiScreenGamePlay.StartLoading(delegate { MySession.Static.LoadMultiplayerWorld(world, multiplayerSession); if (ScenarioWorldLoaded != null) { ScenarioWorldLoaded(); } }); }); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); })); } MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - End"); }, onCancelledCallback : delegate() { MyGuiScreenMainMenu.UnloadAndExitToMenu(); }); }
public static void LoadMultiplayerBattleWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) { MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - Start"); Debug.Assert(MySession.Static != null); if (MySession.Static == null) { MyGuiScreenMainMenu.UnloadAndExitToMenu(); return; } if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false)) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); })); MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End"); return; } MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods, onFinishedCallback : delegate(bool success) { if (success) { MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); MyGuiScreenGamePlay.StartLoading(delegate { MySession.Static.LoadMultiplayerWorld(world, multiplayerSession); Debug.Assert(MySession.Static.Battle); if (BattleWorldLoaded != null) { BattleWorldLoaded(); } }); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); })); } MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End"); }, onCancelledCallback : delegate() { MyGuiScreenMainMenu.UnloadAndExitToMenu(); }); }
private void StartNewSandbox() { MyLog.Default.WriteLine("StartNewSandbox - Start"); GetSettingsFromControls(); if (!MySteamWorkshop.CheckLocalModsAllowed(m_mods, m_settings.OnlineMode == MyOnlineModeEnum.OFFLINE)) { 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(m_mods, delegate(bool success) { if (success || (m_settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(m_mods)) { MyScreenManager.RemoveAllScreensExcept(null); if (AsteroidAmount < 0) { MyWorldGenerator.SetProceduralSettings(AsteroidAmount, m_settings); m_asteroidAmount = 0; } MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Custom); MyGuiScreenGamePlay.StartLoading(delegate { MySession.Start( m_nameTextbox.Text, GetDescription(), GetPassword(), m_settings, m_mods, new MyWorldGenerator.Args() { AsteroidAmount = this.AsteroidAmount, Scenario = (m_scenarioTypesGroup.SelectedButton as MyGuiControlScenarioButton).Scenario } ); }); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed), buttonType: MyMessageBoxButtonsType.OK)); } MyLog.Default.WriteLine("StartNewSandbox - End"); }); }
public static void LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) { MyLog.Default.WriteLine("LoadSession() - Start"); if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false)) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods, onFinishedCallback : delegate(bool success) { if (success) { //Sandbox.Audio.MyAudio.Static.Mute = true; MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(VRage.Game.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; } MyGuiScreenGamePlay.StartLoading(delegate { MySession.LoadMultiplayer(world, multiplayerSession); }); } else { if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Dispose(); } MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType: MyMessageBoxButtonsType.OK)); } MyLog.Default.WriteLine("LoadSession() - End"); }, onCancelledCallback : delegate() { multiplayerSession.Dispose(); }); }
// Start game with some default values public static void QuickstartSandbox(MyObjectBuilder_SessionSettings quickstartSettings, MyWorldGenerator.Args?quickstartArgs) { MyLog.Default.WriteLine("QuickstartSandbox - START"); MyScreenManager.RemoveAllScreensExcept(null); MyGuiScreenGamePlay.StartLoading(delegate { var settings = (quickstartSettings != null) ? quickstartSettings : CreateBasicQuickStartSettings(); var args = (quickstartArgs != null) ? quickstartArgs.Value : CreateBasicQuickstartArgs(); var mods = new List <MyObjectBuilder_Checkpoint.ModItem>(0); MySession.Start("Created " + DateTime.Now.ToString("yyyy-MM-dd HH:mm"), "", "", settings, mods, args); }); MyLog.Default.WriteLine("QuickstartSandbox - END"); }
public static void LoadSingleplayerSession(MyObjectBuilder_Checkpoint checkpoint, string sessionPath, ulong checkpointSizeInBytes) { if (!MySession.IsCompatibleVersion(checkpoint)) { MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.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(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.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(VRage.Game.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; } MyGuiScreenGamePlay.StartLoading(delegate { MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Load); MySession.Load(sessionPath, checkpoint, checkpointSizeInBytes); }); } else { MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed).ToString()); if (MySteam.IsOnline) { 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(); } })); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline), buttonType: MyMessageBoxButtonsType.OK)); } } 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"); }); }