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

@@ -41,7 +41,6 @@ namespace Content.Server.RoundEnd
/// Countdown to use where there is no station alert countdown to be found.
/// </summary>
public TimeSpan DefaultCountdownDuration { get; set; } = TimeSpan.FromMinutes(10);
public TimeSpan DefaultRestartRoundDuration { get; set; } = TimeSpan.FromMinutes(2);
private CancellationTokenSource? _countdownTokenSource = null;
private CancellationTokenSource? _cooldownTokenSource = null;
@@ -211,8 +210,26 @@ namespace Content.Server.RoundEnd
_gameTicker.EndRound();
_countdownTokenSource?.Cancel();
_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()