handle god mode properly when restarting/cheat-dying

This commit is contained in:
yuni 2024-04-11 21:17:34 +02:00
parent cb698cc3b2
commit 053f2827dd
3 changed files with 4 additions and 5 deletions

View file

@ -234,7 +234,7 @@ pub fn update_physics_lifeforms(
pub fn handle_input( pub fn handle_input(
mut commands: Commands, mut commands: Commands,
keyboard_input: Res<ButtonInput<KeyCode>>, keyboard_input: Res<ButtonInput<KeyCode>>,
settings: ResMut<settings::Settings>, mut settings: ResMut<settings::Settings>,
q_talker: Query<(&chat::Talker, &Transform), (Without<actor::Player>, Without<Camera>)>, q_talker: Query<(&chat::Talker, &Transform), (Without<actor::Player>, Without<Camera>)>,
player: Query<Entity, With<actor::Player>>, player: Query<Entity, With<actor::Player>>,
q_camera: Query<&Transform, With<Camera>>, q_camera: Query<&Transform, With<Camera>>,
@ -296,6 +296,7 @@ pub fn handle_input(
} }
} }
else if keyboard_input.just_pressed(settings.key_restart) { else if keyboard_input.just_pressed(settings.key_restart) {
settings.god_mode = false;
ew_playerdies.send(PlayerDiesEvent(DamageType::Mental)); ew_playerdies.send(PlayerDiesEvent(DamageType::Mental));
} }
} }

View file

@ -77,7 +77,7 @@ fn setup(
fn handle_input( fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>, keyboard_input: Res<ButtonInput<KeyCode>>,
mut settings: ResMut<settings::Settings>, settings: Res<settings::Settings>,
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>, mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
mut windows: Query<&mut Window, With<PrimaryWindow>>, mut windows: Query<&mut Window, With<PrimaryWindow>>,
) { ) {
@ -93,7 +93,4 @@ fn handle_input(
} }
} }
} }
if keyboard_input.just_pressed(settings.key_restart) {
settings.reset();
}
} }

View file

@ -446,6 +446,7 @@ fn handle_cheats(
lifeform.adrenaline = 1.0; lifeform.adrenaline = 1.0;
} }
if key_input.just_pressed(settings.key_cheat_die) { if key_input.just_pressed(settings.key_cheat_die) {
settings.god_mode = false;
ew_playerdies.send(actor::PlayerDiesEvent(actor::DamageType::Trauma)); ew_playerdies.send(actor::PlayerDiesEvent(actor::DamageType::Trauma));
} }
} }