//
// Created by sebastian on 02.08.26.
//

#ifndef COLORRACE_PIECEPRESENTER_H
#define COLORRACE_PIECEPRESENTER_H
#include <optional>

#include "BoardLayout.h"
#include "LudoGameState.h"
#include "ecs/EntityRegistry.h"
#include "loader/assets/AssetManager.h"
#include "loader/models/Model.h"


namespace ludo {
    class PiecePresenter {
    public:
        PiecePresenter(engine::EntityRegistry& registry, std::unordered_map<std::string, std::shared_ptr<engine::Model>> pieceModels, BoardLayout& layout)
            : m_registry(registry), m_pieceModels(std::move(pieceModels)), m_layout(layout) {}

        void spawnPieces(const ludo::LudoGameState& state);
        void onPieceMoved(const ludo::PieceMovedEvent& event, const ludo::LudoGameState& state);
        [[nodiscard]] const std::vector<engine::Entity>& getPieceEntities() const { return m_pieceEntities; }

        [[nodiscard]] std::optional<int> getPieceIndex(std::optional<engine::Entity>::value_type entity);

    private:
        engine::EntityRegistry& m_registry;
        std::unordered_map<std::string, std::shared_ptr<engine::Model>> m_pieceModels;
        BoardLayout& m_layout;
        std::vector<engine::Entity> m_pieceEntities;
    };
}


#endif //COLORRACE_PIECEPRESENTER_H
