@@ -441,14 +441,24 @@ namespace Content.Shared.Hands.Components
|
|||||||
var origin = Owner.Transform.MapPosition;
|
var origin = Owner.Transform.MapPosition;
|
||||||
var other = targetCoords.ToMap(Owner.EntityManager);
|
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);
|
var dropLength = EntitySystem.Get<SharedInteractionSystem>().UnobstructedDistance(origin, other, ignoredEnt: Owner);
|
||||||
dropLength = MathF.Min(dropLength, SharedInteractionSystem.InteractionRange);
|
|
||||||
|
|
||||||
var dropVector = origin.Position;
|
var diff = requestedDropDistance - dropLength;
|
||||||
if (dropLength != 0)
|
|
||||||
dropVector += (other.Position - origin.Position).Normalized * 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>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user