Random emergency shuttle time (#10047)
* Random emergency shuttle time 60 to 180 seconds. Rounds up to nearest 10. All other FTL will go to the default of 30s. * fix
This commit is contained in:
@@ -32,7 +32,7 @@ namespace Content.IntegrationTests.Tests
|
|||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
config.SetCVar(CCVars.GameLobbyEnabled, true);
|
config.SetCVar(CCVars.GameLobbyEnabled, true);
|
||||||
config.SetCVar(CCVars.EmergencyShuttleTransitTime, 1f);
|
config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, 1f);
|
||||||
config.SetCVar(CCVars.EmergencyShuttleDockTime, 1f);
|
config.SetCVar(CCVars.EmergencyShuttleDockTime, 1f);
|
||||||
|
|
||||||
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(100);
|
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(100);
|
||||||
@@ -116,7 +116,7 @@ namespace Content.IntegrationTests.Tests
|
|||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
config.SetCVar(CCVars.GameLobbyEnabled, false);
|
config.SetCVar(CCVars.GameLobbyEnabled, false);
|
||||||
config.SetCVar(CCVars.EmergencyShuttleTransitTime, CCVars.EmergencyShuttleTransitTime.DefaultValue);
|
config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, CCVars.EmergencyShuttleMinTransitTime.DefaultValue);
|
||||||
config.SetCVar(CCVars.EmergencyShuttleDockTime, CCVars.EmergencyShuttleDockTime.DefaultValue);
|
config.SetCVar(CCVars.EmergencyShuttleDockTime, CCVars.EmergencyShuttleDockTime.DefaultValue);
|
||||||
|
|
||||||
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromSeconds(30);
|
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromSeconds(30);
|
||||||
|
|||||||
@@ -41,7 +41,17 @@ public sealed partial class EmergencyShuttleSystem
|
|||||||
private readonly TimeSpan _bufferTime = TimeSpan.FromSeconds(5);
|
private readonly TimeSpan _bufferTime = TimeSpan.FromSeconds(5);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="CCVars.EmergencyShuttleTransitTime"/>
|
/// <see cref="CCVars.EmergencyShuttleMinTransitTime"/>
|
||||||
|
/// </summary>
|
||||||
|
public float MinimumTransitTime { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <see cref="CCVars.EmergencyShuttleMaxTransitTime"/>
|
||||||
|
/// </summary>
|
||||||
|
public float MaximumTransitTime { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long it will take for the emergency shuttle to arrive at CentComm.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float TransitTime { get; private set; }
|
public float TransitTime { get; private set; }
|
||||||
|
|
||||||
@@ -69,7 +79,8 @@ public sealed partial class EmergencyShuttleSystem
|
|||||||
|
|
||||||
private void InitializeEmergencyConsole()
|
private void InitializeEmergencyConsole()
|
||||||
{
|
{
|
||||||
_configManager.OnValueChanged(CCVars.EmergencyShuttleTransitTime, SetTransitTime, true);
|
_configManager.OnValueChanged(CCVars.EmergencyShuttleMinTransitTime, SetMinTransitTime, true);
|
||||||
|
_configManager.OnValueChanged(CCVars.EmergencyShuttleMaxTransitTime, SetMaxTransitTime, true);
|
||||||
_configManager.OnValueChanged(CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime, true);
|
_configManager.OnValueChanged(CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime, true);
|
||||||
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, ComponentStartup>(OnEmergencyStartup);
|
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, ComponentStartup>(OnEmergencyStartup);
|
||||||
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, EmergencyShuttleAuthorizeMessage>(OnEmergencyAuthorize);
|
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, EmergencyShuttleAuthorizeMessage>(OnEmergencyAuthorize);
|
||||||
@@ -95,15 +106,22 @@ public sealed partial class EmergencyShuttleSystem
|
|||||||
_authorizeTime = obj;
|
_authorizeTime = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetTransitTime(float obj)
|
private void SetMinTransitTime(float obj)
|
||||||
{
|
{
|
||||||
TransitTime = obj;
|
MinimumTransitTime = obj;
|
||||||
|
MaximumTransitTime = Math.Max(MaximumTransitTime, MinimumTransitTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetMaxTransitTime(float obj)
|
||||||
|
{
|
||||||
|
MaximumTransitTime = Math.Max(MinimumTransitTime, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShutdownEmergencyConsole()
|
private void ShutdownEmergencyConsole()
|
||||||
{
|
{
|
||||||
_configManager.UnsubValueChanged(CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime);
|
_configManager.UnsubValueChanged(CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime);
|
||||||
_configManager.UnsubValueChanged(CCVars.EmergencyShuttleTransitTime, SetTransitTime);
|
_configManager.UnsubValueChanged(CCVars.EmergencyShuttleMinTransitTime, SetMinTransitTime);
|
||||||
|
_configManager.UnsubValueChanged(CCVars.EmergencyShuttleMaxTransitTime, SetMaxTransitTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEmergencyStartup(EntityUid uid, EmergencyShuttleConsoleComponent component, ComponentStartup args)
|
private void OnEmergencyStartup(EntityUid uid, EmergencyShuttleConsoleComponent component, ComponentStartup args)
|
||||||
@@ -283,6 +301,9 @@ public sealed partial class EmergencyShuttleSystem
|
|||||||
_consoleAccumulator = float.MinValue;
|
_consoleAccumulator = float.MinValue;
|
||||||
EarlyLaunchAuthorized = false;
|
EarlyLaunchAuthorized = false;
|
||||||
EmergencyShuttleArrived = false;
|
EmergencyShuttleArrived = false;
|
||||||
|
TransitTime = MinimumTransitTime + (MaximumTransitTime - MinimumTransitTime) * _random.NextFloat();
|
||||||
|
// Round to nearest 10
|
||||||
|
TransitTime = MathF.Round(TransitTime / 10f) * 10f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAllEmergencyConsoles()
|
private void UpdateAllEmergencyConsoles()
|
||||||
|
|||||||
@@ -1108,16 +1108,22 @@ namespace Content.Shared.CCVar
|
|||||||
CVarDef.Create("shuttle.emergency_authorize_time", 10f, CVar.SERVERONLY);
|
CVarDef.Create("shuttle.emergency_authorize_time", 10f, CVar.SERVERONLY);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How long after the console is authorized for the shuttle to early launch.
|
/// The minimum time for the emergency shuttle to arrive at centcomm.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly CVarDef<float> EmergencyShuttleTransitTime =
|
public static readonly CVarDef<float> EmergencyShuttleMinTransitTime =
|
||||||
CVarDef.Create("shuttle.emergency_transit_time", 60f, CVar.SERVERONLY);
|
CVarDef.Create("shuttle.emergency_transit_time_min", 60f, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum time for the emergency shuttle to arrive at centcomm.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<float> EmergencyShuttleMaxTransitTime =
|
||||||
|
CVarDef.Create("shuttle.emergency_transit_time_max", 180f, CVar.SERVERONLY);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the emergency shuttle is enabled or should the round just end.
|
/// Whether the emergency shuttle is enabled or should the round just end.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly CVarDef<bool> EmergencyShuttleEnabled =
|
public static readonly CVarDef<bool> EmergencyShuttleEnabled =
|
||||||
CVarDef.Create("shuttle.emergency_enabled", true, CVar.SERVERONLY);
|
CVarDef.Create("shuttle.emergency", true, CVar.SERVERONLY);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The percentage of time passed from the initial call to when the shuttle can no longer be recalled.
|
/// The percentage of time passed from the initial call to when the shuttle can no longer be recalled.
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ preload = false
|
|||||||
# Wastes startup time
|
# Wastes startup time
|
||||||
auto_call_time = 0
|
auto_call_time = 0
|
||||||
cargo = false
|
cargo = false
|
||||||
emergency_enabled = false
|
emergency = false
|
||||||
arrivals = false
|
arrivals = false
|
||||||
|
|||||||
Reference in New Issue
Block a user