ColorRace/game/src/ludo/PiecePresenter.h
2026-08-05 17:26:57 +02:00

44 lines
1.8 KiB
C++

//
// Created by sebastian on 02.08.26.
//
#ifndef COLORRACE_PIECEPRESENTER_H
#define COLORRACE_PIECEPRESENTER_H
#include <optional>
#include <utility>
#include "BoardLayout.h"
#include "LudoGameState.h"
#include "core/animation/events/AnimationMarkerEvent.h"
#include "core/audio/SoundSource.h"
#include "core/events/EventBus.h"
#include "ecs/EntityRegistry.h"
#include "loader/assets/AssetManager.h"
#include "loader/models/Model.h"
namespace ludo {
class PiecePresenter {
public:
PiecePresenter(engine::EventBus<engine::animation::AnimationMarkerEvent>& animationEventbus, engine::EntityRegistry& registry, std::unordered_map<std::string, std::shared_ptr<engine::Model>> pieceModels, std::unordered_map<std::string, std::shared_ptr<engine::audio::SoundBuffer>> pieceSounds, std::shared_ptr<engine::Model> boardModel)
: m_registry(registry), m_pieceModels(std::move(pieceModels)), m_pieceSounds(std::move(pieceSounds)), m_layout(std::move(boardModel)), m_animationEventBus(animationEventbus) {}
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;
std::unordered_map<std::string, std::shared_ptr<engine::audio::SoundBuffer>> m_pieceSounds;
BoardLayout m_layout;
std::vector<engine::Entity> m_pieceEntities;
engine::EventBus<engine::animation::AnimationMarkerEvent>& m_animationEventBus;
};
}
#endif //COLORRACE_PIECEPRESENTER_H