27 lines
548 B
C#
27 lines
548 B
C#
using Godot;
|
|
|
|
namespace Game.Features.Interactions.Domain;
|
|
|
|
public readonly record struct DropRayHit(
|
|
Vector3 Origin,
|
|
Vector3 Direction,
|
|
float RayLength,
|
|
bool IsBlocked,
|
|
Vector3 BlockPoint
|
|
);
|
|
|
|
public static class DropPosition
|
|
{
|
|
public static Vector3 CalculateFrom(DropRayHit hit)
|
|
{
|
|
float distance = hit.RayLength;
|
|
|
|
if (hit.IsBlocked)
|
|
{
|
|
distance = Mathf.Max(0.25f, hit.Origin.DistanceTo(hit.BlockPoint) - 0.2f);
|
|
}
|
|
|
|
return hit.Origin + hit.Direction * distance;
|
|
}
|
|
}
|