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

#ifndef COLORRACE_AUDIOLAYER_H
#define COLORRACE_AUDIOLAYER_H
#include <utility>

#include "core/audio/SoundSource.h"
#include "core/audio/ecs/AudioSystem.h"
#include "core/events/EventBus.h"
#include "layer/Layer.h"
#include "loader/assets/AssetManager.h"
#include "ludo/LudoGameMode.h"



namespace ludo {
    class AudioLayer :public engine::Layer {
    public:
        AudioLayer(engine::AssetManager& assetManager, engine::Keyboard &keyboard, engine::Mouse &mouse, std::shared_ptr<LudoGameMode> gameMode,
            engine::EntityRegistry&  registry, engine::EventBus<LudoEvent>& eventBus, engine::EventBus<engine::animation::AnimationMarkerEvent>& animationEventbus)
            : Layer(keyboard, mouse, animationEventbus), m_assetManager(assetManager), m_gameMode(std::move(gameMode)), m_registry(registry),
            m_eventBus(eventBus), m_audioSystem(m_registry)  {
        }

        void onUpdate(float deltaTime) override;

    protected:
        void onAttachImpl() override;
    private:
        engine::AssetManager& m_assetManager;
        std::shared_ptr<ludo::LudoGameMode> m_gameMode;
        engine::EntityRegistry& m_registry;
        engine::Entity m_diceSoundEntity;
        engine::EventBus<LudoEvent>& m_eventBus;
        engine::audio::AudioSystem m_audioSystem;
    };

}

#endif //COLORRACE_AUDIOLAYER_H
