Readyall and Toggleready commands to LEC. Fix an issue with ready button desync. (#38706)
* commit * commit * change lobby shell string.
This commit is contained in:
@@ -1,32 +1,41 @@
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.GameTicking.Commands
|
||||
namespace Content.Server.GameTicking.Commands;
|
||||
|
||||
[AnyCommand]
|
||||
public sealed class ToggleReadyCommand : LocalizedEntityCommands
|
||||
{
|
||||
[AnyCommand]
|
||||
sealed class ToggleReadyCommand : IConsoleCommand
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
|
||||
public override string Command => "toggleready";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
|
||||
public string Command => "toggleready";
|
||||
public string Description => "";
|
||||
public string Help => "";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
if (args.Length != 1)
|
||||
{
|
||||
var player = shell.Player;
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||
return;
|
||||
}
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ticker = _e.System<GameTicker>();
|
||||
ticker.ToggleReady(player, bool.Parse(args[0]));
|
||||
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (shell.Player is not { } player)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bool.TryParse(args[0], out var ready))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-must-be-boolean"));
|
||||
return;
|
||||
}
|
||||
|
||||
_gameTicker.ToggleReady(player, ready);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user