namespace NeonSprawl.Server.Game.World;

/// <summary>
/// Horizontal (floor-plane) distance on <strong>X/Z only</strong>; <c>Y</c> is ignored for reach (NS-18).
/// </summary>
public static class HorizontalReach
{
    /// <summary>Planar distance <c>sqrt(dx² + dz²)</c> using only <c>X</c> and <c>Z</c>.</summary>
    public static double HorizontalDistance(double ax, double az, double bx, double bz)
    {
        var dx = ax - bx;
        var dz = az - bz;
        return Math.Sqrt(dx * dx + dz * dz);
    }

    /// <summary><c>true</c> when <see cref="HorizontalDistance"/> <c>&lt;= radius</c> (boundary inclusive).</summary>
    /// <exception cref="ArgumentOutOfRangeException"><paramref name="radius"/> is negative (invalid configuration).</exception>
    public static bool IsWithinHorizontalRadius(double ax, double az, double bx, double bz, double radius)
    {
        ArgumentOutOfRangeException.ThrowIfNegative(radius);
        return HorizontalDistance(ax, az, bx, bz) <= radius;
    }
}
