//
// Created by sebastian on 04.08.26.
//

#ifndef COLORRACE_TRANSFORMANIMATIONCOMPONENT_H
#define COLORRACE_TRANSFORMANIMATIONCOMPONENT_H

#include <functional>

#include "glm/glm.hpp"
namespace engine::animation {
    using EasingFunction = std::function<float(float)>;

    template<typename T>
    struct Keyframe {
        float time;
        T value;

        EasingFunction easingFunction = [](float t) {
            return t;
        };
    };

    struct AnimationMarker {
        float time;
        std::function<void()> callback;
    };


    template<typename T>
    struct AnimationTrack {
        std::vector<Keyframe<T>> keys;
    };

    struct TransformAnimationComponent {
        float time = 0.0f;
        float duration = 0.0f;

        AnimationTrack<glm::vec3> position;
        AnimationTrack<glm::vec3> rotation;
        AnimationTrack<glm::vec3> scale;

        std::vector<AnimationMarker> markers;
        size_t nextMarkerIndex = 0;

        std::function<void()> onFinished;
        bool loop = false;
        bool finished = false;
    };
}
#endif //COLORRACE_TRANSFORMANIMATIONCOMPONENT_H
