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:
@@ -186,10 +186,10 @@ namespace Content.Client.Lobby
|
||||
else
|
||||
{
|
||||
Lobby!.StartTime.Text = string.Empty;
|
||||
Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady;
|
||||
Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready": "lobby-state-player-status-not-ready");
|
||||
Lobby!.ReadyButton.ToggleMode = true;
|
||||
Lobby!.ReadyButton.Disabled = false;
|
||||
Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady;
|
||||
Lobby!.ObserveButton.Disabled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.Administration.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class ReadyAll : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
|
||||
public string Command => "readyall";
|
||||
public string Description => "Readies up all players in the lobby, except for observers.";
|
||||
public string Help => $"{Command} | ̣{Command} <ready>";
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var ready = true;
|
||||
|
||||
if (args.Length > 0)
|
||||
{
|
||||
ready = bool.Parse(args[0]);
|
||||
}
|
||||
|
||||
var gameTicker = _e.System<GameTicker>();
|
||||
|
||||
|
||||
if (gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
shell.WriteLine("This command can only be ran while in the lobby!");
|
||||
return;
|
||||
}
|
||||
|
||||
gameTicker.ToggleReadyAll(ready);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Content.Server/Administration/Commands/ReadyAllCommand.cs
Normal file
32
Content.Server/Administration/Commands/ReadyAllCommand.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.Administration.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Round)]
|
||||
public sealed class ReadyAllCommand : LocalizedEntityCommands
|
||||
{
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
|
||||
public override string Command => "readyall";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var ready = true;
|
||||
|
||||
if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length > 0 && !bool.TryParse(args[0], out ready))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-must-be-boolean"));
|
||||
return;
|
||||
}
|
||||
|
||||
_gameTicker.ToggleReadyAll(ready);
|
||||
}
|
||||
}
|
||||
@@ -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 IEntityManager _e = default!;
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
|
||||
public string Command => "toggleready";
|
||||
public string Description => "";
|
||||
public string Help => "";
|
||||
public override string Command => "toggleready";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player;
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||
return;
|
||||
}
|
||||
if (player == null)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
|
||||
return;
|
||||
}
|
||||
|
||||
var ticker = _e.System<GameTicker>();
|
||||
ticker.ToggleReady(player, bool.Parse(args[0]));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,6 @@ namespace Content.Server.GameTicking
|
||||
return;
|
||||
}
|
||||
|
||||
var status = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay;
|
||||
_playerGameStatuses[player.UserId] = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay;
|
||||
RaiseNetworkEvent(GetStatusMsg(player), player.Channel);
|
||||
// update server info to reflect new ready count
|
||||
|
||||
2
Resources/Locale/en-US/commands/readyall-command.ftl
Normal file
2
Resources/Locale/en-US/commands/readyall-command.ftl
Normal file
@@ -0,0 +1,2 @@
|
||||
cmd-readyall-desc = Readies up all players in the lobby, except for observers.
|
||||
cmd-readyall-help = Usage: readyall [bool]
|
||||
2
Resources/Locale/en-US/commands/toggleready-command.ftl
Normal file
2
Resources/Locale/en-US/commands/toggleready-command.ftl
Normal file
@@ -0,0 +1,2 @@
|
||||
cmd-toggleready-desc = Toggle the players ready status.
|
||||
cmd-toggleready-help = Usage: toggleready <ready>
|
||||
Reference in New Issue
Block a user