//
// Created by sebastian on 29.07.26.
//

#ifndef COLORRACE_LAYER_H
#define COLORRACE_LAYER_H
#include "core/animation/events/AnimationMarkerEvent.h"
#include "core/events/EventBus.h"
#include "core/inputsOutputs/context/InputContextStack.h"
#include "core/inputsOutputs/inputs/Keyboard.h"
#include "core/inputsOutputs/inputs/Mouse.h"
#include "ecs/EntityRegistry.h"


namespace engine {
    class Layer {
    public:
        Layer(Keyboard& keyboard, Mouse& mouse, EventBus<animation::AnimationMarkerEvent>& animationEventBus) : m_keyboard(keyboard), m_mouse(mouse), m_animationEventBus(animationEventBus){};
        virtual ~Layer() = default;
        void onAttach(InputContextStack& inputStack);
        void onDetach(InputContextStack& inputStack);
        virtual void onUpdate(float deltaTime) {}
        virtual void onRender() {}
    protected:
        virtual void onAttachImpl() {}
        virtual void onDetachImpl() {}
        std::shared_ptr<InputContext>& getInputContext() { return m_context; }
        InputContextStack& getInputStack() { return *m_inputStack; }
        Keyboard& getKeyboard() { return m_keyboard; }
        Mouse& getMouse() { return m_mouse; }
        EventBus<animation::AnimationMarkerEvent>& getAnimationEventBus() { return m_animationEventBus; }
    private:
        std::shared_ptr<InputContext> m_context;
        InputContextStack* m_inputStack = nullptr;

        engine::Keyboard& m_keyboard;
        engine::Mouse& m_mouse;
        engine::EventBus<animation::AnimationMarkerEvent>& m_animationEventBus;
    };

}


#endif //COLORRACE_LAYER_H
