From ef0ada9dacfa1eca03801088601abba528fd7fe7 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 11 Apr 2024 21:20:54 +0200 Subject: [PATCH] reset *some* settings on death --- src/actor.rs | 3 ++- src/settings.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/actor.rs b/src/actor.rs index aaf71d4..8b38d41 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -424,12 +424,13 @@ fn handle_player_death( mut ew_sfx: EventWriter, mut ew_effect: EventWriter, mut log: ResMut, - settings: Res, + mut settings: ResMut, ) { for death in er_playerdies.read() { if settings.god_mode { return; } + settings.reset_player_settings(); for entity in &q_noscenes { cmd.entity(entity).despawn(); } diff --git a/src/settings.rs b/src/settings.rs index c5ff26e..9a98457 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -155,11 +155,20 @@ impl Default for Settings { } impl Settings { + #[allow(dead_code)] pub fn reset(&mut self) { println!("Resetting settings!"); *self = Self::default(); } + pub fn reset_player_settings(&mut self) { + println!("Resetting player settings!"); + let default = Self::default(); + self.rotation_stabilizer_active = default.rotation_stabilizer_active; + self.third_person = default.third_person; + self.is_zooming = default.is_zooming; + } + pub fn get_reply_keys(&self) -> [KeyCode; 10] { return [ self.key_reply1,