using UnityEngine;

namespace ScrambleKit.Extensions
{

    public static class Vector2Extensions
    {
        public static float AngleFacing(this Vector2 vector)
        {
            if (vector == Vector2.zero)
                return 0;

            Vector2 v = vector.normalized;
            return Mathf.Atan2(v.x, v.y) * -180 / Mathf.PI;
        }

        public static float AngleTo(this Vector2 start, Vector2 toward)
        {
            return (toward - start).AngleFacing();
        }
    }
}