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

View file

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