fix(engine): freeze game timers while the Home picker is up
The HUD's elapsed-time counter ticked from the moment the default Classic deal landed at startup, even though the auto-show Home picker was still up — so the player saw "0:11" before they had chosen a mode. Time Attack had the same issue when M was pressed mid-session: the 10-minute countdown burned while the player browsed modes. `tick_elapsed_time` and `advance_time_attack` now also gate on the absence of `HomeScreen`, mirroring their existing `PausedResource` check. The Home modal already covers input via its scrim, so this purely freezes the timer without coupling to the pause-overlay ownership of `PausedResource`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -252,16 +252,20 @@ pub fn advance_elapsed(
|
||||
}
|
||||
|
||||
/// Increment `GameState.elapsed_seconds` once per real-world second while
|
||||
/// the game is in progress (not won) and not paused. Stops counting on
|
||||
/// win so the final time reflects how long the player took to solve the
|
||||
/// deal; stops while the pause overlay is open.
|
||||
/// the game is in progress (not won), not paused, and the launch /
|
||||
/// mode-picker Home modal isn't covering the board. Stops counting on
|
||||
/// win so the final time reflects how long the player took to solve
|
||||
/// the deal; stops while the pause overlay is open; stops while Home
|
||||
/// is up so the timer doesn't tick under the picker before the player
|
||||
/// has actually committed to a deal.
|
||||
fn tick_elapsed_time(
|
||||
time: Res<Time>,
|
||||
mut game: ResMut<GameStateResource>,
|
||||
mut accumulator: Local<f32>,
|
||||
paused: Option<Res<crate::pause_plugin::PausedResource>>,
|
||||
home_screens: Query<(), With<crate::home_plugin::HomeScreen>>,
|
||||
) {
|
||||
if paused.is_some_and(|p| p.0) {
|
||||
if paused.is_some_and(|p| p.0) || !home_screens.is_empty() {
|
||||
return;
|
||||
}
|
||||
let is_won = game.0.is_won;
|
||||
|
||||
@@ -171,11 +171,15 @@ fn advance_time_attack(
|
||||
mut ended: MessageWriter<TimeAttackEndedEvent>,
|
||||
paused: Option<Res<crate::pause_plugin::PausedResource>>,
|
||||
path: Option<Res<TimeAttackSessionPath>>,
|
||||
home_screens: Query<(), With<crate::home_plugin::HomeScreen>>,
|
||||
) {
|
||||
if !session.active {
|
||||
return;
|
||||
}
|
||||
if paused.is_some_and(|p| p.0) {
|
||||
// Mirrors `tick_elapsed_time`: pause while the launch / mode-picker
|
||||
// Home modal is up so the countdown doesn't burn while the player
|
||||
// is choosing what to play next.
|
||||
if paused.is_some_and(|p| p.0) || !home_screens.is_empty() {
|
||||
return;
|
||||
}
|
||||
session.remaining_secs -= time.delta_secs();
|
||||
|
||||
Reference in New Issue
Block a user