Disable emergency shuttles locally (#9195)

Can still re-enable via cvar but this is to make devving faster.
This commit is contained in:
metalgearsloth
2022-06-27 15:19:40 +10:00
committed by GitHub
parent 8a6d914586
commit 12e5cdacae
3 changed files with 51 additions and 4 deletions

View File

@@ -46,13 +46,41 @@ public sealed partial class ShuttleSystem
private const float ShuttleSpawnBuffer = 1f; private const float ShuttleSpawnBuffer = 1f;
private bool _emergencyShuttleEnabled;
private void InitializeEscape() 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<RoundStartingEvent>(OnRoundStart); SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart);
SubscribeLocalEvent<StationDataComponent, ComponentStartup>(OnStationStartup); SubscribeLocalEvent<StationDataComponent, ComponentStartup>(OnStationStartup);
SubscribeNetworkEvent<EmergencyShuttleRequestPositionMessage>(OnShuttleRequestPosition); SubscribeNetworkEvent<EmergencyShuttleRequestPositionMessage>(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);
}
/// <summary> /// <summary>
/// If the client is requesting debug info on where an emergency shuttle would dock. /// If the client is requesting debug info on where an emergency shuttle would dock.
/// </summary> /// </summary>
@@ -343,7 +371,7 @@ public sealed partial class ShuttleSystem
private void OnRoundStart(RoundStartingEvent ev) private void OnRoundStart(RoundStartingEvent ev)
{ {
Setup(); SetupEmergencyShuttle();
} }
/// <summary> /// <summary>
@@ -353,6 +381,12 @@ public sealed partial class ShuttleSystem
{ {
if (EmergencyShuttleArrived) return; if (EmergencyShuttleArrived) return;
if (!_emergencyShuttleEnabled)
{
_roundEnd.EndRound();
return;
}
_consoleAccumulator = _configManager.GetCVar(CCVars.EmergencyShuttleDockTime); _consoleAccumulator = _configManager.GetCVar(CCVars.EmergencyShuttleDockTime);
EmergencyShuttleArrived = true; EmergencyShuttleArrived = true;
@@ -402,9 +436,9 @@ public sealed partial class ShuttleSystem
return result; 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(); _centcommMap = _mapManager.CreateMap();
_mapManager.SetMapPaused(_centcommMap.Value, true); _mapManager.SetMapPaused(_centcommMap.Value, true);
@@ -421,7 +455,7 @@ public sealed partial class ShuttleSystem
private void AddEmergencyShuttle(StationDataComponent component) private void AddEmergencyShuttle(StationDataComponent component)
{ {
if (_centcommMap == null || component.EmergencyShuttle != null) return; if (!_emergencyShuttleEnabled || _centcommMap == null || component.EmergencyShuttle != null) return;
// Load escape shuttle // Load escape shuttle
var (_, shuttle) = _loader.LoadBlueprint(_centcommMap.Value, component.EmergencyShuttlePath.ToString(), new MapLoadOptions() var (_, shuttle) = _loader.LoadBlueprint(_centcommMap.Value, component.EmergencyShuttlePath.ToString(), new MapLoadOptions()
@@ -442,6 +476,12 @@ public sealed partial class ShuttleSystem
private void CleanupEmergencyShuttle() private void CleanupEmergencyShuttle()
{ {
// If we get cleaned up mid roundend just end it.
if (_launchedShuttles)
{
_roundEnd.EndRound();
}
_shuttleIndex = 0f; _shuttleIndex = 0f;
if (_centcommMap == null || !_mapManager.MapExists(_centcommMap.Value)) if (_centcommMap == null || !_mapManager.MapExists(_centcommMap.Value))

View File

@@ -81,6 +81,7 @@ namespace Content.Server.Shuttles.Systems
public override void Shutdown() public override void Shutdown()
{ {
base.Shutdown(); base.Shutdown();
ShutdownEscape();
ShutdownEmergencyConsole(); ShutdownEmergencyConsole();
_configManager.UnsubValueChanged(CCVars.ShuttleMaxLinearSpeed, SetShuttleMaxLinearSpeed); _configManager.UnsubValueChanged(CCVars.ShuttleMaxLinearSpeed, SetShuttleMaxLinearSpeed);
_configManager.UnsubValueChanged(CCVars.ShuttleMaxAngularSpeed, SetShuttleMaxAngularSpeed); _configManager.UnsubValueChanged(CCVars.ShuttleMaxAngularSpeed, SetShuttleMaxAngularSpeed);

View File

@@ -928,6 +928,12 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<float> EmergencyShuttleTransitTime = public static readonly CVarDef<float> EmergencyShuttleTransitTime =
CVarDef.Create("shuttle.emergency_transit_time", 120f, CVar.SERVERONLY); CVarDef.Create("shuttle.emergency_transit_time", 120f, CVar.SERVERONLY);
/// <summary>
/// Whether the emergency shuttle is enabled or should the round just end.
/// </summary>
public static readonly CVarDef<bool> EmergencyShuttleEnabled =
CVarDef.Create("shuttle.emergency_enabled", true, CVar.SERVERONLY);
/* /*
* VIEWPORT * VIEWPORT
*/ */