Files
tbd-station-14/Content.Server/Decals/Commands/RemoveDecalCommand.cs
Jake Huxell 59e46aab93 Reduced Warning Count By 130 For Full Rebuilds (#26518)
* remove deprecated entity coordinate extension functions. Reduces warning count by approximately 50

* final toCoords Removed

* Remove all unused variables and dead code paths

* remove always true variable, should be a cvar or something instead

* remove superfluous variables from tests
2024-03-29 16:28:16 +11:00

49 lines
1.6 KiB
C#

using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Map.Components;
namespace Content.Server.Decals.Commands
{
[AdminCommand(AdminFlags.Mapping)]
public sealed class RemoveDecalCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entManager = default!;
public string Command => "rmdecal";
public string Description => "removes a decal";
public string Help => $"{Command} <uid> <gridId>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteError($"Unexpected number of arguments.\nExpected two: {Help}");
return;
}
if (!uint.TryParse(args[0], out var uid))
{
shell.WriteError($"Failed parsing uid.");
return;
}
if (!NetEntity.TryParse(args[1], out var rawGridIdNet) ||
!_entManager.TryGetEntity(rawGridIdNet, out var rawGridId) ||
!_entManager.HasComponent<MapGridComponent>(rawGridId))
{
shell.WriteError("Failed parsing gridId.");
return;
}
var decalSystem = _entManager.System<DecalSystem>();
if (decalSystem.RemoveDecal(rawGridId.Value, uid))
{
shell.WriteLine($"Successfully removed decal {uid}.");
return;
}
shell.WriteError($"Failed trying to remove decal {uid}.");
}
}
}