Add CVar for customizing round restart time (#19136)

Co-authored-by: TsjipTsjip <19798667+TsjipTsjip@users.noreply.github.com>
This commit is contained in:
Arimah Greene
2023-08-16 03:36:50 +02:00
committed by GitHub
parent 627dd6addd
commit 3e464cd1f0
4 changed files with 30 additions and 6 deletions

View File

@@ -34,10 +34,10 @@ namespace Content.IntegrationTests.Tests
config.SetCVar(CCVars.GameLobbyEnabled, true); config.SetCVar(CCVars.GameLobbyEnabled, true);
config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, 1f); config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, 1f);
config.SetCVar(CCVars.EmergencyShuttleDockTime, 1f); config.SetCVar(CCVars.EmergencyShuttleDockTime, 1f);
config.SetCVar(CCVars.RoundRestartTime, 1f);
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(100); roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(100);
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMilliseconds(300); roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMilliseconds(300);
roundEndSystem.DefaultRestartRoundDuration = TimeSpan.FromMilliseconds(100);
}); });
await server.WaitAssertion(() => await server.WaitAssertion(() =>
@@ -131,10 +131,10 @@ namespace Content.IntegrationTests.Tests
config.SetCVar(CCVars.GameLobbyEnabled, false); config.SetCVar(CCVars.GameLobbyEnabled, false);
config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, CCVars.EmergencyShuttleMinTransitTime.DefaultValue); config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, CCVars.EmergencyShuttleMinTransitTime.DefaultValue);
config.SetCVar(CCVars.EmergencyShuttleDockTime, CCVars.EmergencyShuttleDockTime.DefaultValue); config.SetCVar(CCVars.EmergencyShuttleDockTime, CCVars.EmergencyShuttleDockTime.DefaultValue);
config.SetCVar(CCVars.RoundRestartTime, CCVars.RoundRestartTime.DefaultValue);
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromSeconds(30); roundEndSystem.DefaultCooldownDuration = TimeSpan.FromSeconds(30);
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMinutes(4); roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMinutes(4);
roundEndSystem.DefaultRestartRoundDuration = TimeSpan.FromMinutes(1);
ticker.RestartRound(); ticker.RestartRound();
}); });
await PoolManager.ReallyBeIdle(pairTracker.Pair, 10); await PoolManager.ReallyBeIdle(pairTracker.Pair, 10);

View File

@@ -41,7 +41,6 @@ namespace Content.Server.RoundEnd
/// Countdown to use where there is no station alert countdown to be found. /// Countdown to use where there is no station alert countdown to be found.
/// </summary> /// </summary>
public TimeSpan DefaultCountdownDuration { get; set; } = TimeSpan.FromMinutes(10); public TimeSpan DefaultCountdownDuration { get; set; } = TimeSpan.FromMinutes(10);
public TimeSpan DefaultRestartRoundDuration { get; set; } = TimeSpan.FromMinutes(2);
private CancellationTokenSource? _countdownTokenSource = null; private CancellationTokenSource? _countdownTokenSource = null;
private CancellationTokenSource? _cooldownTokenSource = null; private CancellationTokenSource? _cooldownTokenSource = null;
@@ -211,8 +210,26 @@ namespace Content.Server.RoundEnd
_gameTicker.EndRound(); _gameTicker.EndRound();
_countdownTokenSource?.Cancel(); _countdownTokenSource?.Cancel();
_countdownTokenSource = new(); _countdownTokenSource = new();
_chatManager.DispatchServerAnnouncement(Loc.GetString("round-end-system-round-restart-eta-announcement", ("minutes", DefaultRestartRoundDuration.Minutes)));
Timer.Spawn(DefaultRestartRoundDuration, AfterEndRoundRestart, _countdownTokenSource.Token); var countdownTime = TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.RoundRestartTime));
int time;
string unitsLocString;
if (countdownTime.TotalSeconds < 60)
{
time = countdownTime.Seconds;
unitsLocString = "eta-units-seconds";
}
else
{
time = countdownTime.Minutes;
unitsLocString = "eta-units-minutes";
}
_chatManager.DispatchServerAnnouncement(
Loc.GetString(
"round-end-system-round-restart-eta-announcement",
("time", time),
("units", Loc.GetString(unitsLocString))));
Timer.Spawn(countdownTime, AfterEndRoundRestart, _countdownTokenSource.Token);
} }
private void AfterEndRoundRestart() private void AfterEndRoundRestart()

View File

@@ -312,6 +312,13 @@ namespace Content.Shared.CCVar
/// </summary> /// </summary>
public static readonly CVarDef<float> ArtifactRoundEndTimer = CVarDef.Create("game.artifact_round_end_timer", 0.5f, CVar.NOTIFY | CVar.REPLICATED); public static readonly CVarDef<float> ArtifactRoundEndTimer = CVarDef.Create("game.artifact_round_end_timer", 0.5f, CVar.NOTIFY | CVar.REPLICATED);
/// <summary>
/// The time in seconds that the server should wait before restarting the round.
/// Defaults to 2 minutes.
/// </summary>
public static readonly CVarDef<float> RoundRestartTime =
CVarDef.Create("game.round_restart_time", 120f, CVar.SERVERONLY);
/* /*
* Discord * Discord
*/ */

View File

@@ -3,7 +3,7 @@
round-end-system-shuttle-called-announcement = An emergency shuttle has been sent. ETA: {$time} {$units}. round-end-system-shuttle-called-announcement = An emergency shuttle has been sent. ETA: {$time} {$units}.
round-end-system-shuttle-auto-called-announcement = An automatic crew shift change shuttle has been sent. ETA: {$time} {$units}. Recall the shuttle to extend the shift. round-end-system-shuttle-auto-called-announcement = An automatic crew shift change shuttle has been sent. ETA: {$time} {$units}. Recall the shuttle to extend the shift.
round-end-system-shuttle-recalled-announcement = The emergency shuttle has been recalled. round-end-system-shuttle-recalled-announcement = The emergency shuttle has been recalled.
round-end-system-round-restart-eta-announcement = Restarting the round in {$minutes} minutes... round-end-system-round-restart-eta-announcement = Restarting the round in {$time} {$units}...
eta-units-minutes = minutes eta-units-minutes = minutes
eta-units-seconds = seconds eta-units-seconds = seconds