-using Content.Shared.Construction;
+using Content.Server.Hands.Components;
+using Content.Server.Hands.Systems;
+using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Server.Containers;
using Robust.Shared.Containers;
[DataDefinition]
public sealed class EmptyAllContainers : IGraphAction
{
+ /// <summary>
+ /// Whether or not the user should attempt to pick up the removed entities.
+ /// </summary>
+ [DataField("pickup")]
+ public bool Pickup = false;
+
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
return;
- var transform = entityManager.GetComponent<TransformComponent>(uid);
var containerSys = entityManager.EntitySysManager.GetEntitySystem<ContainerSystem>();
+ var handSys = entityManager.EntitySysManager.GetEntitySystem<HandsSystem>();
+
+ HandsComponent? hands = null;
+ var pickup = Pickup && entityManager.TryGetComponent(userUid, out hands);
+
foreach (var container in containerManager.GetAllContainers())
{
- containerSys.EmptyContainer(container, true, transform.Coordinates);
+ foreach (var ent in containerSys.EmptyContainer(container, true, reparent: !pickup))
+ {
+ if (pickup)
+ handSys.PickupOrDrop(userUid, ent, handsComp: hands);
+ }
}
}
}
-using System.Linq;
+using Content.Server.Hands.Components;
+using Content.Server.Hands.Systems;
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Server.Containers;
{
[DataField("container")] public string Container { get; private set; } = string.Empty;
+ /// <summary>
+ /// Whether or not the user should attempt to pick up the removed entities.
+ /// </summary>
+ [DataField("pickup")]
+ public bool Pickup = false;
+
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager) ||
!containerManager.TryGetContainer(Container, out var container)) return;
var containerSys = entityManager.EntitySysManager.GetEntitySystem<ContainerSystem>();
- var transform = entityManager.GetComponent<TransformComponent>(uid);
- containerSys.EmptyContainer(container, true, transform.Coordinates, true);
+ var handSys = entityManager.EntitySysManager.GetEntitySystem<HandsSystem>();
+
+ HandsComponent? hands = null;
+ var pickup = Pickup && entityManager.TryGetComponent(userUid, out hands);
+
+ foreach (var ent in containerSys.EmptyContainer(container, true, reparent: !pickup))
+ {
+ if (pickup)
+ handSys.PickupOrDrop(userUid, ent, handsComp: hands);
+ }
}
}
}
private void OnDestroyed(EntityUid uid, SecretStashComponent component, DestructionEventArgs args)
{
- _containerSystem.EmptyContainer(component.ItemContainer, attachToGridOrMap: true);
+ _containerSystem.EmptyContainer(component.ItemContainer);
}
/// <summary>
private void OnRejuvenate(EntityUid uid, CuffableComponent component, RejuvenateEvent args)
{
- _container.EmptyContainer(component.Container, true, attachToGridOrMap: true);
+ _container.EmptyContainer(component.Container, true);
}
private void OnCuffsRemovedFromContainer(EntityUid uid, CuffableComponent component, EntRemovedFromContainerMessage args)
private void OnKeyRemoval(EntityUid uid, EncryptionKeyHolderComponent component, EncryptionRemovalFinishedEvent args)
{
var contained = component.KeyContainer.ContainedEntities.ToArray();
- _container.EmptyContainer(component.KeyContainer, entMan: EntityManager);
+ _container.EmptyContainer(component.KeyContainer, reparent: false);
foreach (var ent in contained)
{
_hands.PickupOrDrop(args.User, ent);