feat(stats): Player com a font de veritat de vides/score/tresors i sarcs amb recompensa
This commit is contained in:
1 parent
d186f66c2c
commit
f5d251c33b
14 files changed
+226
-34
No files matched your search
@@ -31,7 +31,7 @@ EntityManager::EntityManager() {
|
||||
// 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) { notifyPlayerTilePainted(tile->col, tile->row); }
|
||||
if (tile != nullptr) { notifyPlayerTilePainted(tile->col, tile->row, ev.player_id); }
|
||||
});
|
||||
|
||||
// Subscripció a `player_exited` (publicat per Door en travessar la
|
||||
@@ -141,12 +141,13 @@ void EntityManager::update(float delta_time) {
|
||||
std::erase_if(entities_, [](const auto& e) { return e->isDead(); });
|
||||
}
|
||||
|
||||
void EntityManager::notifyPlayerTilePainted(int col, int row) {
|
||||
void EntityManager::notifyPlayerTilePainted(int col, int row, int player_id) {
|
||||
// Fan-out polimòrfic a totes les entitats: cada una decideix què fer
|
||||
// (`Sarcophagus` actualitza el seu perímetre, la resta queden en
|
||||
// no-op). Cost d'iterar 40 elements amb crida virtual buida ~ 1 µs;
|
||||
// qui paga el cost guanya simplicitat al callsite.
|
||||
for (auto& e : entities_) { e->notifyTilePainted(col, row); }
|
||||
// (`Sarcophagus` actualitza el seu perímetre i recorda qui va tancar
|
||||
// el cercle, la resta queden en no-op). `player_id` ve del bus
|
||||
// (`ev.player_id`) — pot ser -1 al broadcast de càrrega inicial de
|
||||
// nivell, els consumidors filtren si necessiten atribució.
|
||||
for (auto& e : entities_) { e->notifyTilePainted(col, row, player_id); }
|
||||
}
|
||||
|
||||
auto EntityManager::findFloorTriggerAt(const SDL_FRect& rect) const -> const Entity* {
|
||||
|
||||
Reference in new issue
Block a user