Console Unify API Changes (#3059)
* Remove unused IChatCommand. * Lots of refactoring into a shared context. * Removed ICommonSession from server concmd Execute. * Added argStr parameter to concmd execute. * The execute function of client concmds now returns void, use the new shell.RemoteExecuteCommand function to forward commands. * Finally move shells and commands into shared. * Console commands can now be registered directly without a class in a shared context. * Engine API Changes. * Repair rebase damage. * Update Submodule.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.GameObjects.Components.Atmos;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -14,14 +14,15 @@ using Robust.Shared.Map;
|
||||
namespace Content.Server.Commands.Atmos
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class DeleteGasCommand : IClientCommand
|
||||
public class DeleteGasCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "deletegas";
|
||||
public string Description => "Removes all gases from a grid, or just of one type if specified.";
|
||||
public string Help => $"Usage: {Command} <GridId> <Gas> / {Command} <GridId> / {Command} <Gas> / {Command}";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
GridId gridId;
|
||||
Gas? gas = null;
|
||||
|
||||
@@ -30,13 +31,13 @@ namespace Content.Server.Commands.Atmos
|
||||
case 0:
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "A grid must be specified when the command isn't used by a player.");
|
||||
shell.WriteLine("A grid must be specified when the command isn't used by a player.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "You have no entity to get a grid from.");
|
||||
shell.WriteLine("You have no entity to get a grid from.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.SendText(player, "You aren't on a grid to delete gas from.");
|
||||
shell.WriteLine("You aren't on a grid to delete gas from.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,13 +57,13 @@ namespace Content.Server.Commands.Atmos
|
||||
// Argument is a gas
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "A grid id must be specified if not using this command as a player.");
|
||||
shell.WriteLine("A grid id must be specified if not using this command as a player.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "You have no entity from which to get a grid id.");
|
||||
shell.WriteLine("You have no entity from which to get a grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,13 +71,13 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.SendText(player, "You aren't on a grid to delete gas from.");
|
||||
shell.WriteLine("You aren't on a grid to delete gas from.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse<Gas>(args[0], true, out var parsedGas))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} is not a valid gas name.");
|
||||
shell.WriteLine($"{args[0]} is not a valid gas name.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.SendText(player, $"{gridId} is not a valid grid id.");
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ namespace Content.Server.Commands.Atmos
|
||||
{
|
||||
if (!int.TryParse(args[0], out var first))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} is not a valid integer for a grid id.");
|
||||
shell.WriteLine($"{args[0]} is not a valid integer for a grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,13 +108,13 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.SendText(player, $"{gridId} is not a valid grid id.");
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse<Gas>(args[1], true, out var parsedGas))
|
||||
{
|
||||
shell.SendText(player, $"{args[1]} is not a valid gas.");
|
||||
shell.WriteLine($"{args[1]} is not a valid gas.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ namespace Content.Server.Commands.Atmos
|
||||
break;
|
||||
}
|
||||
default:
|
||||
shell.SendText(player, Help);
|
||||
shell.WriteLine(Help);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
shell.SendText(player, $"No grid exists with id {gridId}");
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,13 +139,13 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
|
||||
{
|
||||
shell.SendText(player, $"Grid {gridId} has no entity.");
|
||||
shell.WriteLine($"Grid {gridId} has no entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gridEntity.TryGetComponent(out GridAtmosphereComponent? atmosphere))
|
||||
{
|
||||
shell.SendText(player, $"Grid {gridId} has no {nameof(GridAtmosphereComponent)}");
|
||||
shell.WriteLine($"Grid {gridId} has no {nameof(GridAtmosphereComponent)}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -182,11 +183,11 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
if (gas == null)
|
||||
{
|
||||
shell.SendText(player, $"Removed {moles} moles from {tiles} tiles.");
|
||||
shell.WriteLine($"Removed {moles} moles from {tiles} tiles.");
|
||||
return;
|
||||
}
|
||||
|
||||
shell.SendText(player, $"Removed {moles} moles of gas {gas} from {tiles} tiles.");
|
||||
shell.WriteLine($"Removed {moles} moles of gas {gas} from {tiles} tiles.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user