This commit is contained in:
yuni 2024-03-18 03:45:46 +01:00
parent 2361209eab
commit f069cd7325
2 changed files with 23 additions and 16 deletions

View file

@ -77,12 +77,14 @@ pub fn setup(
}, },
}, },
)); ));
if !settings.mute_sfx {
commands.spawn(( commands.spawn((
AudioBundle { AudioBundle {
source: asset_server.load("sounds/wakeup.ogg"), source: asset_server.load("sounds/wakeup.ogg"),
settings: PlaybackSettings::DESPAWN, settings: PlaybackSettings::DESPAWN,
}, },
)); ));
}
commands.spawn(( commands.spawn((
ComponentThrusterSound, ComponentThrusterSound,
AudioBundle { AudioBundle {
@ -113,6 +115,7 @@ pub fn toggle_bgm(
pub fn play_sfx( pub fn play_sfx(
mut commands: Commands, mut commands: Commands,
settings: Res<settings::Settings>,
mut events_click: EventReader<AudioClickEvent>, mut events_click: EventReader<AudioClickEvent>,
mut events_switch: EventReader<AudioSwitchEvent>, mut events_switch: EventReader<AudioSwitchEvent>,
sound_click: Res<SoundClick>, sound_click: Res<SoundClick>,
@ -120,18 +123,22 @@ pub fn play_sfx(
) { ) {
if !events_click.is_empty() { if !events_click.is_empty() {
events_click.clear(); events_click.clear();
if !settings.mute_sfx {
commands.spawn(AudioBundle { commands.spawn(AudioBundle {
source: sound_click.0.clone(), source: sound_click.0.clone(),
settings: PlaybackSettings::DESPAWN, settings: PlaybackSettings::DESPAWN,
}); });
} }
}
if !events_switch.is_empty() { if !events_switch.is_empty() {
events_switch.clear(); events_switch.clear();
if !settings.mute_sfx {
commands.spawn(AudioBundle { commands.spawn(AudioBundle {
source: sound_switch.0.clone(), source: sound_switch.0.clone(),
settings: PlaybackSettings::DESPAWN, settings: PlaybackSettings::DESPAWN,
}); });
} }
}
} }
pub fn update_music( pub fn update_music(

View file

@ -15,8 +15,8 @@ pub struct Settings {
impl Default for Settings { impl Default for Settings {
fn default() -> Self { fn default() -> Self {
Settings { Settings {
mute_sfx: false, mute_sfx: true,
mute_music: false, mute_music: true,
volume_sfx: 100, volume_sfx: 100,
volume_music: 100, volume_music: 100,
font_size_hud: 32.0, font_size_hud: 32.0,