using UnityEngine;

namespace Intrepid.Utilities
{
    public static class GonFunctions
    {
        public static Vector2 ConstrainDirectionToForwardCone(
            Vector2 direction,
            Vector2 forward,
            float maxAngleDegrees)
        {
            var clampedAngle = Mathf.Clamp(
                Vector2.SignedAngle(forward, direction),
                -maxAngleDegrees,
                maxAngleDegrees
            );
            return forward.Rotate(clampedAngle).normalized;
        }
    }
}