Localize, cleanup, and LEC round control commands. (#38812)
* commit-progress * commit
This commit is contained in:
@@ -2,50 +2,44 @@
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.GameTicking.Commands
|
||||
namespace Content.Server.GameTicking.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class DelayStartCommand : LocalizedEntityCommands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
sealed class DelayStartCommand : IConsoleCommand
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
|
||||
public override string Command => "delaystart";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
|
||||
public string Command => "delaystart";
|
||||
public string Description => "Delays the round start.";
|
||||
public string Help => $"Usage: {Command} <seconds>\nPauses/Resumes the countdown if no argument is provided.";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
var ticker = _e.System<GameTicker>();
|
||||
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
var paused = ticker.TogglePause();
|
||||
shell.WriteLine(paused ? "Paused the countdown." : "Resumed the countdown.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.WriteLine("Need zero or one arguments.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
|
||||
{
|
||||
shell.WriteLine($"{args[0]} isn't a valid amount of seconds.");
|
||||
return;
|
||||
}
|
||||
|
||||
var time = TimeSpan.FromSeconds(seconds);
|
||||
if (!ticker.DelayStart(time))
|
||||
{
|
||||
shell.WriteLine("An unknown error has occurred.");
|
||||
}
|
||||
shell.WriteLine(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
var paused = _gameTicker.TogglePause();
|
||||
shell.WriteLine(Loc.GetString(paused ? "cmd-delaystart-paused" : "cmd-delaystart-unpaused"));
|
||||
return;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("cmd-delaystart-invalid-seconds", ("value", args[0])));
|
||||
return;
|
||||
}
|
||||
|
||||
var time = TimeSpan.FromSeconds(seconds);
|
||||
if (!_gameTicker.DelayStart(time))
|
||||
shell.WriteLine(Loc.GetString("cmd-delaystart-too-late"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,28 +2,23 @@
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.GameTicking.Commands
|
||||
namespace Content.Server.GameTicking.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class EndRoundCommand : LocalizedEntityCommands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
sealed class EndRoundCommand : IConsoleCommand
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
|
||||
public override string Command => "endround";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
|
||||
public string Command => "endround";
|
||||
public string Description => "Ends the round and moves the server to PostRound.";
|
||||
public string Help => String.Empty;
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
if (_gameTicker.RunLevel != GameRunLevel.InRound)
|
||||
{
|
||||
var ticker = _e.System<GameTicker>();
|
||||
|
||||
if (ticker.RunLevel != GameRunLevel.InRound)
|
||||
{
|
||||
shell.WriteLine("This can only be executed while the game is in a round.");
|
||||
return;
|
||||
}
|
||||
|
||||
ticker.EndRound();
|
||||
shell.WriteLine(Loc.GetString("shell-can-only-run-while-round-is-active"));
|
||||
return;
|
||||
}
|
||||
|
||||
_gameTicker.EndRound();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,43 +3,37 @@ using Content.Server.RoundEnd;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.GameTicking.Commands
|
||||
namespace Content.Server.GameTicking.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class RestartRoundCommand : LocalizedEntityCommands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class RestartRoundCommand : IConsoleCommand
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
|
||||
|
||||
public override string Command => "restartround";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
|
||||
public string Command => "restartround";
|
||||
public string Description => "Ends the current round and starts the countdown for the next lobby.";
|
||||
public string Help => string.Empty;
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
if (_gameTicker.RunLevel != GameRunLevel.InRound)
|
||||
{
|
||||
var ticker = _e.System<GameTicker>();
|
||||
|
||||
if (ticker.RunLevel != GameRunLevel.InRound)
|
||||
{
|
||||
shell.WriteLine("This can only be executed while the game is in a round - try restartroundnow");
|
||||
return;
|
||||
}
|
||||
|
||||
_e.System<RoundEndSystem>().EndRound();
|
||||
shell.WriteLine(Loc.GetString("shell-can-only-run-while-round-is-active"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class RestartRoundNowCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
|
||||
public string Command => "restartroundnow";
|
||||
public string Description => "Moves the server from PostRound to a new PreRoundLobby.";
|
||||
public string Help => String.Empty;
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
_e.System<GameTicker>().RestartRound();
|
||||
}
|
||||
_roundEndSystem.EndRound();
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class RestartRoundNowCommand : LocalizedEntityCommands
|
||||
{
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
|
||||
public override string Command => "restartroundnow";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
_gameTicker.RestartRound();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,28 +2,23 @@
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.GameTicking.Commands
|
||||
namespace Content.Server.GameTicking.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class StartRoundCommand : LocalizedEntityCommands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
sealed class StartRoundCommand : IConsoleCommand
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
|
||||
public override string Command => "startround";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
|
||||
public string Command => "startround";
|
||||
public string Description => "Ends PreRoundLobby state and starts the round.";
|
||||
public string Help => String.Empty;
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
var ticker = _e.System<GameTicker>();
|
||||
|
||||
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
|
||||
return;
|
||||
}
|
||||
|
||||
ticker.StartRound();
|
||||
shell.WriteLine(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
|
||||
return;
|
||||
}
|
||||
|
||||
_gameTicker.StartRound();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user