feat(entities): integració del sistema d'entitats al GameScene

This commit is contained in:
JailDesigner committed 2026-04-21 13:55:21 +02:00
1 parent 96b71b0f65
commit 7191a08618
16 files changed
+683 -15

No files matched your search

+19
View File
@@ -6,6 +6,11 @@
#include "game/entities/concrete/sarcophagus.hpp"
#include "game/entities/entity.hpp"
// NOTA: `loadFromLevel` viu a `entity_manager_loadlevel.cpp` per evitar
// arrossegar `Resource::Cache`, `Surface` i les seues dependències (GIF,
// àudio) a consumidors que només volen la base del manager — en
// particular, el smoke test stand-alone.
EntityManager::EntityManager() {
// Subscripció al bus: cada sarcòfag obert incrementa el comptador;
// quan iguala el total registrat, obrim la porta. La subscripció
@@ -16,10 +21,19 @@ EntityManager::EntityManager() {
door_->open();
}
});
// Subscripció al moviment del jugador: quan publica `on_tile_entered`
// amb payload `TilePos`, fem fan-out a totes les entitats perquè els
// sarcòfags puguin actualitzar el seu `visited_`.
tile_sub_id_ = bus_.subscribe("on_tile_entered", [this](const Event& ev) {
const auto* tile = std::get_if<TilePos>(&ev.payload);
if (tile != nullptr) { notifyPlayerEnteredTile(tile->col, tile->row); }
});
}
EntityManager::~EntityManager() {
bus_.unsubscribe(sarc_sub_id_);
bus_.unsubscribe(tile_sub_id_);
}
auto EntityManager::add(std::unique_ptr<Entity> entity) -> Entity* {
@@ -53,3 +67,8 @@ void EntityManager::update(float delta_time) {
void EntityManager::notifyPlayerEnteredTile(int col, int row) {
for (auto& e : entities_) { e->notifyTileEntered(col, row); }
}
// NOTA: `renderAll` es defineix a `entity_manager_loadlevel.cpp`. Conté
// blits via `Surface::render`, que dragaria el pipeline complet de render
// (GIF, Canvas, Screen, àudio...) al smoke test. Separar-lo manté el smoke
// autocontingut.