From d0df5c5dbd3f490f4e41c366578dc7b958caaaf9 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 11 Apr 2024 21:06:21 +0200 Subject: [PATCH] implement rotation stabilizer (key Y) --- README.md | 1 + src/camera.rs | 11 ++++++++++- src/settings.rs | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fc9d72..6a01157 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Links: - Tab: Toggle HUD/AR - F11: Toggle fullscreen - F: Toggle 3rd person view + - Y: Toggle rotation stabilizer - T: Toggle music - M: Toggle sound effects - Cheats diff --git a/src/camera.rs b/src/camera.rs index 708aada..359fd5e 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -117,10 +117,15 @@ pub fn update_fov( pub fn handle_input( keyboard_input: Res>, mut settings: ResMut, + mut ew_sfx: EventWriter, ) { if keyboard_input.just_pressed(settings.key_camera) { settings.third_person ^= true; } + if keyboard_input.just_pressed(settings.key_rotation_stabilizer) { + ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click)); + settings.rotation_stabilizer_active ^= true; + } } fn manage_player_actor( @@ -301,7 +306,11 @@ pub fn apply_input_to_player( } } - let angular_slowdown: f64 = (2.0 - engine.reaction_wheels.powf(0.01).clamp(1.001, 1.1)) as f64; + let angular_slowdown: f64 = if settings.rotation_stabilizer_active { + (2.0 - engine.reaction_wheels.powf(0.01).clamp(1.001, 1.1)) as f64 + } else { + 1.0 + }; if pitch_yaw_rot.length_squared() > 1.0e-18 { play_reactionwheel_sound = true; pitch_yaw_rot *= settings.mouse_sensitivity * sensitivity_factor * engine.reaction_wheels; diff --git a/src/settings.rs b/src/settings.rs index 4ae94e0..c5ff26e 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -19,6 +19,7 @@ pub struct Settings { pub hud_active: bool, pub is_zooming: bool, pub third_person: bool, + pub rotation_stabilizer_active: bool, pub key_selectobject: MouseButton, pub key_zoom: MouseButton, pub key_togglehud: KeyCode, @@ -37,6 +38,7 @@ pub struct Settings { pub key_vehicle: KeyCode, pub key_camera: KeyCode, pub key_rotate: KeyCode, + pub key_rotation_stabilizer: KeyCode, pub key_mouseup: KeyCode, pub key_mousedown: KeyCode, pub key_mouseleft: KeyCode, @@ -101,6 +103,7 @@ impl Default for Settings { hud_active: false, is_zooming: false, third_person: false, + rotation_stabilizer_active: true, key_selectobject: MouseButton::Left, key_zoom: MouseButton::Right, key_togglehud: KeyCode::Tab, @@ -119,6 +122,7 @@ impl Default for Settings { key_vehicle: KeyCode::KeyQ, key_camera: KeyCode::KeyF, key_rotate: KeyCode::KeyR, + key_rotation_stabilizer: KeyCode::KeyY, key_mouseup: KeyCode::KeyI, key_mousedown: KeyCode::KeyK, key_mouseleft: KeyCode::KeyJ,