refactor(entities): rename notifyTileEntered → notifyTilePainted i escolta tile_painted
This commit is contained in:
1 parent
0f56ce7567
commit
e3cf2eb773
7 files changed
+33
-28
No files matched your search
@@ -24,12 +24,13 @@ EntityManager::EntityManager() {
|
||||
}
|
||||
});
|
||||
|
||||
// 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) {
|
||||
// Subscripció al pintat: el PaintLayer publica `tile_painted` amb
|
||||
// payload `TilePos` un cop ha filtrat pintabilitat i aplicat la regla
|
||||
// "primer que pinta guanya". Fem fan-out a totes les entitats perquè
|
||||
// els sarcòfags puguin actualitzar el seu `visited_`.
|
||||
tile_sub_id_ = bus_.subscribe("tile_painted", [this](const Event& ev) {
|
||||
const auto* tile = std::get_if<TilePos>(&ev.payload);
|
||||
if (tile != nullptr) { notifyPlayerEnteredTile(tile->col, tile->row); }
|
||||
if (tile != nullptr) { notifyPlayerTilePainted(tile->col, tile->row); }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,8 +67,8 @@ void EntityManager::update(float delta_time) {
|
||||
for (auto& e : entities_) { e->update(delta_time); }
|
||||
}
|
||||
|
||||
void EntityManager::notifyPlayerEnteredTile(int col, int row) {
|
||||
for (auto& e : entities_) { e->notifyTileEntered(col, row); }
|
||||
void EntityManager::notifyPlayerTilePainted(int col, int row) {
|
||||
for (auto& e : entities_) { e->notifyTilePainted(col, row); }
|
||||
}
|
||||
|
||||
auto EntityManager::getEntities() const -> std::vector<Entity*> {
|
||||
|
||||
Reference in new issue
Block a user