cntrl/src/game/blackout.hpp
dandovlatov faf048c1f2 FBC: NIGHT SHIFT - polished the blackout flow and made skill keys responsive
- Kept the default tactical camera in the projector blackout; lights go out
  ~2 s after crossing the screen (Pending phase with normal play/grace)
- Removed the blackout task HUD (progress card, dots, instructions); replaced
  with close-range world-anchored FBC inspection placards for the screen,
  phones and the glass case
- Fixed manual J/K/U presses feeling dead: queued a press while the skill is on
  cooldown and flashed the HUD stamp immediately; cleared the queue on autoplay
  toggle and during the pocket. Added a regression test
- Added a --blackout-near-phone QA hook; updated design docs and README
2026-11-25 00:20:49 +04:00

63 lines
2.6 KiB
C++

#pragma once
#include "core/events.hpp"
#include "core/math.hpp"
#include "game/floor.hpp"
struct Player;
// The projector-screen pocket ritual: walk into the screen, walk over all 20
// 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, 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;
}
bool complete() const { return phase_ == BlackoutPhase::Complete; }
BlackoutPhase phase() const { return phase_; }
int answered() const { return answered_count_; }
bool phone_answered(int i) const { return answered_[i]; }
Vec2 screen_pos() const { return screen_pos_; }
Vec2 case_pos() const { return case_pos_; }
Vec2 phone(int i) const { return phones_[i]; }
// True when the player's centre is inside the (non-colliding) screen footprint.
bool entered(Vec2 pos) const;
void begin(EventQueue& events);
void dev_reveal(EventQueue& events); // QA: jump straight to the glass case
// Returns true on the tick the case is entered (lights come back).
bool update(float dt, const Player& player, EventQueue& events, bool autoplay);
private:
void answer(int index, EventQueue& events);
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]{};
Vec2 screen_pos_{};
float screen_half_w_ = 9.0f;
float screen_half_d_ = 3.0f;
Vec2 phones_[kPhoneCount]{};
Vec2 case_pos_{};
};