2021-11-11 16:10:57 -07:00
|
|
|
using Content.Server.Body.Components;
|
2021-11-01 23:32:58 -05:00
|
|
|
using Content.Shared.Administration;
|
2022-01-04 02:17:39 -07:00
|
|
|
using Content.Shared.Body.Components;
|
2021-11-01 23:32:58 -05:00
|
|
|
using Robust.Shared.Console;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Administration.Commands
|
|
|
|
|
{
|
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class RemoveMechanismCommand : IConsoleCommand
|
2021-11-01 23:32:58 -05:00
|
|
|
{
|
|
|
|
|
public string Command => "rmmechanism";
|
|
|
|
|
public string Description => "Removes a given entity from it's containing bodypart, if any.";
|
|
|
|
|
public string Help => "Usage: rmmechanism <uid>";
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!EntityUid.TryParse(args[0], out var entityUid))
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
|
2021-11-08 12:37:32 +01:00
|
|
|
if (!entityManager.TryGetComponent<TransformComponent>(entityUid, out var transform)) return;
|
2021-11-01 23:32:58 -05:00
|
|
|
|
|
|
|
|
var parent = transform.ParentUid;
|
|
|
|
|
|
|
|
|
|
if (entityManager.TryGetComponent<BodyPartComponent>(parent, out var body) &&
|
|
|
|
|
entityManager.TryGetComponent<MechanismComponent>(entityUid, out var part))
|
|
|
|
|
{
|
|
|
|
|
body.RemoveMechanism(part);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError("Was not a mechanism, or did not have a parent.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|