diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs
index 8431e27658b..2060ee892fd 100644
--- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs
+++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs
@@ -419,6 +419,9 @@ public abstract partial class SharedHandsSystem
return GetHeldItem(ent, handId) == null;
}
+ ///
+ /// Counts the number of hands on this entity.
+ ///
public int GetHandCount(Entity ent)
{
if (!Resolve(ent, ref ent.Comp, false))
@@ -427,6 +430,9 @@ public abstract partial class SharedHandsSystem
return ent.Comp.Hands.Count;
}
+ ///
+ /// Counts the number of hands that are empty.
+ ///
public int CountFreeHands(Entity ent)
{
if (!Resolve(ent, ref ent.Comp, false))
@@ -442,11 +448,19 @@ public abstract partial class SharedHandsSystem
return free;
}
- public int CountFreeableHands(Entity hands)
+ ///
+ /// Counts the number of hands that are empty or can be emptied by dropping an item.
+ /// Unremoveable items will cause a hand to not be freeable.
+ ///
+ /// The hand this entity is in will be ignored when counting.
+ public int CountFreeableHands(Entity hands, EntityUid? except = null)
{
var freeable = 0;
foreach (var name in hands.Comp.Hands.Keys)
{
+ if (except != null && GetHeldItem(hands.AsNullable(), name) == except)
+ continue;
+
if (HandIsEmpty(hands.AsNullable(), name) || CanDropHeld(hands, name))
freeable++;
}
diff --git a/Content.Shared/Wieldable/SharedWieldableSystem.cs b/Content.Shared/Wieldable/SharedWieldableSystem.cs
index 3b9b8dd8e71..49db4ff86cf 100644
--- a/Content.Shared/Wieldable/SharedWieldableSystem.cs
+++ b/Content.Shared/Wieldable/SharedWieldableSystem.cs
@@ -259,7 +259,7 @@ public abstract class SharedWieldableSystem : EntitySystem
return false;
}
- if (_hands.CountFreeableHands((user, hands)) < component.FreeHandsRequired)
+ if (_hands.CountFreeableHands((user, hands), except: uid) < component.FreeHandsRequired)
{
if (!quiet)
{