public static void SetProceduralSettings(int?asteroidAmount, MyObjectBuilder_SessionSettings sessionSettings) { sessionSettings.ProceduralSeed = MyRandom.Instance.Next(); switch ((MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum)asteroidAmount) { case MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum.ProceduralNone: sessionSettings.ProceduralDensity = 0.00f; break; case MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum.ProceduralLow: sessionSettings.ProceduralDensity = 0.25f; break; case MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum.ProceduralNormal: sessionSettings.ProceduralDensity = 0.35f; break; case MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum.ProceduralHigh: sessionSettings.ProceduralDensity = 0.50f; break; default: throw new InvalidBranchException(); break; } }
private void gamesListBox_SelectedIndexChanged(object sender, EventArgs e) { if (gamesListBox.SelectedIndex != -1) { ulong sizeInBytes; WorldItem worldItem = (WorldItem)gamesListBox.Items[gamesListBox.SelectedIndex]; ((MyConfigDedicated <MyObjectBuilder_SessionSettings>)MySandboxGame.ConfigDedicated).LoadWorld = worldItem.SessionPath; var loadPath = worldItem.SessionPath; MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(loadPath, out sizeInBytes); m_selectedSessionSettings = checkpoint.Settings; MySandboxGame.ConfigDedicated.Mods.Clear(); foreach (var mod in checkpoint.Mods) { if (mod.PublishedFileId != 0) { MySandboxGame.ConfigDedicated.Mods.Add(mod.PublishedFileId); } } modIdsTextBox.Text = string.Join(Environment.NewLine, MySandboxGame.ConfigDedicated.Mods.ToArray()); FillSessionSettingsItems(); } }
private void startTypeRadio_CheckedChanged(object sender, EventArgs e) { if (!m_canChangeStartType) { return; } startGameButton.Enabled = true; tableLayoutPanel1.Show(); newGameSettingsPanel.Show(); if (loadGameButton.Checked) { if (gamesListBox.Items.Count > 0) { gamesListBox.Enabled = true; //tableLayoutPanel1.Enabled = false; newGameSettingsPanel.Enabled = false; if (gamesListBox.SelectedIndex == -1) { gamesListBox.SelectedIndex = 0; } } else { startGameButton.Checked = true; gamesListBox.Enabled = false; //tableLayoutPanel1.Enabled = true; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; FillSessionSettingsItems(); } } else { gamesListBox.SelectedIndex = -1; gamesListBox.Enabled = false; //tableLayoutPanel1.Enabled = true; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; //enable tool shake needs to be true for new world, but false for old saved worlds. m_selectedSessionSettings.EnableToolShake = true; m_selectedSessionSettings.EnableFlora = (MyPerGameSettings.Game == GameEnum.SE_GAME) && MyFakes.ENABLE_PLANETS; m_selectedSessionSettings.EnableSunRotation = MyPerGameSettings.Game == GameEnum.SE_GAME; m_selectedSessionSettings.CargoShipsEnabled = true; m_selectedSessionSettings.EnableWolfs = false; m_selectedSessionSettings.EnableSpiders = true; FillSessionSettingsItems(); } }
/// <summary> /// Creates a view model using an existing <see cref="MyObjectBuilder_SessionSettings"/> object. /// </summary> public SessionSettingsViewModel(MyObjectBuilder_SessionSettings settings) { _settings = settings; foreach (var limit in settings.BlockTypeLimits.Dictionary) { BlockLimits.Add(new BlockLimitViewModel(this, limit.Key, limit.Value)); } }
private void LoadValues() { m_nameTextbox.Text = m_checkpoint.SessionName ?? ""; m_descriptionTextbox.Text = m_checkpoint.Description ?? ""; m_settings = CopySettings(m_checkpoint.Settings); m_mods = m_checkpoint.Mods; SetSettingsToControls(); }
private void LoadValues() { m_nameTextbox.Text = m_checkpoint.SessionName ?? ""; m_descriptionTextbox.Text = m_checkpoint.Description ?? ""; m_settings = CopySettings(m_checkpoint.Settings); m_mods = m_checkpoint.Mods; m_asteroidAmountCombo.SelectItemByKey((int)AsteroidAmountEnum.Normal); SetSettingsToControls(); }
private void LoadValues() { m_nameTextbox.Text = m_checkpoint.SessionName ?? ""; m_descriptionTextbox.Text = m_checkpoint.Description ?? ""; m_settings = CopySettings(m_checkpoint.Settings); m_mods = m_checkpoint.Mods; m_environment.SelectItemByKey((int)(m_checkpoint.Settings.EnvironmentHostility)); SetSettingsToControls(); }
public static void FillDefaultBattleServerSettings(MyObjectBuilder_SessionSettings settings, bool dedicated) { settings.GameMode = MyGameModeEnum.Survival; settings.Battle = true; settings.OnlineMode = MyOnlineModeEnum.PUBLIC; settings.MaxPlayers = dedicated ? (short)MAX_BATTLE_PLAYERS : (short)12; settings.PermanentDeath = false; settings.AutoSave = false; settings.EnableStructuralSimulation = true; }
public void GetSettings(MyObjectBuilder_SessionSettings output) { output.EnablePlanets = m_enablePlanets.IsChecked; output.FloraDensity = GetFloraDensity(); output.EnableFlora = output.FloraDensity > 0; output.MoonMaxSize = m_moonMaxSizeSlider.Value; output.MoonMinSize = m_moonMinSizeSlider.Value; output.PlanetMaxSize = m_planetMaxSizeSlider.Value; output.PlanetMinSize = m_planetMinSizeSlider.Value; }
public void ReportGameplayStart(MyObjectBuilder_SessionSettings settings) { if (this.m_isSessionStarted) { Dictionary <string, object> gameplayStartData = this.GetGameplayStartData(this.m_entry, settings); this.m_gameplayStartTime = DateTime.UtcNow; ReportEvent(MyAnalyticsProgressionStatus.WorldStart, gameplayStartData, 0.0); this.ReportMods(); } }
private void reloadButton_Click(object sender, EventArgs e) { MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; UpdateLoadedData(); FillSessionSettingsItems(true); }
private void SetDefaultValues() { m_scenarioTypesGroup.SelectByKey(0); m_settings = GetDefaultSettings(); m_settings.EnableToolShake = true; m_settings.VoxelGeneratorVersion = MyVoxelConstants.VOXEL_GENERATOR_VERSION; m_settings.EnableOxygen = true; m_mods = new List <MyObjectBuilder_Checkpoint.ModItem>(); SetSettingsToControls(); SetDefaultName(); }
private void SetDefaultValues() { m_scenarioTypesGroup.SelectByKey(0); m_settings = GetDefaultSettings(); m_settings.EnableToolShake = true; m_settings.EnablePlanets = (MyPerGameSettings.Game == GameEnum.SE_GAME) && MyFakes.ENABLE_PLANETS; m_settings.EnableStationVoxelSupport = MyPerGameSettings.Game == GameEnum.SE_GAME; m_settings.EnableSunRotation = MyPerGameSettings.Game == GameEnum.SE_GAME; m_settings.VoxelGeneratorVersion = MyVoxelConstants.VOXEL_GENERATOR_VERSION; m_settings.EnableOxygen = true; m_mods = new List <MyObjectBuilder_Checkpoint.ModItem>(); SetSettingsToControls(); SetDefaultName(); }
private void scenario_SelectedChanged(MyGuiControlRadioButtonGroup group) { SetDefaultName(); // If the scenario selected is "Empty World" it will select Safe as the default environment, but only if this setting wasn't changed before if (!m_isHostilityChanged) { m_environment.SelectItemByKey(0); // It will change with the above code to true m_isHostilityChanged = false; } if (MyFakes.ENABLE_PLANETS) { m_worldGeneratorButton.Enabled = true; if (m_worldGeneratorButton.Enabled) { if (WorldGenerator != null) { WorldGenerator.GetSettings(m_settings); AsteroidAmount = WorldGenerator.AsteroidAmount; } else { //GK: If AsteroidAmount==0 it will cause no Asteroids spawned near player in Asteroids Scenario AsteroidAmount = -1; } } else if (m_settings != null) { AsteroidAmount = 0; m_settings.EnableFlora = true; } } else { UpdateAsteroidAmountEnabled(true); } var checkpointPath = group.SelectedButton.UserData as string; ulong size; var checkpoint = MyLocalCache.LoadCheckpoint(checkpointPath, out size); if (checkpoint != null) { m_settings = CopySettings(checkpoint.Settings); SetSettingsToControls(); } }
public static void FillDefaultBattleServerSettings(MyObjectBuilder_SessionSettings settings) { settings.GameMode = MyGameModeEnum.Survival; settings.Battle = true; settings.OnlineMode = MyOnlineModeEnum.PUBLIC; settings.MaxPlayers = 6; settings.PermanentDeath = false; settings.AutoSave = false; if (settings is MyObjectBuilder_MedievalSessionSettings) { MyObjectBuilder_MedievalSessionSettings me_settings = settings as MyObjectBuilder_MedievalSessionSettings; me_settings.EnableStructuralSimulation = true; } }
// 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"); }
private void loadConfigButton_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Configuration file (*.xml)|*.xml|All files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { MySandboxGame.ConfigDedicated.Load(ofd.FileName); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; UpdateLoadedData(); FillSessionSettingsItems(true); } }
private void startTypeRadio_CheckedChanged(object sender, EventArgs e) { if (!m_canChangeStartType) { return; } if (loadGameButton.Checked) { if (gamesListBox.Items.Count > 0) { gamesListBox.Enabled = true; //tableLayoutPanel1.Enabled = false; newGameSettingsPanel.Enabled = false; if (gamesListBox.SelectedIndex == -1) { gamesListBox.SelectedIndex = 0; } } else { startGameButton.Checked = true; gamesListBox.Enabled = false; //tableLayoutPanel1.Enabled = true; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; } } else { gamesListBox.SelectedIndex = -1; gamesListBox.Enabled = false; //tableLayoutPanel1.Enabled = true; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; //enable tool shake needs to be true for new world, but false for old saved worlds. m_selectedSessionSettings.EnableToolShake = true; } FillSessionSettingsItems(); }
protected override Dictionary <string, object> GetGameplayStartData(MyGameEntryEnum entry, MyObjectBuilder_SessionSettings settings) { int isVanilla; int num2; int count; MyVisualScriptManagerSessionComponent component = MySession.Static.GetComponent <MyVisualScriptManagerSessionComponent>(); bool flag = (MyCampaignManager.Static != null) ? (MyCampaignManager.Static.ActiveCampaign != null) : false; Dictionary <string, object> gameplayStartData = base.GetGameplayStartData(entry, settings); gameplayStartData["is_campaign_mission"] = flag; Dictionary <string, object> dictionary1 = gameplayStartData; if (!flag || (MyCampaignManager.Static.ActiveCampaign == null)) { isVanilla = 0; } else { isVanilla = (int)MyCampaignManager.Static.ActiveCampaign.IsVanilla; } dictionary1[(string)dictionary1] = (bool)isVanilla; if ((component == null) || (component.RunningLevelScriptNames == null)) { num2 = 0; } else { num2 = component.RunningLevelScriptNames.Count <string>(); } "is_official_campaign"["level_script_count"] = num2; if (((component == null) || (component.SMManager == null)) || (component.SMManager.MachineDefinitions == null)) { count = 0; } else { count = component.SMManager.MachineDefinitions.Count; } "is_official_campaign"["state_machine_count"] = count; this.m_lastCampaignProgressionTime = 0; string local2 = "is_official_campaign"; local2["voxel_support"] = settings.StationVoxelSupport; local2["destructible_blocks"] = settings.DestructibleBlocks; local2["destructible_voxels"] = settings.EnableVoxelDestruction; local2["jetpack"] = settings.EnableJetpack; local2["hostility"] = settings.EnvironmentHostility.ToString(); local2["drones"] = settings.EnableDrones; local2["wolfs"] = settings.EnableWolfs; local2["spiders"] = settings.EnableSpiders; local2["encounters"] = settings.EnableEncounters; local2["oxygen"] = settings.EnableOxygen; local2["pressurization"] = settings.EnableOxygenPressurization; local2["realistic_sounds"] = settings.RealisticSound; local2["tool_shake"] = settings.EnableToolShake; local2["multiplier_inventory"] = settings.InventorySizeMultiplier; local2["multiplier_welding_speed"] = settings.WelderSpeedMultiplier; local2["multiplier_grinding_speed"] = settings.GrinderSpeedMultiplier; local2["multiplier_refinery_speed"] = settings.RefinerySpeedMultiplier; local2["multiplier_assembler_speed"] = settings.AssemblerSpeedMultiplier; local2["multiplier_assembler_efficiency"] = settings.AssemblerEfficiencyMultiplier; local2["max_floating_objects"] = settings.MaxFloatingObjects; return((Dictionary <string, object>)local2); }
public void SetSettings(MyObjectBuilder_SessionSettings settings) { m_onlineMode.SelectItemByKey((int)settings.OnlineMode); m_environment.SelectItemByKey((int)settings.EnvironmentHostility); m_worldSizeCombo.SelectItemByKey((int)WorldSizeEnumKey(settings.WorldSizeKm)); m_spawnShipTimeCombo.SelectItemByKey((int)(settings.SpawnShipTimeMultiplier * 10)); m_viewDistanceCombo.SelectItemByKey((int)ViewDistanceEnumKey(settings.ViewDistance)); m_soundModeCombo.SelectItemByKey(settings.RealisticSound ? (int)MySoundModeEnum.Realistic : (int)MySoundModeEnum.Arcade); if (m_physicsOptionsCombo.TryGetItemByKey(settings.PhysicsIterations) != null) m_physicsOptionsCombo.SelectItemByKey(settings.PhysicsIterations); else m_physicsOptionsCombo.SelectItemByKey((int)MyPhysicsPerformanceEnum.Fast); m_autoHealing.IsChecked = settings.AutoHealing; m_clientCanSave.IsChecked = settings.ClientCanSave; m_cargoShipsEnabled.IsChecked = settings.CargoShipsEnabled; m_enableCopyPaste.IsChecked = settings.EnableCopyPaste; m_enableSpectator.IsChecked = settings.EnableSpectator; m_resetOwnership.IsChecked = settings.ResetOwnership; m_permanentDeath.IsChecked = settings.PermanentDeath.Value; m_destructibleBlocks.IsChecked = settings.DestructibleBlocks; m_enableEncounters.IsChecked = settings.EnableEncounters; m_enable3rdPersonCamera.IsChecked = settings.Enable3rdPersonView; m_enableIngameScripts.IsChecked = settings.EnableIngameScripts; m_enableToolShake.IsChecked = settings.EnableToolShake; m_showPlayerNamesOnHud.IsChecked = settings.ShowPlayerNamesOnHud; m_thrusterDamage.IsChecked = settings.ThrusterDamage; m_weaponsEnabled.IsChecked = settings.WeaponsEnabled; m_trashRemoval.IsChecked = settings.RemoveTrash; m_enableOxygen.IsChecked = settings.EnableOxygen; if (settings.VoxelGeneratorVersion < MyVoxelConstants.VOXEL_GENERATOR_MIN_ICE_VERSION) { m_showWarningForOxygen = true; } m_disableRespawnShips.IsChecked = settings.DisableRespawnShips; m_respawnShipDelete.IsChecked = settings.RespawnShipDelete; m_stationVoxelSupport.IsChecked = settings.EnableStationVoxelSupport; m_enableSunRotation.IsChecked = settings.EnableSunRotation; m_enableJetpack.IsChecked = settings.EnableJetpack; m_spawnWithTools.IsChecked = settings.SpawnWithTools; m_startInRespawnScreen.IsChecked = settings.StartInRespawnScreen; m_sunRotationIntervalSlider.Enabled = m_enableSunRotation.IsChecked; m_sunRotationPeriodValue.Visible = m_enableSunRotation.IsChecked; m_sunRotationIntervalSlider.Value = MathHelper.Clamp(MathHelper.InterpLogInv((float)settings.SunRotationIntervalMinutes, MIN_DAY_TIME_MINUTES, MAX_DAY_TIME_MINUTES), 0, 1); m_maxPlayersSlider.Value = settings.MaxPlayers; m_maxFloatingObjectsSlider.Value = settings.MaxFloatingObjects; m_enableVoxelDestruction.IsChecked = settings.EnableVoxelDestruction; CheckButton(settings.AssemblerSpeedMultiplier, m_assembler_x1, m_assembler_x3, m_assembler_x10); CheckButton(settings.InventorySizeMultiplier, m_inventory_x1, m_inventory_x3, m_inventory_x10); CheckButton(settings.RefinerySpeedMultiplier, m_refinery_x1, m_refinery_x3, m_refinery_x10); CheckButton(settings.WelderSpeedMultiplier, m_welder_x1, m_welder_half, m_welder_x2, m_welder_x5); CheckButton(settings.GrinderSpeedMultiplier, m_grinder_x1, m_grinder_half, m_grinder_x2, m_grinder_x5); UpdateSurvivalState(settings.GameMode == MyGameModeEnum.Survival); }
private void startTypeRadio_CheckedChanged(object sender, EventArgs e) { if (!m_canChangeStartType) { return; } startGameButton.Enabled = true; tableLayoutPanel1.Show(); newGameSettingsPanel.Show(); if (loadGameButton.Checked) { if (MyFakes.ENABLE_BATTLE_SYSTEM) { FillWorldsList(); } if (gamesListBox.Items.Count > 0) { gamesListBox.Enabled = true; //tableLayoutPanel1.Enabled = false; newGameSettingsPanel.Enabled = false; if (gamesListBox.SelectedIndex == -1) { gamesListBox.SelectedIndex = 0; } } else { startGameButton.Checked = true; gamesListBox.Enabled = false; //tableLayoutPanel1.Enabled = true; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; } if (m_selectedSessionSettings != null) { m_selectedSessionSettings.Battle = false; } } else { if (MyFakes.ENABLE_BATTLE_SYSTEM && battleButton.Checked) { FillBattlesList(); tableLayoutPanel1.Hide(); newGameSettingsPanel.Hide(); if (gamesListBox.Items.Count > 0) { gamesListBox.Enabled = true; if (gamesListBox.SelectedIndex == -1) { gamesListBox.SelectedIndex = 0; } } else { startGameButton.Enabled = false; gamesListBox.Enabled = false; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; } if (m_selectedSessionSettings != null) { MyBattleHelper.FillDefaultBattleServerSettings(m_selectedSessionSettings, true); } } else { gamesListBox.SelectedIndex = -1; gamesListBox.Enabled = false; //tableLayoutPanel1.Enabled = true; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; //enable tool shake needs to be true for new world, but false for old saved worlds. m_selectedSessionSettings.EnableToolShake = true; m_selectedSessionSettings.EnableFlora = (MyPerGameSettings.Game == GameEnum.SE_GAME) && MyFakes.ENABLE_PLANETS; m_selectedSessionSettings.EnableSunRotation = MyPerGameSettings.Game == GameEnum.SE_GAME; m_selectedSessionSettings.CargoShipsEnabled = !MyFakes.ENABLE_PLANETS; m_selectedSessionSettings.EnableCyberhounds = false; m_selectedSessionSettings.EnableSpiders = true; m_selectedSessionSettings.Battle = false; } } FillSessionSettingsItems(); }
public void GetSettings(MyObjectBuilder_SessionSettings output) { }
public void GetSettings(MyObjectBuilder_SessionSettings output) { output.FloraDensity = GetFloraDensity(); output.EnableFlora = output.FloraDensity > 0; }
private void SetDefaultValues() { m_scenarioTypesGroup.SelectByKey(0); m_settings = GetDefaultSettings(); m_settings.EnableToolShake = true; m_settings.EnableFlora = (MyPerGameSettings.Game == GameEnum.SE_GAME) && MyFakes.ENABLE_PLANETS; m_settings.EnableSunRotation = MyPerGameSettings.Game == GameEnum.SE_GAME; m_settings.VoxelGeneratorVersion = MyVoxelConstants.VOXEL_GENERATOR_VERSION; m_settings.EnableOxygen = true; m_settings.CargoShipsEnabled = true; m_mods = new List<MyObjectBuilder_Checkpoint.ModItem>(); SetSettingsToControls(); SetDefaultName(); }
/// <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"); }); }
internal static void FixIncorrectSettings(MyObjectBuilder_SessionSettings settings) { var defaultSettings = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_SessionSettings>(); if (settings.RefinerySpeedMultiplier <= 0.0f) settings.RefinerySpeedMultiplier = defaultSettings.RefinerySpeedMultiplier; if (settings.AssemblerSpeedMultiplier <= 0.0f) settings.AssemblerSpeedMultiplier = defaultSettings.AssemblerSpeedMultiplier; if (settings.AssemblerEfficiencyMultiplier <= 0.0f) settings.AssemblerEfficiencyMultiplier = defaultSettings.AssemblerEfficiencyMultiplier; if (settings.InventorySizeMultiplier <= 0.0f) settings.InventorySizeMultiplier = defaultSettings.InventorySizeMultiplier; if (settings.WelderSpeedMultiplier <= 0.0f) settings.WelderSpeedMultiplier = defaultSettings.WelderSpeedMultiplier; if (settings.GrinderSpeedMultiplier <= 0.0f) settings.GrinderSpeedMultiplier = defaultSettings.GrinderSpeedMultiplier; if (settings.HackSpeedMultiplier <= 0.0f) settings.HackSpeedMultiplier = defaultSettings.HackSpeedMultiplier; if (!settings.PermanentDeath.HasValue) settings.PermanentDeath = true; settings.ViewDistance = MathHelper.Clamp(settings.ViewDistance, 1000, 50000); if (Engine.Platform.Game.IsDedicated) { settings.Scenario = false; settings.ScenarioEditMode = false; } if (settings.EnableSpiders.HasValue == false) { settings.EnableSpiders = settings.EnvironmentHostility != MyEnvironmentHostilityEnum.SAFE; } if (settings.EnableCyberhounds.HasValue == false) { settings.EnableCyberhounds = false; } //In case of planets ignore World Size. Null check needed when limit size already exists in a planet save //In that case World Size is ignored until user saves again where World Size becomes unlimited if (Static != null && Static.Scenario != null) { settings.WorldSizeKm = Static.Scenario.HasPlanets ? 0 : settings.WorldSizeKm; } }
public void SetSettings(MyObjectBuilder_SessionSettings settings) { m_onlineMode.SelectItemByKey((int)settings.OnlineMode); m_environment.SelectItemByKey((int)settings.EnvironmentHostility); m_worldSizeCombo.SelectItemByKey((int)WorldSizeEnumKey(settings.WorldSizeKm)); m_spawnShipTimeCombo.SelectItemByKey((int)(settings.SpawnShipTimeMultiplier * 10)); m_viewDistanceCombo.SelectItemByKey((int)ViewDistanceEnumKey(settings.ViewDistance)); m_soundModeCombo.SelectItemByKey(settings.RealisticSound ? (int)MySoundModeEnum.Realistic : (int)MySoundModeEnum.Arcade); m_autoHealing.IsChecked = settings.AutoHealing; m_clientCanSave.IsChecked = settings.ClientCanSave; m_cargoShipsEnabled.IsChecked = settings.CargoShipsEnabled; m_enableCopyPaste.IsChecked = settings.EnableCopyPaste; m_enableSpectator.IsChecked = settings.EnableSpectator; m_resetOwnership.IsChecked = settings.ResetOwnership; m_permanentDeath.IsChecked = settings.PermanentDeath.Value; m_destructibleBlocks.IsChecked = settings.DestructibleBlocks; m_enableEncounters.IsChecked = settings.EnableEncounters; m_enable3rdPersonCamera.IsChecked = settings.Enable3rdPersonView; m_enableIngameScripts.IsChecked = settings.EnableIngameScripts; m_enableToolShake.IsChecked = settings.EnableToolShake; m_showPlayerNamesOnHud.IsChecked = settings.ShowPlayerNamesOnHud; m_thrusterDamage.IsChecked = settings.ThrusterDamage; m_weaponsEnabled.IsChecked = settings.WeaponsEnabled; m_trashRemoval.IsChecked = settings.RemoveTrash; m_enableOxygen.IsChecked = settings.EnableOxygen; if (settings.VoxelGeneratorVersion < MyVoxelConstants.VOXEL_GENERATOR_MIN_ICE_VERSION) { m_showWarningForOxygen = true; } m_respawnShipDelete.IsChecked = settings.RespawnShipDelete; m_maxPlayersSlider.Value = settings.MaxPlayers; m_maxFloatingObjectsSlider.Value = settings.MaxFloatingObjects; CheckButton(settings.AssemblerSpeedMultiplier, m_assembler_x1, m_assembler_x3, m_assembler_x10); CheckButton(settings.InventorySizeMultiplier, m_inventory_x1, m_inventory_x3, m_inventory_x10); CheckButton(settings.RefinerySpeedMultiplier, m_refinery_x1, m_refinery_x3, m_refinery_x10); CheckButton(settings.WelderSpeedMultiplier, m_welder_x1, m_welder_half, m_welder_x2, m_welder_x5); CheckButton(settings.GrinderSpeedMultiplier, m_grinder_x1, m_grinder_half, m_grinder_x2, m_grinder_x5); UpdateSurvivalState(settings.GameMode == MyGameModeEnum.Survival); }
protected virtual MyObjectBuilder_SessionSettings CopySettings(MyObjectBuilder_SessionSettings source) { return(source.Clone() as MyObjectBuilder_SessionSettings); }
private void startTypeRadio_CheckedChanged(object sender, EventArgs e) { if (loadGameButton.Checked) { if (gamesListBox.Items.Count > 0) { gamesListBox.Enabled = true; //tableLayoutPanel1.Enabled = false; newGameSettingsPanel.Enabled = false; if (gamesListBox.SelectedIndex == -1) gamesListBox.SelectedIndex = 0; } else { startGameButton.Checked = true; gamesListBox.Enabled = false; //tableLayoutPanel1.Enabled = true; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; } } else { gamesListBox.SelectedIndex = -1; gamesListBox.Enabled = false; //tableLayoutPanel1.Enabled = true; newGameSettingsPanel.Enabled = true; MySandboxGame.ConfigDedicated.Load(); m_selectedSessionSettings = MySandboxGame.ConfigDedicated.SessionSettings; //enable tool shake needs to be true for new world, but false for old saved worlds. m_selectedSessionSettings.EnableToolShake = true; } FillSessionSettingsItems(); }
public SessionSettingsViewModel(MyObjectBuilder_SessionSettings settings) { _settings = settings; }
public static void LoadBattle(string sessionPath, MyObjectBuilder_Checkpoint checkpoint, ulong checkpointSizeInBytes, MyObjectBuilder_SessionSettings settings) { MyLog.Default.WriteLine("Loading battle session: " + sessionPath); MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Load); Load(sessionPath, checkpoint, checkpointSizeInBytes); Static.Settings = settings; Debug.Assert(Static.Settings.Battle = true); }
// 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"); }
/// <summary> /// Initializes a new single player session and start new game with parameters /// </summary> public static void Start( string name, string description, string password, MyObjectBuilder_SessionSettings settings, List<MyObjectBuilder_Checkpoint.ModItem> mods, MyWorldGenerator.Args generationArgs) { MyLog.Default.WriteLineAndConsole("Starting world " + name); MyEntityContainerEventExtensions.InitEntityEvents(); Static = new MySession(); Static.Name = name; Static.Mods = mods; Static.Description = description; Static.Password = password; Static.Settings = settings; Static.Scenario = generationArgs.Scenario; FixIncorrectSettings(Static.Settings); double radius = settings.WorldSizeKm * 500; //half size if (radius > 0) { Static.WorldBoundaries = new BoundingBoxD(new Vector3D(-radius, -radius, -radius), new Vector3D(radius, radius, radius)); } Static.InGameTime = generationArgs.Scenario.GameDate;//MyObjectBuilder_Checkpoint.DEFAULT_DATE; Static.RequiresDX = generationArgs.Scenario.HasPlanets ? 11 : 9; if (Static.OnlineMode != MyOnlineModeEnum.OFFLINE) StartServerRequest(); Static.IsCameraAwaitingEntity = true; // Find new non existing folder. The game folder name may be different from game name, so we have to // make sure we don't overwrite another save string safeName = MyUtils.StripInvalidChars(name); Static.CurrentPath = MyLocalCache.GetSessionSavesPath(safeName, false, false); while (Directory.Exists(Static.CurrentPath)) { Static.CurrentPath = MyLocalCache.GetSessionSavesPath(safeName + MyUtils.GetRandomInt(int.MaxValue).ToString("########"), false, false); } Static.PrepareBaseSession(mods, generationArgs.Scenario); MySector.EnvironmentDefinition = MyDefinitionManager.Static.GetDefinition<MyEnvironmentDefinition>(generationArgs.Scenario.Environment); MyWorldGenerator.GenerateWorld(generationArgs); if (Sync.IsServer) { // Factions have to be initialized before world is generated/loaded. Static.InitializeFactions(); } if (!Engine.Platform.Game.IsDedicated) { var playerId = new MyPlayer.PlayerId(Sync.MyId, 0); MyToolBarCollection.RequestCreateToolbar(playerId); } Static.SendSessionStartStats(); var scenarioName = generationArgs.Scenario.DisplayNameText.ToString(); Static.LogSettings(scenarioName, generationArgs.AsteroidAmount); if (generationArgs.Scenario.SunDirection.IsValid()) { MySector.SunProperties.SunDirectionNormalized = Vector3.Normalize(generationArgs.Scenario.SunDirection); MySector.SunProperties.BaseSunDirectionNormalized = Vector3.Normalize(generationArgs.Scenario.SunDirection); } //Because blocks fills SubBlocks in this method.. //TODO: Create LoadPhase2 MyEntities.UpdateOnceBeforeFrame(); Static.BeforeStartComponents(); Static.Save(); MyLocalCache.SaveLastLoadedTime(Static.CurrentPath, DateTime.Now); // Initialize Spectator light MySpectatorCameraController.Static.InitLight(false); }
/// <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"); }); }
protected virtual MyObjectBuilder_SessionSettings CopySettings(MyObjectBuilder_SessionSettings source) { return source.Clone() as MyObjectBuilder_SessionSettings; }
protected virtual Dictionary <string, object> GetGameplayStartData(MyGameEntryEnum entry, MyObjectBuilder_SessionSettings settings) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); try { dictionary["entry"] = entry.ToString(); dictionary["game_mode"] = settings.GameMode.ToString(); dictionary["online_mode"] = settings.OnlineMode.ToString(); dictionary["world_type"] = MySession.Static.Scenario.Id.SubtypeName; dictionary["worldName"] = MySession.Static.Name; dictionary["server_is_dedicated"] = (MyMultiplayer.Static == null) ? ((object)0) : ((object)MyMultiplayer.Static.HostName.Equals("Dedicated server")); dictionary["server_name"] = (MyMultiplayer.Static != null) ? MyMultiplayer.Static.HostName : MySession.Static.LocalHumanPlayer.DisplayName; dictionary["server_max_number_of_players"] = (MyMultiplayer.Static != null) ? MyMultiplayer.Static.MemberLimit : 1; dictionary["server_current_number_of_players"] = (MyMultiplayer.Static != null) ? MyMultiplayer.Static.MemberCount : 1; dictionary["is_hosting_player"] = (MyMultiplayer.Static != null) ? ((object)MyMultiplayer.Static.IsServer) : ((object)1); if (MyMultiplayer.Static == null) { dictionary["multiplayer_type"] = "Off-line"; } else if (((MySession.Static == null) || (MySession.Static.LocalCharacter == null)) || !MyMultiplayer.Static.HostName.Equals(MySession.Static.LocalCharacter.DisplayNameText)) { dictionary["multiplayer_type"] = !MyMultiplayer.Static.HostName.Equals("Dedicated server") ? "Client" : "Dedicated server"; } else { dictionary["multiplayer_type"] = "Host"; } dictionary["active_mods"] = GetModList(); dictionary["active_mods_count"] = MySession.Static.Mods.Count; long num = (long)Math.Ceiling((DateTime.UtcNow - this.m_loadingStartedAt).TotalSeconds); dictionary["loading_duration"] = num; } catch (Exception exception) { dictionary["failed_to_get_data"] = exception.Message + "\n" + exception.StackTrace; } return(dictionary); }
private void SetDefaultValues() { m_scenarioTypesGroup.SelectByKey(0); m_settings = GetDefaultSettings(); m_settings.EnableToolShake = true; m_settings.VoxelGeneratorVersion = MyVoxelConstants.VOXEL_GENERATOR_VERSION; m_settings.EnableOxygen = true; m_mods = new List<MyObjectBuilder_Checkpoint.ModItem>(); SetSettingsToControls(); SetDefaultName(); }
private void gamesListBox_SelectedIndexChanged(object sender, EventArgs e) { if (gamesListBox.SelectedIndex != -1) { ulong sizeInBytes; WorldItem worldItem = (WorldItem)gamesListBox.Items[gamesListBox.SelectedIndex]; ((MyConfigDedicated<MyObjectBuilder_SessionSettings>)MySandboxGame.ConfigDedicated).LoadWorld = worldItem.SessionPath; var loadPath = worldItem.SessionPath; MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(loadPath, out sizeInBytes); m_selectedSessionSettings = checkpoint.Settings; MySandboxGame.ConfigDedicated.Mods.Clear(); foreach (var mod in checkpoint.Mods) { if (mod.PublishedFileId != 0) { MySandboxGame.ConfigDedicated.Mods.Add(mod.PublishedFileId); } } modIdsTextBox.Text = string.Join(Environment.NewLine, MySandboxGame.ConfigDedicated.Mods.ToArray()); FillSessionSettingsItems(); } }
public static void SetProceduralSettings(int? asteroidAmount, MyObjectBuilder_SessionSettings sessionSettings) { sessionSettings.ProceduralSeed = MyRandom.Instance.Next(); switch ((MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum)asteroidAmount) { case MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum.ProceduralLow: sessionSettings.ProceduralDensity = 0.25f; break; case MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum.ProceduralNormal: sessionSettings.ProceduralDensity = 0.35f; break; case MyGuiScreenWorldGeneratorSettings.AsteroidAmountEnum.ProceduralHigh: sessionSettings.ProceduralDensity = 0.50f; break; default: throw new InvalidBranchException(); break; } }
public void GetSettings(MyObjectBuilder_SessionSettings output) { output.OnlineMode = (MyOnlineModeEnum)m_onlineMode.GetSelectedKey(); output.EnvironmentHostility = (MyEnvironmentHostilityEnum)m_environment.GetSelectedKey(); output.AutoHealing = m_autoHealing.IsChecked; output.ClientCanSave = m_clientCanSave.IsChecked; output.CargoShipsEnabled = m_cargoShipsEnabled.IsChecked; output.EnableCopyPaste = m_enableCopyPaste.IsChecked; output.EnableSpectator = m_enableSpectator.IsChecked; output.ResetOwnership = m_resetOwnership.IsChecked; output.PermanentDeath = m_permanentDeath.IsChecked; output.DestructibleBlocks = m_destructibleBlocks.IsChecked; output.EnableIngameScripts = m_enableIngameScripts.IsChecked; output.Enable3rdPersonView = m_enable3rdPersonCamera.IsChecked; output.EnableEncounters = m_enableEncounters.IsChecked; output.EnableToolShake = m_enableToolShake.IsChecked; output.ShowPlayerNamesOnHud = m_showPlayerNamesOnHud.IsChecked; output.ThrusterDamage = m_thrusterDamage.IsChecked; output.WeaponsEnabled = m_weaponsEnabled.IsChecked; output.RemoveTrash = m_trashRemoval.IsChecked; output.EnableOxygen = m_enableOxygen.IsChecked; if (output.EnableOxygen && output.VoxelGeneratorVersion < MyVoxelConstants.VOXEL_GENERATOR_MIN_ICE_VERSION) { output.VoxelGeneratorVersion = MyVoxelConstants.VOXEL_GENERATOR_MIN_ICE_VERSION; } output.RespawnShipDelete = m_respawnShipDelete.IsChecked; output.EnableStationVoxelSupport = m_stationVoxelSupport.IsChecked; output.DisableRespawnShips = m_disableRespawnShips.IsChecked; output.EnableSunRotation = m_enableSunRotation.IsChecked; output.EnableJetpack = m_enableJetpack.IsChecked; output.SpawnWithTools = m_spawnWithTools.IsChecked; output.StartInRespawnScreen = m_startInRespawnScreen.IsChecked; output.EnableVoxelDestruction = m_enableVoxelDestruction.IsChecked; output.MaxPlayers = (short)m_maxPlayersSlider.Value; output.MaxFloatingObjects = (short)m_maxFloatingObjectsSlider.Value; output.SunRotationIntervalMinutes = MathHelper.Clamp(MathHelper.InterpLog(m_sunRotationIntervalSlider.Value, MIN_DAY_TIME_MINUTES, MAX_DAY_TIME_MINUTES), MIN_DAY_TIME_MINUTES, MAX_DAY_TIME_MINUTES); output.AssemblerEfficiencyMultiplier = GetAssemblerMultiplier(); output.AssemblerSpeedMultiplier = GetAssemblerMultiplier(); output.InventorySizeMultiplier = GetInventoryMultiplier(); output.RefinerySpeedMultiplier = GetRefineryMultiplier(); output.WelderSpeedMultiplier = GetWelderMultiplier(); output.GrinderSpeedMultiplier = GetGrinderMultiplier(); output.SpawnShipTimeMultiplier = GetSpawnShipTimeMultiplier(); output.WorldSizeKm = GetWorldSize(); output.ViewDistance = GetViewDistance(); output.RealisticSound = ((MySoundModeEnum)m_soundModeCombo.GetSelectedKey() == MySoundModeEnum.Realistic); output.PhysicsIterations = (int)m_physicsOptionsCombo.GetSelectedKey(); output.GameMode = GetGameMode(); }
public void GetSettings(MyObjectBuilder_SessionSettings settings) { //settings.CanJoinRunning= }
public SessionSettingsViewModel() { _settings = new MyObjectBuilder_SessionSettings(); }