diff --git a/Content.Client/Hands/Systems/HandsSystem.cs b/Content.Client/Hands/Systems/HandsSystem.cs index dc33db2fc2..9461af62d0 100644 --- a/Content.Client/Hands/Systems/HandsSystem.cs +++ b/Content.Client/Hands/Systems/HandsSystem.cs @@ -15,6 +15,7 @@ using Robust.Client.Player; using Robust.Client.UserInterface; using Robust.Shared.Containers; using Robust.Shared.GameStates; +using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Utility; @@ -92,9 +93,11 @@ namespace Content.Client.Hands.Systems public override void DoDrop(Entity ent, string handId, bool doDropInteraction = true, - bool log = true) + bool log = true, + EntityCoordinates? targetDropLocation = null + ) { - base.DoDrop(ent, handId, doDropInteraction, log); + base.DoDrop(ent, handId, doDropInteraction, log, targetDropLocation); if (TryGetHeldItem(ent, handId, out var held) && TryComp(held, out SpriteComponent? sprite)) sprite.RenderOrder = EntityManager.CurrentTick.Value; diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs index 516cae61e9..708be42c27 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs @@ -154,17 +154,7 @@ public abstract partial class SharedHandsSystem // drop the item with heavy calculations from their hands and place it at the calculated interaction range position // The DoDrop is handle if there's no drop target - DoDrop(ent, handId, doDropInteraction: doDropInteraction); - - // if there's no drop location stop here - if (targetDropLocation == null) - return true; - - // otherwise, also move dropped item and rotate it properly according to grid/map - var (itemPos, itemRot) = TransformSystem.GetWorldPositionRotation(entity.Value); - var origin = new MapCoordinates(itemPos, itemXform.MapID); - var target = TransformSystem.ToMapCoordinates(targetDropLocation.Value); - TransformSystem.SetWorldPositionRotation(entity.Value, GetFinalDropCoordinates(ent, origin, target, entity.Value), itemRot); + DoDrop(ent, handId, doDropInteraction: doDropInteraction, targetDropLocation: targetDropLocation); return true; } @@ -235,7 +225,9 @@ public abstract partial class SharedHandsSystem public virtual void DoDrop(Entity ent, string handId, bool doDropInteraction = true, - bool log = true) + bool log = true, + EntityCoordinates? targetDropLocation = null + ) { if (!Resolve(ent, ref ent.Comp, false)) return; @@ -255,6 +247,15 @@ public abstract partial class SharedHandsSystem return; } + if (targetDropLocation != null) + { + var (itemPos, itemRot) = TransformSystem.GetWorldPositionRotation(entity.Value); + // otherwise, also move dropped item and rotate it properly according to grid/map + var origin = new MapCoordinates(itemPos, Transform(entity.Value).MapID); + var target = TransformSystem.ToMapCoordinates(targetDropLocation.Value); + TransformSystem.SetWorldPositionRotation(entity.Value, GetFinalDropCoordinates(ent, origin, target, entity.Value), itemRot); + } + Dirty(ent); if (doDropInteraction) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 158b2260cc..0d29e67beb 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -1266,9 +1266,6 @@ namespace Content.Shared.Interaction if (IsDeleted(user) || IsDeleted(item)) return; - var dropMsg = new DroppedEvent(user); - RaiseLocalEvent(item, dropMsg, true); - // If the dropper is rotated then use their targetrelativerotation as the drop rotation var rotation = Angle.Zero; @@ -1278,6 +1275,9 @@ namespace Content.Shared.Interaction } Transform(item).LocalRotation = rotation; + + var dropMsg = new DroppedEvent(user); + RaiseLocalEvent(item, dropMsg, true); } #endregion