diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs index 2e20b2f954..532ea9796d 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs @@ -46,13 +46,41 @@ public sealed partial class ShuttleSystem private const float ShuttleSpawnBuffer = 1f; + private bool _emergencyShuttleEnabled; + private void InitializeEscape() { +#if !FULL_RELEASE + _configManager.OverrideDefault(CCVars.EmergencyShuttleEnabled, false); +#endif + _emergencyShuttleEnabled = _configManager.GetCVar(CCVars.EmergencyShuttleEnabled); + // Don't immediately invoke as roundstart will just handle it. + _configManager.OnValueChanged(CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled); SubscribeLocalEvent(OnRoundStart); SubscribeLocalEvent(OnStationStartup); SubscribeNetworkEvent(OnShuttleRequestPosition); } + private void SetEmergencyShuttleEnabled(bool value) + { + if (_emergencyShuttleEnabled == value) return; + _emergencyShuttleEnabled = value; + + if (value) + { + SetupEmergencyShuttle(); + } + else + { + CleanupEmergencyShuttle(); + } + } + + private void ShutdownEscape() + { + _configManager.UnsubValueChanged(CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled); + } + /// /// If the client is requesting debug info on where an emergency shuttle would dock. /// @@ -343,7 +371,7 @@ public sealed partial class ShuttleSystem private void OnRoundStart(RoundStartingEvent ev) { - Setup(); + SetupEmergencyShuttle(); } /// @@ -353,6 +381,12 @@ public sealed partial class ShuttleSystem { if (EmergencyShuttleArrived) return; + if (!_emergencyShuttleEnabled) + { + _roundEnd.EndRound(); + return; + } + _consoleAccumulator = _configManager.GetCVar(CCVars.EmergencyShuttleDockTime); EmergencyShuttleArrived = true; @@ -402,9 +436,9 @@ public sealed partial class ShuttleSystem return result; } - private void Setup() + private void SetupEmergencyShuttle() { - if (_centcommMap != null && _mapManager.MapExists(_centcommMap.Value)) return; + if (!_emergencyShuttleEnabled || _centcommMap != null && _mapManager.MapExists(_centcommMap.Value)) return; _centcommMap = _mapManager.CreateMap(); _mapManager.SetMapPaused(_centcommMap.Value, true); @@ -421,7 +455,7 @@ public sealed partial class ShuttleSystem private void AddEmergencyShuttle(StationDataComponent component) { - if (_centcommMap == null || component.EmergencyShuttle != null) return; + if (!_emergencyShuttleEnabled || _centcommMap == null || component.EmergencyShuttle != null) return; // Load escape shuttle var (_, shuttle) = _loader.LoadBlueprint(_centcommMap.Value, component.EmergencyShuttlePath.ToString(), new MapLoadOptions() @@ -442,6 +476,12 @@ public sealed partial class ShuttleSystem private void CleanupEmergencyShuttle() { + // If we get cleaned up mid roundend just end it. + if (_launchedShuttles) + { + _roundEnd.EndRound(); + } + _shuttleIndex = 0f; if (_centcommMap == null || !_mapManager.MapExists(_centcommMap.Value)) diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.cs index 1eff3a3c76..a6d5e63a2d 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.cs @@ -81,6 +81,7 @@ namespace Content.Server.Shuttles.Systems public override void Shutdown() { base.Shutdown(); + ShutdownEscape(); ShutdownEmergencyConsole(); _configManager.UnsubValueChanged(CCVars.ShuttleMaxLinearSpeed, SetShuttleMaxLinearSpeed); _configManager.UnsubValueChanged(CCVars.ShuttleMaxAngularSpeed, SetShuttleMaxAngularSpeed); diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 872c020548..b0d706186f 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -928,6 +928,12 @@ namespace Content.Shared.CCVar public static readonly CVarDef EmergencyShuttleTransitTime = CVarDef.Create("shuttle.emergency_transit_time", 120f, CVar.SERVERONLY); + /// + /// Whether the emergency shuttle is enabled or should the round just end. + /// + public static readonly CVarDef EmergencyShuttleEnabled = + CVarDef.Create("shuttle.emergency_enabled", true, CVar.SERVERONLY); + /* * VIEWPORT */