Admin shuttle call button (#4859)

* shuttle call ui

* shuttle call ui

* Localize shuttle commands better.

* localization fix
This commit is contained in:
moonheart08
2021-10-13 12:15:28 -05:00
committed by GitHub
parent dfe500a8bb
commit 9250bd62cb
9 changed files with 128 additions and 11 deletions

View File

@@ -0,0 +1,51 @@
using System;
using Content.Server.RoundEnd;
using Content.Shared.Administration;
using Content.Shared.Localizations;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Server)]
public class CallShuttleCommand : IConsoleCommand
{
public string Command => "callshuttle";
public string Description => Loc.GetString("call-shuttle-command-description");
public string Help => Loc.GetString("call-shuttle-command-help-text", ("command",Command));
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
// ReSharper disable once ConvertIfStatementToSwitchStatement
if (args.Length == 1 && TimeSpan.TryParseExact(args[0], Localization.TimeSpanMinutesFormats, loc.DefaultCulture, out var timeSpan))
{
EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(timeSpan, false);
}
else if (args.Length == 1)
{
shell.WriteLine(Loc.GetString("shell-timespan-minutes-must-be-correct"));
}
else
{
EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(false);
}
}
}
[AdminCommand(AdminFlags.Server)]
public class RecallShuttleCommand : IConsoleCommand
{
public string Command => "recallshuttle";
public string Description => Loc.GetString("recall-shuttle-command-description");
public string Help => Loc.GetString("recall-shuttle-command-help-text", ("command",Command));
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
EntitySystem.Get<RoundEndSystem>().CancelRoundEndCountdown(false);
}
}
}

View File

@@ -74,36 +74,41 @@ namespace Content.Server.RoundEnd
Timer.Spawn(CallCooldown, () => OnCallCooldownEnded?.Invoke(), _callCooldownEndedTokenSource.Token);
}
public void RequestRoundEnd()
public void RequestRoundEnd(bool checkCooldown = true)
{
RequestRoundEnd(RoundEndCountdownTime, checkCooldown);
}
public void RequestRoundEnd(TimeSpan countdownTime, bool checkCooldown = true)
{
if (IsRoundEndCountdownStarted)
return;
if (!CanCall())
if (checkCooldown && !CanCall())
{
return;
}
IsRoundEndCountdownStarted = true;
_chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", RoundEndCountdownTime.Minutes)), Loc.GetString("Station"));
_chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station"));
SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlecalled.ogg");
ExpectedCountdownEnd = _gameTiming.CurTime + RoundEndCountdownTime;
Timer.Spawn(RoundEndCountdownTime, EndRound, _roundEndCancellationTokenSource.Token);
ExpectedCountdownEnd = _gameTiming.CurTime + countdownTime;
Timer.Spawn(countdownTime, EndRound, _roundEndCancellationTokenSource.Token);
ActivateCooldown();
OnRoundEndCountdownStarted?.Invoke();
}
public void CancelRoundEndCountdown()
public void CancelRoundEndCountdown( bool checkCooldown = true)
{
if (!IsRoundEndCountdownStarted)
return;
if (!CanCall())
if (checkCooldown && !CanCall())
{
return;
}