]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix selfunremoveable component being bypassed by hand pickup verb (#31089)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Mon, 19 Aug 2024 03:02:38 +0000 (23:02 -0400)
committerGitHub <noreply@github.com>
Mon, 19 Aug 2024 03:02:38 +0000 (21:02 -0600)
* fix selfunremoveable component being bypassed by hand pickup verb

* fix logic

Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs
Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs

index d1f41738e9d8b2c9405e88863babbfb7669c4706..6d619460f4f7e38bd4ecaca94ff5066ec67bbbff 100644 (file)
@@ -1,3 +1,4 @@
+using Content.Shared.Clothing.Components;
 using Content.Shared.Database;
 using Content.Shared.Hands.Components;
 using Content.Shared.Item;
@@ -178,6 +179,17 @@ public abstract partial class SharedHandsSystem : EntitySystem
         if (checkActionBlocker && !_actionBlocker.CanPickup(uid, entity))
             return false;
 
+        if (ContainerSystem.TryGetContainingContainer((entity, null, null), out var container))
+        {
+            if (!ContainerSystem.CanRemove(entity, container))
+                return false;
+
+            if (_inventory.TryGetSlotEntity(uid, container.ID, out var slotEnt) &&
+                slotEnt == entity &&
+                !_inventory.CanUnequip(uid, entity, container.ID, out _))
+                return false;
+        }
+
         // check can insert (including raising attempt events).
         return ContainerSystem.CanInsert(entity, handContainer);
     }
index e48aafeab52f69883db6ee824c8bb08119244cee..1fe66cd3cb86266f4e1159749dc8501f19f41f0d 100644 (file)
@@ -4,6 +4,7 @@ using Content.Shared.ActionBlocker;
 using Content.Shared.Administration.Logs;
 using Content.Shared.Hands.Components;
 using Content.Shared.Interaction;
+using Content.Shared.Inventory;
 using Content.Shared.Inventory.VirtualItem;
 using Content.Shared.Storage.EntitySystems;
 using Robust.Shared.Containers;
@@ -17,6 +18,7 @@ public abstract partial class SharedHandsSystem
     [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
     [Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
     [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
+    [Dependency] private readonly InventorySystem _inventory = default!;
     [Dependency] private readonly SharedStorageSystem _storage = default!;
     [Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
     [Dependency] private readonly SharedVirtualItemSystem _virtualSystem = default!;