diff --git a/Content.Server/GameObjects/Components/GUI/HandsComponent.cs b/Content.Server/GameObjects/Components/GUI/HandsComponent.cs index 3797aa51a6..c25fc442d2 100644 --- a/Content.Server/GameObjects/Components/GUI/HandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/HandsComponent.cs @@ -188,6 +188,25 @@ namespace Content.Server.GameObjects.Components.GUI return GetHand(index)?.Container.CanInsert(item.Owner) == true; } + /// + /// Calls the Dropped Interaction with the item. + /// + /// The itemcomponent of the item to be dropped + /// Check if the item can be dropped + /// True if IDropped.Dropped was called, otherwise false + private bool DroppedInteraction(ItemComponent item, bool doMobChecks) + { + var interactionSystem = _entitySystemManager.GetEntitySystem(); + if (doMobChecks) + { + if (!interactionSystem.TryDroppedInteraction(Owner, item.Owner)) + return false; + } + + interactionSystem.DroppedInteraction(Owner, item.Owner); + return true; + } + public bool TryHand(IEntity entity, [MaybeNullWhen(false)] out string handName) { handName = null; @@ -219,11 +238,8 @@ namespace Content.Server.GameObjects.Components.GUI return false; } - if (doMobChecks && - !_entitySystemManager.GetEntitySystem().TryDroppedInteraction(Owner, item.Owner)) - { + if (!DroppedInteraction(item, doMobChecks)) return false; - } item.RemovedFromSlot(); item.Owner.Transform.GridPosition = coords; @@ -262,11 +278,8 @@ namespace Content.Server.GameObjects.Components.GUI var item = hand.Entity.GetComponent(); - if (doMobChecks && - !_entitySystemManager.GetEntitySystem().TryDroppedInteraction(Owner, item.Owner)) - { + if (!DroppedInteraction(item, doMobChecks)) return false; - } if (!hand.Container.Remove(hand.Entity)) { @@ -325,10 +338,8 @@ namespace Content.Server.GameObjects.Components.GUI var item = hand.Entity.GetComponent(); - if (doMobChecks && !_entitySystemManager.GetEntitySystem().TryDroppedInteraction(Owner, item.Owner)) - { + if (!DroppedInteraction(item, doMobChecks)) return false; - } if (!hand.Container.CanRemove(hand.Entity)) {