@@ -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<SharedInteractionSystem>().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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user