Add capture SFX

I don't love it, so it's easy to disable.
But it's there if we want to keep it.
main
Elijah C. Voigt 1 year ago
parent 91787dff88
commit e7364b4344

@ -191,6 +191,7 @@ pick_up = "/SFX/3D/3DPickUpPiece"
put_down = "/SFX/3D/3DPutDownPiece"
idle = "/SFX/3D/3DPickup-Idle-PutdownWhirr"
invalid = "/sfx/3D/3DInvalidMove"
captured = "/sfx/3d/PieceCaptured"
####################
# Color Settings

@ -46,6 +46,22 @@ pub enum AudioEvent {
Idle,
StopIdle,
Invalid,
Captured,
}
impl AudioEvent {
fn as_str(&self) -> &str {
match self {
AudioEvent::MainMusic | AudioEvent::_StopMainMusic => "audio_music_main",
AudioEvent::MenuHover => "audio_menu_hover",
AudioEvent::MenuSelect => "audio_menu_select",
AudioEvent::PickUp => "audio_display3d_pick_up",
AudioEvent::PutDown => "audio_display3d_put_down",
AudioEvent::Idle | AudioEvent::StopIdle => "audio_display3d_idle",
AudioEvent::Captured => "audio_display3d_captured",
AudioEvent::Invalid => "audio_display3d_invalid",
}
}
}
#[derive(Resource, Debug)]
@ -80,19 +96,8 @@ fn audio_trigger(
.expect("Load tweaks");
let state = display_state.get();
events.read().for_each(|event| {
let aud = match event {
AudioEvent::MainMusic | AudioEvent::_StopMainMusic => {
tweak.get::<String>("audio_music_main").unwrap()
}
AudioEvent::MenuHover => tweak.get::<String>("audio_menu_hover").unwrap(),
AudioEvent::MenuSelect => tweak.get::<String>("audio_menu_select").unwrap(),
AudioEvent::PickUp => tweak.get::<String>("audio_display3d_pick_up").unwrap(),
AudioEvent::PutDown => tweak.get::<String>("audio_display3d_put_down").unwrap(),
AudioEvent::Idle | AudioEvent::StopIdle => {
tweak.get::<String>("audio_display3d_idle").unwrap()
}
AudioEvent::Invalid => tweak.get::<String>("audio_display3d_invalid").unwrap(),
};
let aud = tweak.get::<String>(event.as_str()).unwrap_or("".into());
// There is an event, play an audio
if !aud.is_empty() {
let event_str = format!("event:{}", aud);

@ -1180,6 +1180,7 @@ fn capture_piece_end(
mut events: RemovedComponents<Dissolving>,
mut query: Query<(Entity, &Dissolvable, &Side, &mut Transform), With<BeingCaptured>>,
mut commands: Commands,
score: Res<game::Score>,
) {
events.read().for_each(|e| {

@ -1055,6 +1055,7 @@ pub(crate) fn update_board(
.entity(entity)
.remove::<BoardIndex>()
.insert(BeingCaptured);
audio_events.send(AudioEvent::Captured);
},
MoveType::Promotion(..) => {
commands
@ -1246,7 +1247,7 @@ fn clear_endgame(query: Query<Entity, With<Endgame>>, mut commands: Commands) {
/// * All captured pieces have their captured side preserved
/// We can iterate over these pieces and calculate the score on the fly
fn manage_score(
query: Query<(&Side, &Piece), (With<Captured>, With<display3d::Display3d>)>,
query: Query<(&Side, &Piece), (Or<(With<Captured>, With<BeingCaptured>)>, With<display3d::Display3d>)>,
mut debug_info: ResMut<debug::DebugInfo>,
mut score: ResMut<Score>,
) {

Loading…
Cancel
Save