From 1c10a0c561b47a2f585e4741225b9eba924fdbff Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 13 May 2024 20:42:34 +0200 Subject: [PATCH] block closing death screen for the first 1 second --- src/menu.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/menu.rs b/src/menu.rs index 5ce5f38..0aa6d33 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -24,11 +24,14 @@ impl Plugin for MenuPlugin { app.add_systems(Update, handle_deathscreen_input); app.add_systems(PostUpdate, update_menu); app.add_systems(Update, handle_input.run_if(alive)); + app.insert_resource(DeathScreenInputDelayTimer( + Timer::from_seconds(1.0, TimerMode::Once))); app.insert_resource(MenuState::default()); app.add_event::(); } } +#[derive(Resource)] pub struct DeathScreenInputDelayTimer(pub Timer); #[derive(Component)] pub struct MenuElement; #[derive(Component)] pub struct MenuTopLevel; #[derive(Component)] pub struct DeathScreenElement; @@ -179,6 +182,7 @@ pub fn show_deathscreen( mut ew_effect: EventWriter, mut ew_respawn: EventWriter, mut ew_respawnaudiosinks: EventWriter, + mut timer: ResMut, mut settings: ResMut, ) { for event in er_deathscreen.read() { @@ -190,6 +194,7 @@ pub fn show_deathscreen( settings.alive = !show; if show { + timer.0.reset(); ew_pausesfx.send(audio::PauseAllSfxEvent); if let Ok(mut text) = q_text.get_single_mut() { let poems: Vec<&str> = POEMS.split("\n\n").collect(); @@ -210,11 +215,13 @@ pub fn show_deathscreen( } pub fn handle_deathscreen_input( + time: Res