/// <summary> /// Starts new session and unloads outdated if theres any. /// </summary> /// <param name="sessionName">Created session name.</param> /// <param name="settings">Session settings OB.</param> /// <param name="mods">Mod selection.</param> /// <param name="scenarioDefinition">World generator argument.</param> /// <param name="asteroidAmount">Hostility settings.</param> /// <param name="description">Session description.</param> /// <param name="passwd">Session password.</param> public static void StartNewSession(string sessionName, MyObjectBuilder_SessionSettings settings, List <MyObjectBuilder_Checkpoint.ModItem> mods, MyScenarioDefinition scenarioDefinition = null, int asteroidAmount = 0, string description = "", string passwd = "") { MyLog.Default.WriteLine("StartNewSandbox - Start"); if (!MySteamWorkshop.CheckLocalModsAllowed(mods, settings.OnlineMode == MyOnlineModeEnum.OFFLINE)) { 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(mods, delegate(bool success, string mismatchMods) { if (success || (settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(mods)) { CheckMismatchmods(mismatchMods, callback : delegate(ResultEnum val) { MyScreenManager.RemoveAllScreensExcept(null); if (asteroidAmount < 0) { MyWorldGenerator.SetProceduralSettings(asteroidAmount, settings); asteroidAmount = 0; } MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Custom); StartLoading(delegate { MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Custom); MySession.Start( sessionName, description, passwd, settings, mods, new MyWorldGenerator.Args() { AsteroidAmount = asteroidAmount, Scenario = scenarioDefinition } ); }); }); } else { if (MySteam.IsOnline) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType: MyMessageBoxButtonsType.OK)); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline), buttonType: MyMessageBoxButtonsType.OK)); } } MyLog.Default.WriteLine("StartNewSandbox - End"); }); }