mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
38 lines
1.1 KiB
C#
38 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 : LocalizedCommands
|
|
{
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
public override string Command => "delete";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length != 1)
|
|
{
|
|
shell.WriteLine("You should provide exactly one argument.");
|
|
return;
|
|
}
|
|
|
|
if (!NetEntity.TryParse(args[0], out var entityNet))
|
|
{
|
|
shell.WriteLine("Invalid entity UID.");
|
|
return;
|
|
}
|
|
|
|
if (!_entityManager.TryGetEntity(entityNet, out var entity) || !_entityManager.EntityExists(entity))
|
|
{
|
|
shell.WriteLine("That entity does not exist.");
|
|
return;
|
|
}
|
|
|
|
_entityManager.DeleteEntity(entity.Value);
|
|
}
|
|
}
|
|
}
|