await server.WaitAssertion(() =>
{
config.SetCVar(CCVars.GameLobbyEnabled, true);
- config.SetCVar(CCVars.EmergencyShuttleTransitTime, 1f);
+ config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, 1f);
config.SetCVar(CCVars.EmergencyShuttleDockTime, 1f);
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(100);
await server.WaitAssertion(() =>
{
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);
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromSeconds(30);
private readonly TimeSpan _bufferTime = TimeSpan.FromSeconds(5);
/// <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>
public float TransitTime { get; private set; }
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);
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, ComponentStartup>(OnEmergencyStartup);
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, EmergencyShuttleAuthorizeMessage>(OnEmergencyAuthorize);
_authorizeTime = obj;
}
- private void SetTransitTime(float obj)
+ private void SetMinTransitTime(float obj)
+ {
+ MinimumTransitTime = obj;
+ MaximumTransitTime = Math.Max(MaximumTransitTime, MinimumTransitTime);
+ }
+
+ private void SetMaxTransitTime(float obj)
{
- TransitTime = obj;
+ MaximumTransitTime = Math.Max(MinimumTransitTime, obj);
}
private void ShutdownEmergencyConsole()
{
_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)
_consoleAccumulator = float.MinValue;
EarlyLaunchAuthorized = false;
EmergencyShuttleArrived = false;
+ TransitTime = MinimumTransitTime + (MaximumTransitTime - MinimumTransitTime) * _random.NextFloat();
+ // Round to nearest 10
+ TransitTime = MathF.Round(TransitTime / 10f) * 10f;
}
private void UpdateAllEmergencyConsoles()
CVarDef.Create("shuttle.emergency_authorize_time", 10f, CVar.SERVERONLY);
/// <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>
+ public static readonly CVarDef<float> EmergencyShuttleMinTransitTime =
+ 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> EmergencyShuttleTransitTime =
- CVarDef.Create("shuttle.emergency_transit_time", 60f, CVar.SERVERONLY);
+ public static readonly CVarDef<float> EmergencyShuttleMaxTransitTime =
+ CVarDef.Create("shuttle.emergency_transit_time_max", 180f, 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);
+ CVarDef.Create("shuttle.emergency", true, CVar.SERVERONLY);
/// <summary>
/// The percentage of time passed from the initial call to when the shuttle can no longer be recalled.