|
|
|
@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// TODO: Custom Asset: FmodEventMapper
|
|
|
|
|
|
|
|
///
|
|
|
|
use crate::prelude::*;
|
|
|
|
use crate::prelude::*;
|
|
|
|
|
|
|
|
|
|
|
|
pub(crate) struct AudioPlugin;
|
|
|
|
pub(crate) struct AudioPlugin;
|
|
|
|
@ -11,6 +14,39 @@ impl Plugin for AudioPlugin {
|
|
|
|
"./assets/audio/Martian Chess/Build/Desktop/Music.bank",
|
|
|
|
"./assets/audio/Martian Chess/Build/Desktop/Music.bank",
|
|
|
|
"./assets/audio/Martian Chess/Build/Desktop/SFX.bank",
|
|
|
|
"./assets/audio/Martian Chess/Build/Desktop/SFX.bank",
|
|
|
|
],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
.add_systems(OnExit(GameState::Loading), play_background)
|
|
|
|
|
|
|
|
.add_systems(
|
|
|
|
|
|
|
|
Update,
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
play_audio.run_if(any_with_component::<Button>()),
|
|
|
|
|
|
|
|
button_audio.run_if(any_with_component::<Button>()),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn play_background(studio: Res<FmodStudio>, mut commands: Commands) {
|
|
|
|
|
|
|
|
commands.spawn(AudioSource::new(
|
|
|
|
|
|
|
|
studio.0.get_event("event:/Music").unwrap(),
|
|
|
|
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn play_audio(mut events: Query<&AudioSource, Added<AudioSource>>) {
|
|
|
|
|
|
|
|
events.iter_mut().for_each(|aud| aud.play());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn button_audio(
|
|
|
|
|
|
|
|
events: Query<&Interaction, (Changed<Interaction>, With<Button>)>,
|
|
|
|
|
|
|
|
studio: Res<FmodStudio>,
|
|
|
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
events
|
|
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
|
|
.filter(|&interaction| *interaction != Interaction::None)
|
|
|
|
|
|
|
|
.for_each(|_| {
|
|
|
|
|
|
|
|
commands.spawn(AudioSource::new(
|
|
|
|
|
|
|
|
studio.0.get_event("event:/SFX/MenuSelect").unwrap(),
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|