diff --git a/data/input/keys.yaml b/data/input/keys.yaml index 0c889e4..a6f71cd 100644 --- a/data/input/keys.yaml +++ b/data/input/keys.yaml @@ -53,6 +53,9 @@ keys: - id: next_room code: "]" desc: "Salta a la sala següent del levels.yaml (només Debug)" + - id: open_door + code: "Keypad 1" + desc: "Força l'obertura de la porta de la sala (només Debug)" - id: exit code: "Escape" desc: "Eixir (confirmar amb segona pulsació)" diff --git a/source/game/entities/entity_manager.cpp b/source/game/entities/entity_manager.cpp index 8cf2371..319b061 100644 --- a/source/game/entities/entity_manager.cpp +++ b/source/game/entities/entity_manager.cpp @@ -65,6 +65,10 @@ void EntityManager::setExpectedPlayerCount(int n) { level_complete_emitted_ = false; } +void EntityManager::forceOpenDoor() { + if (door_ != nullptr) { door_->open(); } +} + auto EntityManager::add(std::unique_ptr entity) -> Entity* { if (entity == nullptr) { return nullptr; } entity->setEventBus(&bus_); diff --git a/source/game/entities/entity_manager.hpp b/source/game/entities/entity_manager.hpp index 30453d6..6893cb3 100644 --- a/source/game/entities/entity_manager.hpp +++ b/source/game/entities/entity_manager.hpp @@ -112,6 +112,13 @@ class EntityManager { [[nodiscard]] auto openedSarcophagusCount() const -> std::size_t { return opened_sarcs_; } [[nodiscard]] auto exitedPlayerCount() const -> std::size_t { return exited_players_; } + // Força l'obertura de la porta sense que els sarcòfags estiguin + // oberts. Pensat com a hook de debug per a la GameScene: el flux + // posterior (creuar la porta → `player_exited` → `level_complete` + // → OUTRO) segueix exactament igual perquè depèn de Door, no de + // sarcs. No-op si la porta ja està oberta o si el nivell no en té. + void forceOpenDoor(); + private: EventBus bus_; std::vector> entities_; diff --git a/source/game/scenes/game_scene.cpp b/source/game/scenes/game_scene.cpp index 2f66be5..5a42d74 100644 --- a/source/game/scenes/game_scene.cpp +++ b/source/game/scenes/game_scene.cpp @@ -853,6 +853,14 @@ namespace { } return 0; } + + auto detectOpenDoor() -> bool { + const SDL_Scancode SC = KeyConfig::get().scancode("open_door"); + if (SC == SDL_SCANCODE_UNKNOWN) { return false; } + return std::ranges::any_of(EventBuffer::events, [SC](const SDL_Event& ev) { + return ev.type == SDL_EVENT_KEY_DOWN && ev.key.scancode == SC; + }); + } } // namespace #endif @@ -885,6 +893,15 @@ void GameScene::update(int delta_ms) { enterRoomIntro(); } } + + // Força l'obertura de la porta (Keypad 1). Útil per saltar el + // pintat/sarcs durant proves de progressió. La resta del flux + // (creuar → player_exited → level_complete → OUTRO) es manté. + // Mateixos gates que el salt entre sales. + if (pause_.state == PauseState::IDLE && !editor_.active() && detectOpenDoor()) { + std::cout << "[DEBUG] força obertura de la porta\n"; + entity_manager_.forceOpenDoor(); + } #endif GlobalInputs::update(delta_ms);