namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Round)]
- sealed class ForceMapCommand : IConsoleCommand
+ public sealed class ForceMapCommand : LocalizedCommands
{
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
+ [Dependency] private readonly IGameMapManager _gameMapManager = default!;
+ [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
- public string Command => "forcemap";
- public string Description => Loc.GetString("forcemap-command-description");
- public string Help => Loc.GetString("forcemap-command-help");
+ public override string Command => "forcemap";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
- shell.WriteLine(Loc.GetString("forcemap-command-need-one-argument"));
+ shell.WriteLine(Loc.GetString(Loc.GetString($"shell-need-exactly-one-argument")));
return;
}
- var gameMap = IoCManager.Resolve<IGameMapManager>();
var name = args[0];
// An empty string clears the forced map
- if (!string.IsNullOrEmpty(name) && !gameMap.CheckMapExists(name))
+ if (!string.IsNullOrEmpty(name) && !_gameMapManager.CheckMapExists(name))
{
- shell.WriteLine(Loc.GetString("forcemap-command-map-not-found", ("map", name)));
+ shell.WriteLine(Loc.GetString("cmd-forcemap-map-not-found", ("map", name)));
return;
}
_configurationManager.SetCVar(CCVars.GameMap, name);
if (string.IsNullOrEmpty(name))
- shell.WriteLine(Loc.GetString("forcemap-command-cleared"));
+ shell.WriteLine(Loc.GetString("cmd-forcemap-cleared"));
else
- shell.WriteLine(Loc.GetString("forcemap-command-success", ("map", name)));
+ shell.WriteLine(Loc.GetString("cmd-forcemap-success", ("map", name)));
}
- public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
- var options = IoCManager.Resolve<IPrototypeManager>()
+ var options = _prototypeManager
.EnumeratePrototypes<GameMapPrototype>()
.Select(p => new CompletionOption(p.ID, p.MapName))
.OrderBy(p => p.Value);
- return CompletionResult.FromHintOptions(options, Loc.GetString("forcemap-command-arg-map"));
+ return CompletionResult.FromHintOptions(options, Loc.GetString($"cmd-forcemap-hint"));
}
return CompletionResult.Empty;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Round)]
- sealed class ForcePresetCommand : IConsoleCommand
+ public sealed class ForcePresetCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _e = default!;
+ [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+ [Dependency] private readonly GameTicker _ticker = default!;
- public string Command => "forcepreset";
- public string Description => "Forces a specific game preset to start for the current lobby.";
- public string Help => $"Usage: {Command} <preset>";
+ public override string Command => "forcepreset";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var ticker = _e.System<GameTicker>();
- if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
+ if (_ticker.RunLevel != GameRunLevel.PreRoundLobby)
{
- shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
+ shell.WriteLine(Loc.GetString($"cmd-forcepreset-preround-lobby-only"));
return;
}
if (args.Length != 1)
{
- shell.WriteLine("Need exactly one argument.");
+ shell.WriteLine(Loc.GetString($"shell-need-exactly-one-argument"));
return;
}
var name = args[0];
- if (!ticker.TryFindGamePreset(name, out var type))
+ if (!_ticker.TryFindGamePreset(name, out var type))
{
- shell.WriteLine($"No preset exists with name {name}.");
+ shell.WriteLine(Loc.GetString($"cmd-forcepreset-no-preset-found", ("preset", name)));
return;
}
- ticker.SetGamePreset(type, true);
- shell.WriteLine($"Forced the game to start with preset {name}.");
- ticker.UpdateInfoText();
+ _ticker.SetGamePreset(type, true);
+ shell.WriteLine(Loc.GetString($"cmd-forcepreset-success", ("preset", name)));
+ _ticker.UpdateInfoText();
}
- public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
- var options = IoCManager.Resolve<IPrototypeManager>()
+ var options = _prototypeManager
.EnumeratePrototypes<GamePresetPrototype>()
.OrderBy(p => p.ID)
.Select(p => p.ID);
- return CompletionResult.FromHintOptions(options, "<preset>");
+ return CompletionResult.FromHintOptions(options, Loc.GetString($"cmd-forcepreset-hint"));
}
return CompletionResult.Empty;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Round)]
- public sealed class GoLobbyCommand : IConsoleCommand
+ public sealed class GoLobbyCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _e = default!;
+ [Dependency] private readonly IConfigurationManager _configManager = default!;
+ [Dependency] private readonly GameTicker _gameTicker = default!;
- public string Command => "golobby";
- public string Description => "Enables the lobby and restarts the round.";
- public string Help => $"Usage: {Command} / {Command} <preset>";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "golobby";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
GamePresetPrototype? preset = null;
var presetName = string.Join(" ", args);
- var ticker = _e.System<GameTicker>();
-
if (args.Length > 0)
{
- if (!ticker.TryFindGamePreset(presetName, out preset))
+ if (!_gameTicker.TryFindGamePreset(presetName, out preset))
{
- shell.WriteLine($"No preset found with name {presetName}");
+ shell.WriteLine(Loc.GetString($"cmd-forcepreset-no-preset-found", ("preset", presetName)));
return;
}
}
- var config = IoCManager.Resolve<IConfigurationManager>();
- config.SetCVar(CCVars.GameLobbyEnabled, true);
+ _configManager.SetCVar(CCVars.GameLobbyEnabled, true);
- ticker.RestartRound();
+ _gameTicker.RestartRound();
if (preset != null)
- {
- ticker.SetGamePreset(preset);
- }
+ _gameTicker.SetGamePreset(preset);
- shell.WriteLine($"Enabling the lobby and restarting the round.{(preset == null ? "" : $"\nPreset set to {presetName}")}");
+ shell.WriteLine(Loc.GetString(preset == null ? "cmd-golobby-success" : "cmd-golobby-success-with-preset", ("preset", presetName)));
}
}
}
// Handles logic for "ghost kicking".
// Basically we boot the client off the server without telling them, so the game shits itself.
-// Hilariously isn't it?
+// Hilarious, isn't it?
public sealed class GhostKickManager
{
}
[AdminCommand(AdminFlags.Moderator)]
-public sealed class GhostKickCommand : IConsoleCommand
+public sealed class GhostKickCommand : LocalizedEntityCommands
{
- public string Command => "ghostkick";
- public string Description => "Kick a client from the server as if their network just dropped.";
- public string Help => "Usage: ghostkick <Player> [Reason]";
+ [Dependency] private readonly IPlayerManager _playerManager = default!;
+ [Dependency] private readonly GhostKickManager _ghostKick = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "ghostkick";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 1)
{
- shell.WriteError("Need at least one argument");
+ shell.WriteError(Loc.GetString($"shell-need-exactly-one-argument"));
return;
}
var playerName = args[0];
- var reason = args.Length > 1 ? args[1] : "Ghost kicked by console";
-
- var players = IoCManager.Resolve<IPlayerManager>();
- var ghostKick = IoCManager.Resolve<GhostKickManager>();
+ var reason = args.Length > 1 ? args[1] : Loc.GetString($"cmd-ghostkick-default-reason");
- if (!players.TryGetSessionByUsername(playerName, out var player))
+ if (!_playerManager.TryGetSessionByUsername(playerName, out var player))
{
- shell.WriteError($"Unable to find player: '{playerName}'.");
+ shell.WriteError(Loc.GetString($"shell-target-player-does-not-exist"));
return;
}
- ghostKick.DoDisconnect(player.Channel, reason);
+ _ghostKick.DoDisconnect(player.Channel, reason);
}
}
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
+using Robust.Shared.Prototypes;
namespace Content.Server.Interaction;
[AdminCommand(AdminFlags.Debug)]
-public sealed class TilePryCommand : IConsoleCommand
+public sealed class TilePryCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _entities = default!;
+ [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
- public string Command => "tilepry";
- public string Description => "Pries up all tiles in a radius around the user.";
- public string Help => $"Usage: {Command} <radius>";
+ private readonly string _platingId = "Plating";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "tilepry";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
if (player?.AttachedEntity is not { } attached)
if (!int.TryParse(args[0], out var radius))
{
- shell.WriteError($"{args[0]} isn't a valid integer.");
+ shell.WriteError(Loc.GetString($"cmd-tilepry-arg-must-be-number", ("arg", args[0])));
return;
}
if (radius < 0)
{
- shell.WriteError("Radius must be positive.");
+ shell.WriteError(Loc.GetString($"cmd-tilepry-radius-must-be-positive"));
return;
}
- var mapSystem = _entities.System<SharedMapSystem>();
- var xform = _entities.GetComponent<TransformComponent>(attached);
+ var xform = EntityManager.GetComponent<TransformComponent>(attached);
var playerGrid = xform.GridUid;
- if (!_entities.TryGetComponent<MapGridComponent>(playerGrid, out var mapGrid))
+ if (!EntityManager.TryGetComponent<MapGridComponent>(playerGrid, out var mapGrid))
return;
var playerPosition = xform.Coordinates;
- var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
for (var i = -radius; i <= radius; i++)
{
for (var j = -radius; j <= radius; j++)
{
- var tile = mapSystem.GetTileRef(playerGrid.Value, mapGrid, playerPosition.Offset(new Vector2(i, j)));
- var coordinates = mapSystem.GridTileToLocal(playerGrid.Value, mapGrid, tile.GridIndices);
- var tileDef = (ContentTileDefinition)tileDefinitionManager[tile.Tile.TypeId];
+ var tile = _mapSystem.GetTileRef(playerGrid.Value, mapGrid, playerPosition.Offset(new Vector2(i, j)));
+ var coordinates = _mapSystem.GridTileToLocal(playerGrid.Value, mapGrid, tile.GridIndices);
+ var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId];
- if (!tileDef.CanCrowbar) continue;
+ if (!tileDef.CanCrowbar)
+ continue;
- var plating = tileDefinitionManager["Plating"];
- mapSystem.SetTile(playerGrid.Value, mapGrid, coordinates, new Tile(plating.TileId));
+ var plating = _tileDefinitionManager[_platingId];
+ _mapSystem.SetTile(playerGrid.Value, mapGrid, coordinates, new Tile(plating.TileId));
}
}
}
namespace Content.Server.Mapping
{
[AdminCommand(AdminFlags.Server | AdminFlags.Mapping)]
- sealed class MappingCommand : IConsoleCommand
+ public sealed class MappingCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _entities = default!;
+ [Dependency] private readonly IResourceManager _resourceMgr = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
+ [Dependency] private readonly MappingSystem _mappingSystem = default!;
+ [Dependency] private readonly MapLoaderSystem _mapLoader = default!;
- public string Command => "mapping";
- public string Description => Loc.GetString("cmd-mapping-desc");
- public string Help => Loc.GetString("cmd-mapping-help");
+ public override string Command => "mapping";
- public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
switch (args.Length)
{
case 1:
return CompletionResult.FromHint(Loc.GetString("cmd-hint-mapping-id"));
case 2:
- var res = IoCManager.Resolve<IResourceManager>();
- var opts = CompletionHelper.UserFilePath(args[1], res.UserData)
- .Concat(CompletionHelper.ContentFilePath(args[1], res));
+ var opts = CompletionHelper.UserFilePath(args[1], _resourceMgr.UserData)
+ .Concat(CompletionHelper.ContentFilePath(args[1], _resourceMgr));
return CompletionResult.FromHintOptions(opts, Loc.GetString("cmd-hint-mapping-path"));
case 3:
return CompletionResult.FromHintOptions(["false", "true"], Loc.GetString("cmd-mapping-hint-grid"));
return CompletionResult.Empty;
}
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
MapId mapId;
string? toLoad = null;
- var mapSys = _entities.System<SharedMapSystem>();
+
Entity<MapGridComponent>? grid = null;
// Get the map ID to use
return;
}
- if (mapSys.MapExists(mapId))
+ if (_mapSystem.MapExists(mapId))
{
shell.WriteError(Loc.GetString("cmd-mapping-exists", ("mapId", mapId)));
return;
// either load a map or create a new one.
if (args.Length <= 1)
{
- mapSys.CreateMap(mapId, runMapInit: false);
+ _mapSystem.CreateMap(mapId, runMapInit: false);
}
else
{
var path = new ResPath(args[1]);
toLoad = path.FilenameWithoutExtension;
var opts = new DeserializationOptions {StoreYamlUids = true};
- var loader = _entities.System<MapLoaderSystem>();
if (isGrid == true)
{
- mapSys.CreateMap(mapId, runMapInit: false);
- if (!loader.TryLoadGrid(mapId, path, out grid, opts))
+ _mapSystem.CreateMap(mapId, runMapInit: false);
+ if (!_mapLoader.TryLoadGrid(mapId, path, out grid, opts))
{
shell.WriteError(Loc.GetString("cmd-mapping-error"));
- mapSys.DeleteMap(mapId);
+ _mapSystem.DeleteMap(mapId);
return;
}
}
- else if (!loader.TryLoadMapWithId(mapId, path, out _, out _, opts))
+ else if (!_mapLoader.TryLoadMapWithId(mapId, path, out _, out _, opts))
{
if (isGrid == false)
{
// isGrid was not specified and loading it as a map failed, so we fall back to trying to load
// the file as a grid
shell.WriteLine(Loc.GetString("cmd-mapping-try-grid"));
- mapSys.CreateMap(mapId, runMapInit: false);
- if (!loader.TryLoadGrid(mapId, path, out grid, opts))
+ _mapSystem.CreateMap(mapId, runMapInit: false);
+ if (!_mapLoader.TryLoadGrid(mapId, path, out grid, opts))
{
shell.WriteError(Loc.GetString("cmd-mapping-error"));
- mapSys.DeleteMap(mapId);
+ _mapSystem.DeleteMap(mapId);
return;
}
}
}
// was the map actually created or did it fail somehow?
- if (!mapSys.MapExists(mapId))
+ if (!_mapSystem.MapExists(mapId))
{
shell.WriteError(Loc.GetString("cmd-mapping-error"));
return;
}
}
else
- {
- mapSys.CreateMap(out mapId, runMapInit: false);
- }
+ _mapSystem.CreateMap(out mapId, runMapInit: false);
// map successfully created. run misc helpful mapping commands
if (player.AttachedEntity is { Valid: true } playerEntity &&
- _entities.GetComponent<MetaDataComponent>(playerEntity).EntityPrototype?.ID != GameTicker.AdminObserverPrototypeName)
+ EntityManager.GetComponent<MetaDataComponent>(playerEntity).EntityPrototype?.ID != GameTicker.AdminObserverPrototypeName)
{
shell.ExecuteCommand("aghost");
}
shell.ExecuteCommand("changecvar events.enabled false");
shell.ExecuteCommand("changecvar shuttle.auto_call_time 0");
- var auto = _entities.System<MappingSystem>();
if (grid != null)
- auto.ToggleAutosave(grid.Value.Owner, toLoad ?? "NEWGRID");
+ _mappingSystem.ToggleAutosave(grid.Value.Owner, toLoad ?? "NEWGRID");
else
- auto.ToggleAutosave(mapId, toLoad ?? "NEWMAP");
+ _mappingSystem.ToggleAutosave(mapId, toLoad ?? "NEWMAP");
shell.ExecuteCommand($"tp 0 0 {mapId}");
shell.RemoteExecuteCommand("mappingclientsidesetup");
- DebugTools.Assert(mapSys.IsPaused(mapId));
+ DebugTools.Assert(_mapSystem.IsPaused(mapId));
if (args.Length != 2)
shell.WriteLine(Loc.GetString("cmd-mapping-success", ("mapId", mapId)));
/// Toggles GridDragging on the system.
/// </summary>
[AdminCommand(AdminFlags.Fun)]
-public sealed class GridDraggingCommand : IConsoleCommand
+public sealed class GridDraggingCommand : LocalizedEntityCommands
{
- public string Command => SharedGridDraggingSystem.CommandName;
- public string Description => $"Allows someone with permissions to drag grids around.";
- public string Help => $"{Command}";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ [Dependency] private readonly GridDraggingSystem _grid = default!;
+
+ public override string Command => SharedGridDraggingSystem.CommandName;
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player == null)
{
- shell.WriteError("shell-server-cannot");
+ shell.WriteError("shell-only-players-can-run-this-command");
return;
}
- var system = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<GridDraggingSystem>();
- system.Toggle(shell.Player);
-
- if (system.IsEnabled(shell.Player))
- shell.WriteLine("Grid dragging toggled on");
- else
- shell.WriteLine("Grid dragging toggled off");
+ _grid.Toggle(shell.Player);
+ shell.WriteLine(Loc.GetString($"cmd-griddrag-status", ("status", _grid.IsEnabled(shell.Player))));
}
}
namespace Content.Server.Mind.Commands
{
[AdminCommand(AdminFlags.Admin)]
- public sealed class MindInfoCommand : IConsoleCommand
+ public sealed class MindInfoCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _entities = default!;
+ [Dependency] private readonly IPlayerManager _playerManager = default!;
+ [Dependency] private readonly SharedRoleSystem _roles = default!;
+ [Dependency] private readonly SharedMindSystem _minds = default!;
- public string Command => "mindinfo";
- public string Description => "Lists info for the mind of a specific player.";
- public string Help => "mindinfo <session ID>";
+ public override string Command => "mindinfo";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
- shell.WriteLine("Expected exactly 1 argument.");
+ shell.WriteLine(Loc.GetString($"shell-need-exactly-one-argument"));
return;
}
- var mgr = IoCManager.Resolve<IPlayerManager>();
- if (!mgr.TryGetSessionByUsername(args[0], out var session))
+ if (!_playerManager.TryGetSessionByUsername(args[0], out var session))
{
- shell.WriteLine("Can't find that mind");
+ shell.WriteLine(Loc.GetString($"cmd-mindinfo-mind-not-found"));
return;
}
- var minds = _entities.System<SharedMindSystem>();
- if (!minds.TryGetMind(session, out var mindId, out var mind))
+ if (!_minds.TryGetMind(session, out var mindId, out var mind))
{
- shell.WriteLine("Can't find that mind");
+ shell.WriteLine(Loc.GetString($"cmd-mindinfo-mind-not-found"));
return;
}
var builder = new StringBuilder();
builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.UserId, mind.OwnedEntity);
- var roles = _entities.System<SharedRoleSystem>();
- foreach (var role in roles.MindGetAllRoleInfo(mindId))
+ foreach (var role in _roles.MindGetAllRoleInfo(mindId))
{
builder.AppendFormat("{0} ", role.Name);
}
--- /dev/null
+cmd-forcemap-desc = Forces the game to start with a given map next round.
+cmd-forcemap-help = Usage: forcemap <map ID>
+cmd-forcemap-success = Forced the game to start with map { $map } next round.
+cmd-forcemap-cleared = Cleared the forced map setting.
+cmd-forcemap-map-not-found = No eligible map exists with name { $map }.
+cmd-forcemap-hint = <map ID>
--- /dev/null
+cmd-forcepreset-desc = Forces a specific game preset to start for the current lobby.
+cmd-forcepreset-help = Usage: forcepreset <preset>
+cmd-forcepreset-preround-lobby-only = This can only be executed while the game is in the pre-round lobby.
+cmd-forcepreset-no-preset-found = No preset exists with name {$preset}.
+cmd-forcepreset-success = Forced the game to start with preset {$preset}.
+cmd-forcepreset-hint = <preset>
--- /dev/null
+cmd-ghostkick-desc = Kick a client from the server as if their network just dropped.
+cmd-ghostkick-help = Usage: ghostkick <Player> [Reason]
+cmd-ghostkick-default-reason = Ghost kicked by console.
--- /dev/null
+cmd-golobby-desc = Enables the lobby and restarts the round.
+cmd-golobby-help = Usage: golobby / golobby <preset>
+cmd-golobby-success = Enabling the lobby and restarting the round.
+cmd-golobby-success-with-preset = Enabling the lobby and restarting the round with preset {$preset}.
--- /dev/null
+cmd-griddrag-desc = Allows someone with permissions to drag grids around.
+cmd-griddrag-help = Usage: griddrag
+cmd-griddrag-status = Grid dragging set to {$status}.
--- /dev/null
+cmd-mindinfo-desc = Lists info for the mind of a specific player.
+cmd-mindinfo-help = Usage: mindinfo <session ID>
+cmd-mindinfo-mind-not-found = Can't find that mind.
--- /dev/null
+cmd-tilepry-desc = Pries up all tiles in a radius around the user.
+cmd-tilepry-help = Usage: tilepry <radius>
+cmd-tilepry-radius-must-be-positive = Radius must be positive.
+cmd-tilepry-arg-must-be-number = {$arg} isn't a valid integer.
+++ /dev/null
-## Forcemap command loc.
-
-forcemap-command-description = Forces the game to start with a given map next round.
-forcemap-command-help = forcemap <map ID>
-forcemap-command-need-one-argument = forcemap takes one argument, the path to the map file.
-forcemap-command-map-not-found = No eligible map exists with name { $map }.
-forcemap-command-success = Forced the game to start with map { $map } next round.
-forcemap-command-cleared = Cleared the forced map setting.
-forcemap-command-arg-map = <map ID>