Files
RobustToolbox/Robust.Server/Console/Commands/DeleteCommand.cs
T
AcruidandGitHub 2183cd7ca1 Massive Namespace Cleanup (#1544)
* Removed the Interfaces folder.
* All objects inside the GameObjects subfolders are now in the GameObjects namespace.
* Added a Resharper DotSettings file to mark the GameObjects subfolders as not providing namespaces.
* Simplified Robust.client.Graphics namespace.
* Automated remove redundant using statements.
2021-02-10 23:27:19 -08:00

40 lines
1.1 KiB
C#

using Robust.Server.GameObjects;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Robust.Server.Console.Commands
{
public sealed class DeleteCommand : IConsoleCommand
{
public string Command => "delete";
public string Description => "Deletes the entity with the specified ID.";
public string Help => "delete <entity UID>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine("You should provide exactly one argument.");
return;
}
var ent = IoCManager.Resolve<IServerEntityManager>();
if (!EntityUid.TryParse(args[0], out var uid))
{
shell.WriteLine("Invalid entity UID.");
return;
}
if (!ent.TryGetEntity(uid, out var entity))
{
shell.WriteLine("That entity does not exist.");
return;
}
entity.Delete();
}
}
}