From 79a2502a0a649e4a2d432d71030ed54e5f1cd966 Mon Sep 17 00:00:00 2001 From: dandovlatov Date: Wed, 25 Nov 2026 00:20:49 +0400 Subject: [PATCH] FBC: NIGHT SHIFT - blackout polish and responsive skill keys - Keep the default tactical camera in the projector blackout; lights go out ~2 s after crossing the screen (Pending phase with normal play/grace) - Remove the blackout task HUD (progress card, dots, instructions); replace with close-range world-anchored FBC inspection placards for the screen, phones and the glass case - Fix manual J/K/U presses feeling dead: queue a press while the skill is on cooldown and flash the HUD stamp immediately; clear the queue on autoplay toggle and during the pocket. Add regression test - Add --blackout-near-phone QA hook; update design docs and README --- README.md | 5 ++- docs/BLACKOUT_RITUAL.md | 41 ++++++++++++-------- docs/GAME_DESIGN.md | 8 +++- src/game/blackout.cpp | 25 ++++++++++-- src/game/blackout.hpp | 8 +++- src/game/game.cpp | 26 +++++++------ src/game/game.hpp | 1 - src/game/skills.cpp | 64 +++++++++++++++++++++++++++---- src/game/skills.hpp | 7 ++++ src/main.cpp | 7 ++++ src/render/presenter.cpp | 82 ++++++++++++++++++++++++++++++++-------- src/render/presenter.hpp | 2 + src/render/ui.cpp | 40 ++++---------------- tests/blackout_test.cpp | 11 ++++-- tests/skills_test.cpp | 24 ++++++++++++ 15 files changed, 256 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 44d20c5..f3e55b7 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ area blasts in the open-plan room for litter/destruction VFX look-dev), `--plaza-test` (start in the central plaza hub scene), `--office-test` (start in the office suite and inspect its destructible paper/bins), `--blackout-test` (start inside the projector screen), `--blackout-auto` -(auto-answer the phones), `--blackout-reveal` (QA the glass case), +(auto-answer the phones), `--blackout-reveal` (QA the glass case), `--blackout-near-phone` (QA inspection), `--fov `, `--cam-height ` and `--cam-forward ` for camera framing captures; F12 saves a screenshot on demand. Hiss corruption is visualised on enemies carrying an active enemy-channel buff (burn/slow/vulnerable/resonance) and on Objects of Power. @@ -157,6 +157,9 @@ set `CNTRL_LEVEL` to import a different level file. | K / gamepad B | WARP — magnetize enemies together, then collapse them | | U / gamepad face-left | FLUORESCENT (earned in the projector-screen blackout) | | L / gamepad Back | Toggle skill autoplay (AUTO / MANUAL / OFF on the HUD stamps) | + +Skill keys fire immediately when ready; if autoplay has spent the cooldown the +press is queued until it recovers, and the HUD stamp flashes on every press. | R | Restart run (on death) | | Esc | Quit | diff --git a/docs/BLACKOUT_RITUAL.md b/docs/BLACKOUT_RITUAL.md index efb07f4..d5fc093 100644 --- a/docs/BLACKOUT_RITUAL.md +++ b/docs/BLACKOUT_RITUAL.md @@ -26,17 +26,19 @@ Design pillars it respects: move and Evade. - **Mega Man reward.** Completing the ritual grants a permanent OoP (an active skill) for the rest of the run. -- **Readable in one glance.** Unanswered phones glow red; answered ones go - dark. The HUD shows `PHONES ANSWERED n / 20` and one dot per phone. +- **No task list.** There is no progress counter, dot row or instruction card. + Unanswered phones glow red; answered ones go dark. Progress is read from the + room itself. Close-range, world-anchored FBC placards are the only prompt. ## 2. Experience flow -| Phase | Player sees | Player does | HUD | +| Phase | Player sees | Player does | Diegetic cue | |---|---|---|---| -| `Idle` | Normal Projector Room; the screen is just set dressing | Walk into the screen footprint (≈18 × 6 m) | `OoP DETECTED` banner: `BLACKOUT — ANSWER ALL 20 PHONES` | -| `Active` | Black room, the agent, 20 glowing phone tables in a 5 × 4 grid | Walk over each of the 20 phones (order irrelevant) | `BLACKOUT — THE HOUSE IS RINGING`, progress dots | -| `CaseRevealed` | Same dark room; a glass case with a yellow roof appears at the screen, switch inside | Walk into the case | `LIGHT SWITCH UNGUARDED — ENTER THE CASE` | -| `Complete` | Lights snap back, normal room and horde return | Continue the run | `BLACKOUT CLEARED — FLUORESCENT LIGHT CLAIMED` | +| `Idle` | Normal Projector Room | Approach the screen | Placard at the screen: `PROJECTOR SCREEN / DO NOT LOOK INTO THE IMAGE` | +| `Pending` (2 s) | Normal room, normal camera, lights still on | Walk into the screen footprint (≈18 × 6 m) and stay | The placard is the last hint | +| `Active` | Black room, the agent, 20 red-glowing phone tables in a 5 × 4 grid | Walk over every phone (order irrelevant) | Near a desk: `FBC HOTLINE / LINE STILL OPEN` | +| `CaseRevealed` | Same dark room; a glass case with a yellow roof appears at the screen, switch inside | Walk into the case | Near it: `OBJECT OF POWER / LIGHT SWITCH — CLASS IV` | +| `Complete` | Lights snap back, normal room and horde return | Continue the run | FLUORESCENT skill stamp appears | Edge cases: - Claimed once per run. A floor jump (`blackout.reset()`) makes it claimable @@ -73,12 +75,16 @@ Edge cases: a red ground ring, billboard glow and a pulsing hit-flash), the agent, and the glass case once revealed. Enemies, XP shards, props and post-decay are not drawn. -- A dedicated overhead camera (`height 44`, focus on the grid) frames all 20 - desks and the player at once; the normal tactical framing resumes on exit. +- The **normal tactical camera** follows the player throughout — no camera + switch on entry or exit. The room stays lit for ~2 s after the screen is + crossed (`BlackoutPhase::Pending`); during that grace normal gameplay and + spawns continue, then the lights drop and the blackout pass takes over. - Events `BlackoutStart/Phone/Case/Complete` drive sparks and containment waves; post FX and the containment clock stay visible throughout. -- HUD: a centred yellow-bordered progress card; the objective panel keeps - showing the floor goal so the clock's pressure remains legible. +- No blackout HUD. Only the normal objective panel and containment clock remain, + so the clock's pressure stays legible; the puzzle is read from the world. + `draw_blackout_labels()` projects small FBC placards above the screen, the + nearest unanswered phone (within 6 m) and the case (within 9 m). ## 5. Blender assets (`tools/blender/build_blackout_props.py`) @@ -102,19 +108,22 @@ Source scene: `assets/blender/fbc_blackout_props.blend`. - **Skills:** `SkillType::Fluorescent`, unlock flag, buff application. - **Models:** three `ActorModel` entries + paths; `uAlpha` in `actor.fs`; alpha/blend support in `ModelBank::draw`. -- **Presenter:** `blackout_mode` camera + `draw_blackout()` pass. -- **UI:** blackout progress card, third skill stamp, custom completion banner. +- **Presenter:** `draw_blackout()` pass and `draw_blackout_labels()` placards — + the default camera is retained. +- **UI:** no blackout task card; world-anchored inspection placards, third skill stamp. - **Input:** `U` / gamepad face-left (autoplay means no key is required). - **Dev hooks:** `--blackout-test` (start inside the screen), `--blackout-auto` (answer phones automatically), - `--blackout-reveal` (jump to the glass case for QA). + `--blackout-reveal` (jump to the glass case for QA), + `--blackout-near-phone` (QA the inspection placard). - **Tests:** `tests/blackout_test.cpp` (CTest `blackout_ritual`). ## 7. Verification gates - `cmake --build build -j6` clean; `ctest --test-dir build` 8/8 pass. -- `./build/cntrl --blackout-test --screenshot ... --screenshot-at 2` shows the - dark room, all 20 tables and the agent. +- `./build/cntrl --blackout-test --screenshot ... --screenshot-at 4` shows the + dark room after the 2 s grace, the agent and nearby phone tables in the + normal tactical camera. - `--blackout-test --blackout-reveal --screenshot ...` shows the yellow-roofed glass case with the switch inside. - `--blackout-test --blackout-auto` completes the ritual and restores the diff --git a/docs/GAME_DESIGN.md b/docs/GAME_DESIGN.md index b0c9a9d..6352099 100644 --- a/docs/GAME_DESIGN.md +++ b/docs/GAME_DESIGN.md @@ -98,7 +98,8 @@ AWE: NIGHT SHIFT, CONTROL: BREACH PROTOCOL). draws a plate until art lands); the HUD completes with `RITUAL COMPLETE — Fluorescents revived`. **Projector-screen blackout (implemented, see `docs/BLACKOUT_RITUAL.md`):** - the Projector Room's big screen is a threshold. Walk into it and the House + the Projector Room's big screen is a threshold. Walk into it and, after a + ~2 s beat (normal camera and lighting continue during the grace), the House goes black — only the agent and **20 red-phone tables** (a fixed 5 × 4 grid) are drawn. Walk over all 20 phones (no order, no wrong answers); a translucent glass case with a **yellow Board roof** and the Light Switch inside appears @@ -138,7 +139,10 @@ Every active skill also **autoplays** when the player hasn't pressed its key recently — a manual press takes control for a few seconds, then autoplay resumes; `[L]` disables autoplay for players who want fully manual skills. New active skills join the same `SkillSystem` cast/autoplay path, so the -no-button playstyle keeps working. +no-button playstyle keeps working. A manual press is **queued while the skill +cools down** (autoplay otherwise keeps the cooldown spent, making J/K feel +dead), and the HUD stamp flashes white on every press. The queued cast fires as +soon as the skill is ready; pressing `[L]` back into autoplay drops any queue. ## 3. Corruption — Risk of Rain 2 progressive difficulty, FBC skin diff --git a/src/game/blackout.cpp b/src/game/blackout.cpp index df0d3bf..db29ea3 100644 --- a/src/game/blackout.cpp +++ b/src/game/blackout.cpp @@ -37,6 +37,7 @@ void BlackoutSequence::init(const Floor& floor) { void BlackoutSequence::reset() { phase_ = BlackoutPhase::Idle; answered_count_ = 0; + delay_ = 0.0f; cooldown_ = 0.0f; auto_timer_ = 0.0f; for (bool& done : answered_) done = false; @@ -50,15 +51,19 @@ bool BlackoutSequence::entered(Vec2 pos) const { void BlackoutSequence::begin(EventQueue& events) { if (phase_ != BlackoutPhase::Idle) return; - phase_ = BlackoutPhase::Active; + // The House waits a beat before swallowing the room: normal play and the + // normal camera continue for kLightsOutDelay seconds. + phase_ = BlackoutPhase::Pending; + delay_ = kLightsOutDelay; answered_count_ = 0; - cooldown_ = 0.6f; + cooldown_ = 0.0f; auto_timer_ = 0.0f; - events.push(EventType::BlackoutStart, screen_pos_); } void BlackoutSequence::dev_reveal(EventQueue& events) { - if (phase_ != BlackoutPhase::Active) return; + if (phase_ == BlackoutPhase::Complete) return; + phase_ = BlackoutPhase::Active; + delay_ = 0.0f; for (int i = 0; i < kPhoneCount; ++i) answered_[i] = true; answered_count_ = kPhoneCount; phase_ = BlackoutPhase::CaseRevealed; @@ -82,6 +87,18 @@ void BlackoutSequence::answer(int index, EventQueue& events) { bool BlackoutSequence::update(float dt, const Player& player, EventQueue& events, bool autoplay) { bool entered_case = false; + + if (phase_ == BlackoutPhase::Pending) { + delay_ -= dt; + if (delay_ <= 0.0f) { + delay_ = 0.0f; + phase_ = BlackoutPhase::Active; + cooldown_ = 0.6f; + events.push(EventType::BlackoutStart, screen_pos_); + } + return false; + } + cooldown_ = std::max(0.0f, cooldown_ - dt); if (phase_ == BlackoutPhase::Active) { diff --git a/src/game/blackout.hpp b/src/game/blackout.hpp index 171f093..9a12999 100644 --- a/src/game/blackout.hpp +++ b/src/game/blackout.hpp @@ -10,17 +10,22 @@ struct Player; // red Hotline phones scattered on little desks, then step into the glass case // under the yellow Board roof. Proximity only -- no interact key. Pure sim // state; the presenter renders the black room. -enum class BlackoutPhase { Idle, Active, CaseRevealed, Complete }; +enum class BlackoutPhase { Idle, Pending, Active, CaseRevealed, Complete }; class BlackoutSequence { public: static constexpr int kPhoneCount = 20; // 5 columns x 4 rows static constexpr float kPhoneRadius = 2.2f; static constexpr float kCaseRadius = 2.6f; + static constexpr float kLightsOutDelay = 2.0f; // grace period in the screen void init(const Floor& floor); // derive layout from the authored Screen prop void reset(); // new floor / new run (keeps the layout) + // Pending is the 2 s grace after crossing the screen: the room is still + // lit and normal gameplay continues until the lights actually go out. + bool pending() const { return phase_ == BlackoutPhase::Pending; } + float delay_left() const { return delay_; } bool active() const { return phase_ == BlackoutPhase::Active || phase_ == BlackoutPhase::CaseRevealed; @@ -46,6 +51,7 @@ private: BlackoutPhase phase_ = BlackoutPhase::Idle; int answered_count_ = 0; + float delay_ = 0.0f; // countdown to lights-out after entering the screen float cooldown_ = 0.0f; // prevents one standing position answering twice float auto_timer_ = 0.0f; // dev --blackout-auto cadence bool answered_[kPhoneCount]{}; diff --git a/src/game/game.cpp b/src/game/game.cpp index f1c3568..392a617 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -124,7 +124,6 @@ void Game::reset() { clearance = 1; floor.reset_doors(); floor_banner = 0.0f; - floor_banner_text = nullptr; side_banner = 0.0f; side_banner_text = ""; for (bool& claimed : side_reward_claimed_) claimed = false; @@ -176,22 +175,21 @@ void Game::update(const InputState& in, float dt) { player_update(player, in, dt, floor); if (blackout.active()) { + // Skills cannot target anything in the pocket, but key presses still + // flash their HUD stamps so the buttons never feel unresponsive. + skill_system.tick_presentation(dt, in); + // The 2 s grace may have let another ritual start; only one at a time. + ritual_system = RitualSystem{}; // Inside the screen: the House holds its breath. The corruption clock // keeps running (the run never pauses) but the Director stops spawning // and the horde freezes outside the pocket. Only the puzzle advances. if (blackout.update(dt, player, events, blackout_auto)) { skill_system.unlock_fluorescent(); floor_banner = std::max(floor_banner, 4.0f); - floor_banner_text = "BLACKOUT CLEARED — FLUORESCENT LIGHT CLAIMED"; } - } else if (blackout.entered(player.pos)) { - // One active ritual at a time: entering the screen replaces whatever - // was in progress and starts the phone chain. - blackout.begin(events); - ritual_system = RitualSystem{}; - floor_banner = std::max(floor_banner, 3.0f); - floor_banner_text = "BLACKOUT — ANSWER ALL 20 PHONES"; } else { + // The 2 s grace after crossing the screen still plays as normal game. + if (blackout.pending()) blackout.update(dt, player, events, false); const bool projector_skill_claimed = ritual_system.type() == RitualType::Projector && ritual_system.complete(); ritual_system.update(dt, player, buff_system, enemy_system); @@ -237,6 +235,14 @@ void Game::update(const InputState& in, float dt) { for (const Offer& o : offers) pending_offers.push_back(o); offer_timer = 3.0f; } + + // Crossing the screen arms the ritual; the lights go out 2 s later. + // One active ritual at a time: this replaces whatever was in progress. + if (blackout.entered(player.pos)) { + blackout.begin(events); + ritual_system = RitualSystem{}; + floor_banner = std::max(floor_banner, 3.0f); + } } player.hp = std::min(player.stats.max_hp, player.hp + player.stats.regen * dt); @@ -251,7 +257,6 @@ void Game::floor_pass() { if (!has_key && distance(player.pos, floor.key_pos()) <= floor.key_radius()) { has_key = true; floor_banner = 3.0f; - floor_banner_text = nullptr; events.push(EventType::KeyAcquired, floor.key_pos()); return; } @@ -267,7 +272,6 @@ void Game::floor_pass() { floor.unlock_all_doors(); for (bool& claimed : side_reward_claimed_) claimed = false; floor_banner = 4.0f; - floor_banner_text = nullptr; has_key = false; events.push(EventType::FloorCleared, floor.door_pos(), static_cast(floor_number)); diff --git a/src/game/game.hpp b/src/game/game.hpp index df5e796..3efb350 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -71,7 +71,6 @@ public: int floor_clears = 0; int clearance = 1; // diegetic stamp; gates the three side-room doors float floor_banner = 0.0f; - const char* floor_banner_text = nullptr; // overrides the default key/floor banner float side_banner = 0.0f; const char* side_banner_text = ""; int kills = 0; diff --git a/src/game/skills.cpp b/src/game/skills.cpp index 6a05096..d094480 100644 --- a/src/game/skills.cpp +++ b/src/game/skills.cpp @@ -174,32 +174,80 @@ float skill_cooldown(SkillType type) { void SkillSystem::reset() { for (float& cd : cooldowns) cd = 0.0f; + for (bool& q : queued) q = false; + for (float& f : press_feedback) f = 0.0f; manual_hold = 0.0f; autoplay_enabled = true; piles.clear(); warps.clear(); } +void SkillSystem::note_input(const InputState& in) { + if (in.skill_concrete) { + manual_hold = kManualHold; + queued[static_cast(SkillType::ConcreteCall)] = true; + press_feedback[static_cast(SkillType::ConcreteCall)] = 0.35f; + } + if (in.skill_warp) { + manual_hold = kManualHold; + queued[static_cast(SkillType::Warp)] = true; + press_feedback[static_cast(SkillType::Warp)] = 0.35f; + } + if (in.skill_fluorescent) { + manual_hold = kManualHold; + queued[static_cast(SkillType::Fluorescent)] = true; + press_feedback[static_cast(SkillType::Fluorescent)] = 0.35f; + } +} + void SkillSystem::reset_all() { reset(); fluorescent_unlocked = false; } +void SkillSystem::tick_presentation(float dt, const InputState& in) { + for (float& f : press_feedback) f = std::max(0.0f, f - dt); + if (in.skill_concrete) press_feedback[static_cast(SkillType::ConcreteCall)] = 0.35f; + if (in.skill_warp) press_feedback[static_cast(SkillType::Warp)] = 0.35f; + if (in.skill_fluorescent) press_feedback[static_cast(SkillType::Fluorescent)] = 0.35f; +} + void SkillSystem::update(float dt, const InputState& in, Player& player, EnemySystem& enemies, BuffSystem& buffs, EventQueue& events) { - if (in.toggle_autoplay) autoplay_enabled = !autoplay_enabled; + if (in.toggle_autoplay) { + autoplay_enabled = !autoplay_enabled; + for (bool& q : queued) q = false; + } manual_hold = std::max(0.0f, manual_hold - dt); for (float& cd : cooldowns) cd = std::max(0.0f, cd - dt); + for (float& f : press_feedback) f = std::max(0.0f, f - dt); - if (in.skill_concrete || in.skill_warp || in.skill_fluorescent) { - // A manual press takes control; autoplay stays off for a short window - // even if the skill is still cooling down. - manual_hold = kManualHold; + // A manual press takes control for a short window and is remembered while + // the skill cools down — autoplay otherwise keeps the cooldown spent and + // the key would look dead. + note_input(in); + if (manual_hold <= 0.0f) for (bool& q : queued) q = false; + + const int ci = static_cast(SkillType::ConcreteCall); + const int wi = static_cast(SkillType::Warp); + const int fi = static_cast(SkillType::Fluorescent); + // A successful cast resets the cooldown upward; an aborted attempt only + // ticks it down. Only the former clears the remembered press. + const float before_c = cooldowns[ci], before_w = cooldowns[wi], + before_f = cooldowns[fi]; + if (in.skill_concrete || queued[ci]) { + try_cast(*this, player, enemies, events); + if (cooldowns[ci] > before_c) queued[ci] = false; + } + if (in.skill_warp || queued[wi]) { + try_cast_warp(*this, player, enemies, events); + if (cooldowns[wi] > before_w) queued[wi] = false; + } + if (in.skill_fluorescent || queued[fi]) { + try_cast_fluorescent(*this, player, enemies, buffs, events); + if (cooldowns[fi] > before_f) queued[fi] = false; } - if (in.skill_concrete) try_cast(*this, player, enemies, events); - if (in.skill_warp) try_cast_warp(*this, player, enemies, events); - if (in.skill_fluorescent) try_cast_fluorescent(*this, player, enemies, buffs, events); if (autoplay_active()) { // Generic autoplay: every skill is cast from this same path when the // player isn't driving them by hand. diff --git a/src/game/skills.hpp b/src/game/skills.hpp index b495fe8..3c5308e 100644 --- a/src/game/skills.hpp +++ b/src/game/skills.hpp @@ -46,12 +46,19 @@ struct SkillSystem { float manual_hold = 0.0f; // manual-control window after a key press bool autoplay_enabled = true; bool fluorescent_unlocked = false; // claimed from the projector-screen case + // A manual press is remembered while the skill cools down, so J/K never + // feel like dead keys when autoplay has already spent the cooldown. + bool queued[kSkillCount]{}; + float press_feedback[kSkillCount]{}; // brief HUD flash on any key press DensePool piles{16}; DensePool warps{4}; void reset(); // does not clear the unlock void reset_all(); // new run: clears the unlock too void unlock_fluorescent() { fluorescent_unlocked = true; } + // Presentation-only feedback while combat is suspended (blackout pocket). + void note_input(const InputState& in); + void tick_presentation(float dt, const InputState& in); void update(float dt, const InputState& in, Player& player, EnemySystem& enemies, BuffSystem& buffs, EventQueue& events); diff --git a/src/main.cpp b/src/main.cpp index 65a4c7c..f35833e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,6 +51,7 @@ struct Options { bool blackout_test = false; // --blackout-test: start inside the screen bool blackout_auto = false; // --blackout-auto: auto-answer phones bool blackout_reveal = false; // --blackout-reveal: QA the glass case + bool blackout_near_phone = false; // --blackout-near-phone: QA inspection bool fullscreen = false; // --fullscreen: borderless fullscreen int aniso = 0; // --aniso 0|4|8: concrete texture filtering float fov = 0.0f; // --fov : initial camera FOV @@ -105,6 +106,8 @@ Options parse_options(int argc, char** argv) { opts.blackout_auto = true; } else if (std::strcmp(argv[i], "--blackout-reveal") == 0) { opts.blackout_reveal = true; + } else if (std::strcmp(argv[i], "--blackout-near-phone") == 0) { + opts.blackout_near_phone = true; } else if (std::strcmp(argv[i], "--fullscreen") == 0) { opts.fullscreen = true; } else if (std::strcmp(argv[i], "--aniso") == 0 && i + 1 < argc) { @@ -282,6 +285,10 @@ int main(int argc, char** argv) { game.blackout.dev_reveal(game.events); // Step back so the QA capture shows the case before it is claimed. game.player.pos = game.blackout.phone(0); + } else if (opts.blackout_near_phone) { + // Stand beside (not on) a desk: close enough to inspect, far enough + // not to answer it by proximity. + game.player.pos = game.blackout.phone(7) + Vec2{3.0f, 0.0f}; } } Presenter presenter; diff --git a/src/render/presenter.cpp b/src/render/presenter.cpp index 73e3ea0..c4ef96f 100644 --- a/src/render/presenter.cpp +++ b/src/render/presenter.cpp @@ -1099,6 +1099,51 @@ void Presenter::draw_environment(const Game& game, const ViewCull& cull) { } } +namespace { + +// Small FBC placard that only reveals itself when the player walks up to it. +void draw_inspection_placard(Vector2 screen, const char* title, + const char* sub, Color accent) { + const int w = std::max(MeasureText(title, 12), MeasureText(sub, 11)) + 18; + const int x = static_cast(screen.x) - w / 2; + const int y = static_cast(screen.y) - 36; + DrawRectangle(x, y, w, 34, Color{10, 10, 12, 215}); + DrawRectangleLines(x, y, w, 34, Color{accent.r, accent.g, accent.b, 180}); + DrawText(title, x + 9, y + 3, 12, accent); + DrawText(sub, x + 9, y + 18, 11, Color{205, 200, 190, 220}); +} + +} // namespace + +void Presenter::draw_blackout_labels(const Game& game) { + const BlackoutSequence& b = game.blackout; + const Vec2 p = game.player.pos; + + int nearest = -1; + float best = 6.0f; // inspection range + for (int i = 0; i < BlackoutSequence::kPhoneCount; ++i) { + if (b.phone_answered(i)) continue; + const float d = distance(p, b.phone(i)); + if (d < best) { + best = d; + nearest = i; + } + } + if (nearest >= 0) { + const Vec2 q = b.phone(nearest); + const Vector2 s = GetWorldToScreen({q.x, 1.4f, q.y}, camera_); + draw_inspection_placard(s, "FBC HOTLINE", "LINE STILL OPEN", + Color{245, 197, 24, 255}); + } + if (b.phase() == BlackoutPhase::CaseRevealed && + distance(p, b.case_pos()) < 9.0f) { + const Vec2 c = b.case_pos(); + const Vector2 s = GetWorldToScreen({c.x, 2.8f, c.y}, camera_); + draw_inspection_placard(s, "OBJECT OF POWER", "LIGHT SWITCH / CLASS IV", + Color{245, 197, 24, 255}); + } +} + // Inside the projector screen the House goes dark: only the agent, the ringing // phone tables and (once earned) the glass case survive the blackout. void Presenter::draw_blackout(Game& game) { @@ -1123,18 +1168,18 @@ void Presenter::draw_blackout(Game& game) { const Vec2 q = b.phone(i); const bool answered = b.phone_answered(i); const float pulse = 0.5f + 0.5f * std::sin(anim_time_ * 4.0f + i * 0.7f); - const float ring_flash = answered ? 0.0f : 0.25f + 0.4f * pulse; + const float ring_flash = answered ? 0.0f : 0.10f + 0.25f * pulse; models_.draw(ActorModel::PhoneTable, {q.x, 0.0f, q.y}, 0.0f, 0.78f, answered ? Color{80, 80, 86, 255} : WHITE, ring_flash, false, 0.0f, 0.0f, anim_time_ * (answered ? 0.2f : 1.2f)); if (!answered) { - DrawCylinder({q.x, 0.04f, q.y}, 1.5f, 1.5f, 0.012f, 14, - Color{255, 45, 55, static_cast(110 + 60 * pulse)}); - glow_batch.add_billboard({q.x, 1.35f, q.y}, 6.0f, 6.0f, + DrawCylinder({q.x, 0.04f, q.y}, 0.9f, 0.9f, 0.012f, 12, + Color{255, 45, 55, static_cast(70 + 40 * pulse)}); + glow_batch.add_billboard({q.x, 1.15f, q.y}, 3.2f, 3.2f, cam_right, cam_up, - Color{255, 80, 90, 255}); - glow_batch.add_ground({q.x, 0.02f, q.y}, 2.2f, - Color{220, 30, 40, 120}); + Color{255, 80, 90, 200}); + glow_batch.add_ground({q.x, 0.02f, q.y}, 1.4f, + Color{220, 30, 40, 85}); } } @@ -1306,7 +1351,6 @@ void Presenter::draw_scene(Game& game) { const float sx = static_cast(GetRandomValue(-100, 100)) / 100.0f * shake_; const float sy = static_cast(GetRandomValue(-100, 100)) / 100.0f * shake_; const Vec2 p = game.player.pos; - const BlackoutSequence& b = game.blackout; // Keep the arena rim out of frame when the player hugs a wall — showing // the unlit floor beyond the curb breaks the contained-facility illusion. const float margin = 10.0f; @@ -1316,13 +1360,7 @@ void Presenter::draw_scene(Game& game) { : game.config.arena_half - margin; const float cx = std::clamp(p.x, -bound_x, bound_x); const float cz = std::clamp(p.y, -bound_z, bound_z); - if (game.blackout.active()) { - // Wide overhead framing so the whole 5 x 4 phone grid and the agent - // fit in one shot — the player must see every table in the dark. - const Vec2 focus{b.screen_pos().x, b.screen_pos().y + 12.0f}; - camera_.position = {focus.x, 44.0f, focus.y + 5.0f}; - camera_.target = {focus.x, 0.0f, focus.y}; - } else if (floor_overview_) { + if (floor_overview_) { camera_.position = {0.0f, Floor::kHeight * 1.23f, 0.01f}; camera_.target = {0.0f, 0.0f, 0.0f}; } else if (hiss_test_) { @@ -1363,6 +1401,7 @@ void Presenter::draw_scene(Game& game) { if (game.blackout.active()) { draw_blackout(game); EndMode3D(); + draw_blackout_labels(game); return; } @@ -1619,6 +1658,19 @@ void Presenter::draw_scene(Game& game) { static_cast(screen.y) - 14, 12, Color{255, 255, 255, 200}); } + // The screen carries a redacted placard; it only reads up close. No task + // list, no counter — the player has to inspect the room to find the beat. + if (!game.blackout.complete()) { + const Vec2 screen_pos = game.blackout.screen_pos(); + if (distance(p, screen_pos) < 10.0f) { + const Vector2 s = GetWorldToScreen({screen_pos.x, 4.6f, screen_pos.y}, + camera_); + draw_inspection_placard(s, "PROJECTOR SCREEN", + "DO NOT LOOK INTO THE IMAGE", + Color{245, 197, 24, 255}); + } + } + // World-anchored health bars for damaged enemies. for (const Enemy& e : game.enemy_system.enemies) { if (e.hp >= e.max_hp) continue; diff --git a/src/render/presenter.hpp b/src/render/presenter.hpp index d60dd2d..095e08c 100644 --- a/src/render/presenter.hpp +++ b/src/render/presenter.hpp @@ -71,6 +71,8 @@ private: void draw_floor_environment(const Game& game, const ViewCull& cull); // Projector-screen pocket: black room, player, red phone tables, glass case. void draw_blackout(Game& game); + // Close-range, world-anchored placards replace the old task HUD. + void draw_blackout_labels(const Game& game); void draw_initial_scene(const Game& game, const ViewCull& cull); void draw_office_suite(const Game& game, const ViewCull& cull); void spawn_sparks(Vec2 pos, float height, Color color, int count, float speed); diff --git a/src/render/ui.cpp b/src/render/ui.cpp index a652c97..b6afd4c 100644 --- a/src/render/ui.cpp +++ b/src/render/ui.cpp @@ -63,6 +63,11 @@ void draw_skill_icon(const Game& game, SkillType type, float x, float y, ui_font::draw_text(wait, static_cast(x) + static_cast(size) - 28, static_cast(y) + 3, 12, stamp); } + // Any key press flashes the stamp immediately, even while cooling down. + if (skills.press_feedback[static_cast(type)] > 0.0f) { + DrawRectangleLinesEx({x - 3.0f, y - 3.0f, size + 6.0f, size + 6.0f}, + 2.0f, Color{255, 255, 255, 235}); + } const char* title = skill_name(type); ui_font::draw_text(title, static_cast(x + size / 2.0f) @@ -138,10 +143,8 @@ void draw_hud(const Game& game) { ui_font::draw_text(objective, px + panel_w / 2 - ow / 2, 46, 16, Color{232, 228, 220, 235}); if (game.floor_banner > 0.0f) { - const char* banner = game.floor_banner_text != nullptr - ? game.floor_banner_text - : (game.has_key ? "THRESHOLD KEY ACQUIRED" - : "FLOOR CLEARED — THE HOUSE NOTICED"); + const char* banner = game.has_key + ? "THRESHOLD KEY ACQUIRED" : "FLOOR CLEARED — THE HOUSE NOTICED"; const int bw = ui_font::measure_text(banner, 18); ui_font::draw_text(banner, GetScreenWidth() / 2 - bw / 2, 108, 18, Color{245, 197, 24, 250}); @@ -190,35 +193,6 @@ void draw_hud(const Game& game) { ui_font::draw_text(done, 20, 70.0f, 16, Color{245, 197, 24, 255}); } - // Projector-screen blackout: progress card replaces the ritual prompt. - if (game.blackout.active()) { - const float card_x = GetScreenWidth() / 2.0f - 230.0f; - DrawRectangle(card_x, 84.0f, 460.0f, 78.0f, Color{8, 8, 11, 235}); - DrawRectangleLines(card_x, 84.0f, 460.0f, 78.0f, - Color{245, 197, 24, 200}); - ui_font::draw_text("BLACKOUT - THE HOUSE IS RINGING", - static_cast(card_x) + 12, 91, 16, - Color{245, 197, 24, 255}); - char phones[64]; - std::snprintf(phones, sizeof(phones), "PHONES ANSWERED %d / %d", - game.blackout.answered(), - BlackoutSequence::kPhoneCount); - ui_font::draw_text(phones, static_cast(card_x) + 12, 114, 15, - Color{230, 226, 218, 255}); - if (game.blackout.phase() == BlackoutPhase::CaseRevealed) { - ui_font::draw_text("LIGHT SWITCH UNGUARDED - ENTER THE CASE", - static_cast(card_x) + 12, 137, 13, - Color{245, 197, 24, 255}); - } else { - for (int i = 0; i < BlackoutSequence::kPhoneCount; ++i) { - const Color dot = game.blackout.phone_answered(i) - ? Color{245, 197, 24, 255} - : Color{90, 26, 32, 255}; - DrawRectangle(card_x + 12.0f + i * 21.0f, 142.0f, 15.0f, 9.0f, dot); - } - } - } - // Owned OoP loadout (left column). float oy = 84.0f; ui_font::draw_text("OoP LOADOUT", 20, oy, 16, Color{245, 197, 24, 235}); diff --git a/tests/blackout_test.cpp b/tests/blackout_test.cpp index b40a898..816e81b 100644 --- a/tests/blackout_test.cpp +++ b/tests/blackout_test.cpp @@ -30,12 +30,17 @@ int main() { check(!b.active() && !b.complete(), "blackout starts idle"); check(!game.skill_system.fluorescent_unlocked, "reward starts locked"); - // Walking into the non-colliding screen begins the puzzle. + // Walking into the non-colliding screen arms the puzzle; the room stays + // lit and the camera stays normal for ~2 s before the lights go out. game.player.pos = b.screen_pos(); game.update(InputState{}, kDt); - check(b.active(), "entering the screen starts blackout"); + check(b.pending() && !b.active(), "entering the screen only arms the blackout"); + check(count_events(game, EventType::BlackoutStart) == 0, + "no lights-out event during the grace period"); + game.update(InputState{}, 2.1f); + check(b.active(), "lights go out ~2 s after entering the screen"); check(count_events(game, EventType::BlackoutStart) == 1, - "blackout start event emitted"); + "blackout start event emitted when lights go out"); // Every unanswered phone can be activated by walking over it; order does // not matter and an already-answered phone is inert. diff --git a/tests/skills_test.cpp b/tests/skills_test.cpp index a5bd8a7..2572336 100644 --- a/tests/skills_test.cpp +++ b/tests/skills_test.cpp @@ -156,6 +156,30 @@ int main() { "warp burst damages the crowd"); } + // --- A manual press during cooldown is queued, not dropped ------------- + { + Game game(11); + spawn_crowd(game); + game.skill_system.autoplay_enabled = false; + const int ci = static_cast(SkillType::ConcreteCall); + game.skill_system.cooldowns[ci] = 0.5f; + + InputState in{}; + in.skill_concrete = true; + game.update(in, kDt); + check(game.skill_system.piles.empty(), "press on cooldown does not double-cast"); + check(game.skill_system.queued[ci], "manual press is queued while cooling down"); + check(game.skill_system.press_feedback[ci] > 0.0f, + "manual press flashes the HUD stamp immediately"); + + in.skill_concrete = false; + for (int tick = 0; tick < 45 && game.skill_system.piles.empty(); ++tick) + game.update(in, kDt); + check(game.skill_system.piles.size() == 1, + "queued manual cast fires as soon as the cooldown ends"); + check(!game.skill_system.queued[ci], "queue clears after the cast"); + } + if (failed) return 1; std::printf("skills: OK\n"); return 0;