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
@@ -4,7 +4,7 @@
|
||||
// T1 factory — tots els tipus es registren i es creen.
|
||||
// T2 loader — llegeix `data/maps/test_entities.yaml` i retorna els spawns.
|
||||
// T3 event bus — subscribe + publish + payload (entity*, int).
|
||||
// T4 sarcòfag — perímetre computat correctament; notifyTileEntered
|
||||
// T4 sarcòfag — perímetre computat correctament; notifyTilePainted
|
||||
// passa a OPENING quan es visiten tots els tiles.
|
||||
// T5 manager — 2 sarcs + 1 door: forçant l'obertura dels sarcs, la porta
|
||||
// s'obri sola; contactar la porta OPEN emet `level_complete`.
|
||||
@@ -138,14 +138,14 @@ namespace {
|
||||
REQUIRE(sarc->getState() == Sarcophagus::State::CLOSED);
|
||||
|
||||
// Visitem un tile que NO és al perímetre: res canvia.
|
||||
sarc->notifyTileEntered(5, 5);
|
||||
sarc->notifyTilePainted(5, 5);
|
||||
REQUIRE(sarc->getVisitedCount() == 0);
|
||||
|
||||
// Visitem tots els del perímetre.
|
||||
const std::vector<std::pair<int, int>> PERIM = {
|
||||
{1, 0}, {2, 0}, {3, 0}, {1, 2}, {2, 2}, {3, 2}, {0, 1}, {4, 1},
|
||||
};
|
||||
for (const auto& [c, r] : PERIM) { sarc->notifyTileEntered(c, r); }
|
||||
for (const auto& [c, r] : PERIM) { sarc->notifyTilePainted(c, r); }
|
||||
REQUIRE(sarc->getVisitedCount() == 8);
|
||||
REQUIRE(sarc->getState() == Sarcophagus::State::OPENING);
|
||||
|
||||
@@ -186,12 +186,12 @@ namespace {
|
||||
const int W = s->getTileWidth();
|
||||
const int H = s->getTileHeight();
|
||||
for (int dc = 0; dc < W; ++dc) {
|
||||
s->notifyTileEntered(COL0 + dc, ROW0 - 1);
|
||||
s->notifyTileEntered(COL0 + dc, ROW0 + H);
|
||||
s->notifyTilePainted(COL0 + dc, ROW0 - 1);
|
||||
s->notifyTilePainted(COL0 + dc, ROW0 + H);
|
||||
}
|
||||
for (int dr = 0; dr < H; ++dr) {
|
||||
s->notifyTileEntered(COL0 - 1, ROW0 + dr);
|
||||
s->notifyTileEntered(COL0 + W, ROW0 + dr);
|
||||
s->notifyTilePainted(COL0 - 1, ROW0 + dr);
|
||||
s->notifyTilePainted(COL0 + W, ROW0 + dr);
|
||||
}
|
||||
};
|
||||
forceOpen(s1);
|
||||
@@ -310,7 +310,9 @@ namespace {
|
||||
REQUIRE(ANCHOR_ROW == 4);
|
||||
|
||||
// 4) Fan-out del bus: un sarcòfag ancorat a (3,4) mida 3×1 rep via
|
||||
// on_tile_entered una visita sobre el seu perímetre → state canvia.
|
||||
// tile_painted una notificació sobre cada tile del seu perímetre
|
||||
// → state canvia. Publiquem directament `tile_painted` (sense
|
||||
// passar pel PaintLayer) per aïllar el fan-out de l'EntityManager.
|
||||
EntityManager manager;
|
||||
auto sarc = std::make_unique<Sarcophagus>(EntityLoader::loadTemplate("sarcophagus"));
|
||||
sarc->place(3, 4, {});
|
||||
@@ -323,7 +325,7 @@ namespace {
|
||||
{2, 4}, {6, 4},
|
||||
};
|
||||
for (const auto& [c, r] : PERIM) {
|
||||
manager.getBus().publish("on_tile_entered", TilePos{.col = c, .row = r});
|
||||
manager.getBus().publish("tile_painted", TilePos{.col = c, .row = r});
|
||||
}
|
||||
REQUIRE(sarc_raw->getState() == Sarcophagus::State::OPENING);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user