diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index dbcafe26c1..1ebab628e4 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -441,14 +441,24 @@ namespace Content.Shared.Hands.Components var origin = Owner.Transform.MapPosition; var other = targetCoords.ToMap(Owner.EntityManager); + var dropVector = other.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); + } + var dropLength = EntitySystem.Get().UnobstructedDistance(origin, other, ignoredEnt: Owner); - dropLength = MathF.Min(dropLength, SharedInteractionSystem.InteractionRange); - var dropVector = origin.Position; - if (dropLength != 0) - dropVector += (other.Position - origin.Position).Normalized * dropLength; + var diff = requestedDropDistance - dropLength; - return targetCoords.WithPosition(dropVector); + // If we come up short then offset the drop location. + if (diff > 0) + return targetCoords.Offset(-dropVector.Normalized * diff); + + return targetCoords; } ///