* checkpoint * pt 2 * pt... i forgot * pt 4 * patch * More test fixes * optimization!!! * the REAL hand system * fix RetractableItemActionSystem.cs oversight * the review * test * remove test usage of body prototype * Update Content.IntegrationTests/Tests/Interaction/InteractionTest.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * hellcode * hellcode 2 * Minor cleanup * test * Chasing the last of the bugs * changes --------- Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
using Content.Shared.Administration;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Content.Shared.Inventory;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Content.Server.Administration.Commands;
|
|
|
|
[AdminCommand(AdminFlags.Debug)]
|
|
public sealed class StripAllCommand : LocalizedEntityCommands
|
|
{
|
|
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
|
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
|
|
|
public override string Command => "stripall";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length != 1)
|
|
{
|
|
shell.WriteLine(Loc.GetString("shell-need-exactly-one-argument"));
|
|
return;
|
|
}
|
|
|
|
if (!NetEntity.TryParse(args[0], out var targetUidNet) || !EntityManager.TryGetEntity(targetUidNet, out var targetEntity))
|
|
{
|
|
shell.WriteLine(Loc.GetString("shell-entity-uid-must-be-number"));
|
|
return;
|
|
}
|
|
|
|
if (!EntityManager.TryGetComponent<InventoryComponent>(targetEntity, out var inventory))
|
|
{
|
|
shell.WriteLine(Loc.GetString("shell-entity-target-lacks-component", ("componentName", nameof(InventoryComponent))));
|
|
return;
|
|
}
|
|
|
|
var slots = _inventorySystem.GetSlotEnumerator((targetEntity.Value, inventory));
|
|
while (slots.NextItem(out _, out var slot))
|
|
{
|
|
_inventorySystem.TryUnequip(targetEntity.Value, targetEntity.Value, slot.Name, true, true, inventory: inventory);
|
|
}
|
|
|
|
if (EntityManager.TryGetComponent<HandsComponent>(targetEntity, out var hands))
|
|
{
|
|
foreach (var hand in _handsSystem.EnumerateHands((targetEntity.Value, hands)))
|
|
{
|
|
_handsSystem.TryDrop((targetEntity.Value, hands),
|
|
hand,
|
|
checkActionBlocker: false,
|
|
doDropInteraction: false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
if (args.Length == 1)
|
|
{
|
|
return CompletionResult.FromHintOptions(
|
|
CompletionHelper.Components<InventoryComponent>(args[0]),
|
|
Loc.GetString("cmd-stripall-player-completion"));
|
|
}
|
|
|
|
return CompletionResult.Empty;
|
|
}
|
|
}
|
|
|