using Sirenix.OdinInspector;
using UnityEngine;

namespace VOID.Generic.Trajectory
{
    [TypeRegistryItem("Parabolic")]
    public sealed class ParabolicTrajectory : AbstractTrajectory
    {
        [SerializeField, Required, MinValue(0)]
        public float height;
        
        protected override void OnInit()
        {
            if (height > 0f) trajectoryDistance = Mathf.PI*Mathf.Sqrt(Mathf.Pow(lineDistance/2,2)*Mathf.Pow(height,2)/2);
        }
        
        public override Vector3 GetPositionByProgress(float progress)
        {
            var result = Vector3.Lerp(startPosition, endPosition, Mathf.Clamp01(progress));
            result.y += Mathf.Sin(progress * Mathf.PI) * height;
            return result;
        }
    }
}