From d4f406337ef0b92246d0604ddd3fb4be30426fd6 Mon Sep 17 00:00:00 2001 From: Exp Date: Sun, 9 Aug 2020 20:52:52 +0200 Subject: [PATCH] Fix Slipping not calling Dropped (#1632) --- .../Components/GUI/HandsComponent.cs | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) 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)) {