add "m" key for muting SFX
This commit is contained in:
parent
5d4ec3c77c
commit
a541591b84
|
@ -61,7 +61,7 @@ pub fn setup(
|
|||
source: SoundBGM(asset_server.load(ASSET_BGM)).0.clone(),
|
||||
settings: PlaybackSettings {
|
||||
mode: PlaybackMode::Loop,
|
||||
paused: settings.hud_active,
|
||||
paused: settings.hud_active || settings.mute_music,
|
||||
..default()
|
||||
},
|
||||
},
|
||||
|
@ -72,7 +72,7 @@ pub fn setup(
|
|||
source: SoundBGM(asset_server.load(ASSET_RADIO)).0.clone(),
|
||||
settings: PlaybackSettings {
|
||||
mode: PlaybackMode::Loop,
|
||||
paused: !settings.hud_active,
|
||||
paused: !settings.hud_active || settings.mute_music,
|
||||
..default()
|
||||
},
|
||||
},
|
||||
|
@ -111,6 +111,11 @@ pub fn toggle_bgm(
|
|||
evwriter_click.send(AudioClickEvent());
|
||||
evwriter_toggle.send(ToggleMusicEvent());
|
||||
}
|
||||
if keyboard_input.just_pressed(KeyCode::KeyM) {
|
||||
settings.mute_sfx ^= true;
|
||||
evwriter_click.send(AudioClickEvent());
|
||||
evwriter_toggle.send(ToggleMusicEvent());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play_sfx(
|
||||
|
|
|
@ -2,7 +2,7 @@ use bevy::prelude::*;
|
|||
use bevy::input::mouse::MouseMotion;
|
||||
use bevy::window::PrimaryWindow;
|
||||
use std::{f32::consts::*, fmt};
|
||||
use crate::audio;
|
||||
use crate::{settings, audio};
|
||||
|
||||
pub struct CameraControllerPlugin;
|
||||
|
||||
|
@ -31,7 +31,6 @@ pub struct CameraController {
|
|||
pub key_run: KeyCode,
|
||||
pub key_stop: KeyCode,
|
||||
pub mouse_key_cursor_grab: MouseButton,
|
||||
pub keyboard_key_toggle_cursor_grab: KeyCode,
|
||||
pub move_speed: f32,
|
||||
pub friction: f32,
|
||||
pub pitch: f32,
|
||||
|
@ -54,7 +53,6 @@ impl Default for CameraController {
|
|||
key_run: KeyCode::KeyR,
|
||||
key_stop: KeyCode::Space,
|
||||
mouse_key_cursor_grab: MouseButton::Left,
|
||||
keyboard_key_toggle_cursor_grab: KeyCode::KeyM,
|
||||
move_speed: 1.0,
|
||||
friction: 0.1,
|
||||
pitch: 1.0, // pitch=0/yaw=0 -> face sun
|
||||
|
@ -72,13 +70,11 @@ impl fmt::Display for CameraController {
|
|||
Freecam Controls:
|
||||
Mouse\t- Move camera orientation
|
||||
{:?}\t- Hold to grab cursor
|
||||
{:?}\t- Toggle cursor grab
|
||||
{:?} & {:?}\t- Fly forward & backwards
|
||||
{:?} & {:?}\t- Fly sideways left & right
|
||||
{:?} & {:?}\t- Fly up & down
|
||||
{:?}\t- Fly faster while held",
|
||||
self.mouse_key_cursor_grab,
|
||||
self.keyboard_key_toggle_cursor_grab,
|
||||
self.key_forward,
|
||||
self.key_back,
|
||||
self.key_left,
|
||||
|
@ -93,6 +89,7 @@ Freecam Controls:
|
|||
#[allow(clippy::too_many_arguments)]
|
||||
fn run_camera_controller(
|
||||
time: Res<Time>,
|
||||
settings: Res<settings::Settings>,
|
||||
mut windows: Query<&mut Window, With<PrimaryWindow>>,
|
||||
mut mouse_events: EventReader<MouseMotion>,
|
||||
mouse_button_input: Res<ButtonInput<MouseButton>>,
|
||||
|
@ -147,9 +144,6 @@ fn run_camera_controller(
|
|||
}
|
||||
}
|
||||
|
||||
if key_input.just_pressed(controller.keyboard_key_toggle_cursor_grab) {
|
||||
*toggle_cursor_grab = !*toggle_cursor_grab;
|
||||
}
|
||||
if mouse_button_input.just_pressed(controller.mouse_key_cursor_grab) {
|
||||
*mouse_cursor_grab = true;
|
||||
}
|
||||
|
@ -168,7 +162,7 @@ fn run_camera_controller(
|
|||
if axis_input != Vec3::ZERO {
|
||||
let new_velocity = controller.velocity + axis_input.normalize() * controller.move_speed;
|
||||
controller.velocity = new_velocity;
|
||||
play_thruster_sound = true;
|
||||
play_thruster_sound = !settings.mute_sfx;
|
||||
} else {
|
||||
controller.velocity *= 1.0 - friction;
|
||||
if controller.velocity.length_squared() < 1e-6 {
|
||||
|
|
Loading…
Reference in a new issue