diff --git a/Content.IntegrationTests/Tests/GameRules/NukeOpsTest.cs b/Content.IntegrationTests/Tests/GameRules/NukeOpsTest.cs index d88a213c33..509222de9c 100644 --- a/Content.IntegrationTests/Tests/GameRules/NukeOpsTest.cs +++ b/Content.IntegrationTests/Tests/GameRules/NukeOpsTest.cs @@ -1,6 +1,7 @@ #nullable enable using System.Linq; using Content.Server._Sunrise.StationCentComm; +using Content.Server._Sunrise.TransitHub; using Content.Server.Body.Components; using Content.Server.GameTicking; using Content.Server.GameTicking.Presets; @@ -78,7 +79,7 @@ public sealed class NukeOpsTest Assert.That(entMan.Count(), Is.Zero); Assert.That(entMan.Count(), Is.Zero); Assert.That(entMan.Count(), Is.Zero); - Assert.That(entMan.Count(), Is.Zero); // Sunrise-Edit + Assert.That(entMan.Count(), Is.Zero); // Sunrise-Edit // And no nukie related components Assert.That(entMan.Count(), Is.Zero); @@ -106,7 +107,7 @@ public sealed class NukeOpsTest // Maps now exist Assert.That(entMan.Count(), Is.GreaterThan(0)); Assert.That(entMan.Count(), Is.GreaterThan(0)); - Assert.That(entMan.Count(), Is.EqualTo(1)); + Assert.That(entMan.Count(), Is.EqualTo(1)); // Sunrise-Edit // And we now have nukie related components Assert.That(entMan.Count(), Is.EqualTo(1)); diff --git a/Content.Server/GameTicking/Commands/ForcePresetCommand.cs b/Content.Server/GameTicking/Commands/ForcePresetCommand.cs index 8d33d4d295..d7346f78ad 100644 --- a/Content.Server/GameTicking/Commands/ForcePresetCommand.cs +++ b/Content.Server/GameTicking/Commands/ForcePresetCommand.cs @@ -7,7 +7,7 @@ using Robust.Shared.Prototypes; namespace Content.Server.GameTicking.Commands { - [AdminCommand(AdminFlags.Round)] + [AdminCommand(AdminFlags.Host)] sealed class ForcePresetCommand : IConsoleCommand { [Dependency] private readonly IEntityManager _e = default!; @@ -38,14 +38,6 @@ namespace Content.Server.GameTicking.Commands return; } - // Sunrise-Start - if (type.Hide) - { - shell.WriteError(Loc.GetString("set-game-preset-preset-error", ("preset", args[0]))); - return; - } - // Sunrise-End - ticker.SetGamePreset(type, true); shell.WriteLine($"Forced the game to start with preset {name}."); ticker.UpdateInfoText(); @@ -55,19 +47,10 @@ namespace Content.Server.GameTicking.Commands { if (args.Length == 1) { - var gamePresets = IoCManager.Resolve().EnumeratePrototypes() - .OrderBy(p => p.ID); - - // Sunrise-Start - var options = new List(); - foreach (var preset in gamePresets) - { - if (preset.Hide) - continue; - - options.Add(preset.ID); - } - // Sunrise-End + var options = IoCManager.Resolve() + .EnumeratePrototypes() + .OrderBy(p => p.ID) + .Select(p => p.ID); return CompletionResult.FromHintOptions(options, ""); } diff --git a/Content.Server/_Sunrise/PlanetPrison/PlanetPrisonSystem.cs b/Content.Server/_Sunrise/PlanetPrison/PlanetPrisonSystem.cs index 782ae0335c..90d414966d 100644 --- a/Content.Server/_Sunrise/PlanetPrison/PlanetPrisonSystem.cs +++ b/Content.Server/_Sunrise/PlanetPrison/PlanetPrisonSystem.cs @@ -46,7 +46,7 @@ namespace Content.Server._Sunrise.PlanetPrison { if (!TryComp(uid, out var mind) || mind.OwnedEntity == null) return; - if (HasComp(uid)) // don't show both briefings + if (HasComp(uid)) return; args.Append(Loc.GetString("planet-prisoner-role-greeting")); } @@ -54,6 +54,8 @@ namespace Content.Server._Sunrise.PlanetPrison private void OnObjectivesTextPrepend(EntityUid uid, PlanetPrisonRuleComponent comp, ref ObjectivesTextPrependEvent args) { var planetPrisonRule = GetPlanetPrisonRule(); + if (planetPrisonRule == null) + return; args.Text += Loc.GetString("planet-prison-round-end-result", ("count", planetPrisonRule.EscapedPrisoners.Count)); } @@ -71,6 +73,9 @@ namespace Content.Server._Sunrise.PlanetPrison NextTick += RefreshCooldown; var planetPrisonRule = GetPlanetPrisonRule(); + if (planetPrisonRule == null) + return; + var planetPrisonStation = EntityQuery().FirstOrDefault(); if (planetPrisonStation == null || planetPrisonStation.PrisonGrid == EntityUid.Invalid) return; @@ -112,14 +117,16 @@ namespace Content.Server._Sunrise.PlanetPrison } } - public PlanetPrisonRuleComponent GetPlanetPrisonRule() + public PlanetPrisonRuleComponent? GetPlanetPrisonRule() { var planetPrisonRule = EntityQuery().FirstOrDefault(); - if (planetPrisonRule != null) - return planetPrisonRule; + return planetPrisonRule; + } + public PlanetPrisonRuleComponent StartPlanetPrisonRule() + { _gameTicker.StartGameRule(GameRule, out var ruleEntity); - planetPrisonRule = Comp(ruleEntity); + var planetPrisonRule = Comp(ruleEntity); return planetPrisonRule; } @@ -127,12 +134,14 @@ namespace Content.Server._Sunrise.PlanetPrison public bool PrisonerEscaped(EntityUid mind) { var planetPrisonRule = GetPlanetPrisonRule(); + if (planetPrisonRule == null) + return false; return planetPrisonRule.EscapedPrisoners.Contains(mind); } private void OnMindAdded(EntityUid uid, PlanetPrisonerComponent component, MindAddedMessage args) { - var planetPrisonRule = GetPlanetPrisonRule(); + var planetPrisonRule = GetPlanetPrisonRule() ?? StartPlanetPrisonRule(); if (!_mindSystem.TryGetMind(uid, out var mindId, out var mind)) { diff --git a/Content.Server/_Sunrise/RoundEndVote/RoundEndVoteSystem.cs b/Content.Server/_Sunrise/RoundEndVote/RoundEndVoteSystem.cs index e5be2c7700..963aeb6031 100644 --- a/Content.Server/_Sunrise/RoundEndVote/RoundEndVoteSystem.cs +++ b/Content.Server/_Sunrise/RoundEndVote/RoundEndVoteSystem.cs @@ -1,7 +1,9 @@ using Content.Server.GameTicking; using Content.Server.RoundEnd; using Content.Server.Voting.Managers; +using Content.Shared._Sunrise.SunriseCCVars; using Content.Shared.Voting; +using Robust.Shared.Configuration; namespace Content.Server._Sunrise.RoundEndVote; @@ -9,6 +11,7 @@ public sealed class RoundEndVoteSystem : EntitySystem { [Dependency] private readonly GameTicker _gameTicker = default!; [Dependency] private readonly IVoteManager _voteManager = default!; + [Dependency] private readonly IConfigurationManager _cfg = default!; public override void Initialize() { @@ -22,9 +25,13 @@ public sealed class RoundEndVoteSystem : EntitySystem if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby) return; - // Очень жаль - //_voteManager.CreateStandardVote(null, StandardVoteType.Preset); - _voteManager.CreateStandardVote(null, StandardVoteType.Map); - _gameTicker.SetGamePreset("Secret"); + if (_cfg.GetCVar(SunriseCCVars.RunMapVoteAfterRestart)) + _voteManager.CreateStandardVote(null, StandardVoteType.Map); + + if (_cfg.GetCVar(SunriseCCVars.RunPresetVoteAfterRestart)) + _voteManager.CreateStandardVote(null, StandardVoteType.Preset); + + if (_cfg.GetCVar(SunriseCCVars.ResetPresetAfterRestart)) + _gameTicker.SetGamePreset("Secret"); } } diff --git a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs index f528ed4971..cac963ebe1 100644 --- a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs +++ b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs @@ -251,4 +251,14 @@ public sealed class SunriseCCVars public static readonly CVarDef ShowPresetVotes = CVarDef.Create("vote.show_preset_votes", true); public static readonly CVarDef ShowMapVotes = CVarDef.Create("vote.show_map_votes", true); + + public static readonly CVarDef RunMapVoteAfterRestart = CVarDef.Create("vote.run_map_vote_after_restart", false); + + public static readonly CVarDef RunPresetVoteAfterRestart = CVarDef.Create("vote.run_preset_vote_after_restart", false); + + /* + * Preset + */ + + public static readonly CVarDef ResetPresetAfterRestart = CVarDef.Create("game.reset_preset_after_restart", false); }