using UnityEngine;

namespace Davanci.Nexus
{
    // Easing curves (t in 0..1) for the code-driven splash motion.
    static class NexusEase
    {
        public static float OutCubic(float t) { t = 1f - t; return 1f - t * t * t; }

        public static float InCubic(float t) => t * t * t;

        public static float InOutCubic(float t) =>
            t < 0.5f ? 4f * t * t * t : 1f - Mathf.Pow(-2f * t + 2f, 3f) * 0.5f;

        public static float OutBack(float t, float overshoot = 1.70158f)
        {
            float u = t - 1f;
            return 1f + (overshoot + 1f) * u * u * u + overshoot * u * u;
        }

        public static float InBack(float t, float overshoot = 1.70158f) =>
            (overshoot + 1f) * t * t * t - overshoot * t * t;

        // 0 before start, 1 after start + duration, linear in between.
        public static float Window(float t, float start, float duration) =>
            Mathf.Clamp01((t - start) / duration);

        // 0 → 1 → 0 over the window, for punches and flashes.
        public static float Bump(float t, float start, float duration)
        {
            float w = (t - start) / duration;
            return w <= 0f || w >= 1f ? 0f : Mathf.Sin(w * Mathf.PI);
        }
    }
}
