block closing death screen for the first 1 second
This commit is contained in:
parent
ac9451ea4a
commit
1c10a0c561
|
@ -24,11 +24,14 @@ impl Plugin for MenuPlugin {
|
||||||
app.add_systems(Update, handle_deathscreen_input);
|
app.add_systems(Update, handle_deathscreen_input);
|
||||||
app.add_systems(PostUpdate, update_menu);
|
app.add_systems(PostUpdate, update_menu);
|
||||||
app.add_systems(Update, handle_input.run_if(alive));
|
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.insert_resource(MenuState::default());
|
||||||
app.add_event::<DeathScreenEvent>();
|
app.add_event::<DeathScreenEvent>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Resource)] pub struct DeathScreenInputDelayTimer(pub Timer);
|
||||||
#[derive(Component)] pub struct MenuElement;
|
#[derive(Component)] pub struct MenuElement;
|
||||||
#[derive(Component)] pub struct MenuTopLevel;
|
#[derive(Component)] pub struct MenuTopLevel;
|
||||||
#[derive(Component)] pub struct DeathScreenElement;
|
#[derive(Component)] pub struct DeathScreenElement;
|
||||||
|
@ -179,6 +182,7 @@ pub fn show_deathscreen(
|
||||||
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
|
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
|
||||||
mut ew_respawn: EventWriter<world::RespawnEvent>,
|
mut ew_respawn: EventWriter<world::RespawnEvent>,
|
||||||
mut ew_respawnaudiosinks: EventWriter<audio::RespawnSinksEvent>,
|
mut ew_respawnaudiosinks: EventWriter<audio::RespawnSinksEvent>,
|
||||||
|
mut timer: ResMut<DeathScreenInputDelayTimer>,
|
||||||
mut settings: ResMut<Settings>,
|
mut settings: ResMut<Settings>,
|
||||||
) {
|
) {
|
||||||
for event in er_deathscreen.read() {
|
for event in er_deathscreen.read() {
|
||||||
|
@ -190,6 +194,7 @@ pub fn show_deathscreen(
|
||||||
settings.alive = !show;
|
settings.alive = !show;
|
||||||
|
|
||||||
if show {
|
if show {
|
||||||
|
timer.0.reset();
|
||||||
ew_pausesfx.send(audio::PauseAllSfxEvent);
|
ew_pausesfx.send(audio::PauseAllSfxEvent);
|
||||||
if let Ok(mut text) = q_text.get_single_mut() {
|
if let Ok(mut text) = q_text.get_single_mut() {
|
||||||
let poems: Vec<&str> = POEMS.split("\n\n").collect();
|
let poems: Vec<&str> = POEMS.split("\n\n").collect();
|
||||||
|
@ -210,11 +215,13 @@ pub fn show_deathscreen(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_deathscreen_input(
|
pub fn handle_deathscreen_input(
|
||||||
|
time: Res<Time>,
|
||||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||||
|
mut timer: ResMut<DeathScreenInputDelayTimer>,
|
||||||
mut ew_deathscreen: EventWriter<DeathScreenEvent>,
|
mut ew_deathscreen: EventWriter<DeathScreenEvent>,
|
||||||
settings: Res<Settings>,
|
settings: Res<Settings>,
|
||||||
) {
|
) {
|
||||||
if !settings.deathscreen_active {
|
if !settings.deathscreen_active || !timer.0.tick(time.delta()).finished() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if keyboard_input.pressed(settings.key_interact) {
|
if keyboard_input.pressed(settings.key_interact) {
|
||||||
|
|
Loading…
Reference in a new issue