diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index d698336476..0eb370bc22 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -437,7 +437,7 @@ namespace Content.Shared.Hands.Components DoDroppedInteraction(heldEntity, intentionalDrop); - heldEntity.Transform.Coordinates = GetFinalDropCoordinates(targetDropLocation); + heldEntity.Transform.WorldPosition = GetFinalDropCoordinates(targetDropLocation); OnItemChanged?.Invoke(); } @@ -445,29 +445,25 @@ namespace Content.Shared.Hands.Components /// /// Calculates the final location a dropped item will end up at, accounting for max drop range and collision along the targeted drop path. /// - private EntityCoordinates GetFinalDropCoordinates(EntityCoordinates targetCoords) + private Vector2 GetFinalDropCoordinates(EntityCoordinates targetCoords) { var origin = Owner.Transform.MapPosition; - var other = targetCoords.ToMap(Owner.EntityManager); + var target = targetCoords.ToMap(Owner.EntityManager); - var dropVector = other.Position - origin.Position; - var requestedDropDistance = (dropVector.Length); + var dropVector = target.Position - origin.Position; + var requestedDropDistance = dropVector.Length; if (dropVector.Length > SharedInteractionSystem.InteractionRange) { dropVector = dropVector.Normalized * SharedInteractionSystem.InteractionRange; - other = new MapCoordinates(origin.Position + dropVector, other.MapId); + target = new MapCoordinates(origin.Position + dropVector, target.MapId); } - var dropLength = EntitySystem.Get().UnobstructedDistance(origin, other, ignoredEnt: Owner); + var dropLength = EntitySystem.Get().UnobstructedDistance(origin, target, ignoredEnt: Owner); - var diff = requestedDropDistance - dropLength; - - // If we come up short then offset the drop location. - if (diff > 0) - return targetCoords.Offset(-dropVector.Normalized * diff); - - return targetCoords; + if (dropLength < requestedDropDistance) + return origin.Position + dropVector.Normalized * dropLength; + return target.Position; } ///