From 00c1493548cc348a0c474241d88fb07d75c22005 Mon Sep 17 00:00:00 2001 From: S Handley Date: Sun, 12 Jan 2020 16:35:20 +0000 Subject: [PATCH] Play the Run SFX when a character lands after jumping or falling This is a small detail but makes a noticable difference. --- .../src/audio/sfx/event_mapper/movement.rs | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/voxygen/src/audio/sfx/event_mapper/movement.rs b/voxygen/src/audio/sfx/event_mapper/movement.rs index 114a785390..b78396b859 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement.rs @@ -128,13 +128,11 @@ impl MovementEventMapper { (MovementState::Climb, ..) => SfxEvent::Climb, (MovementState::Swim, ..) => SfxEvent::Swim, (MovementState::Run, ..) => SfxEvent::Run, - (MovementState::Fall, _, previous_event) => { - if previous_event != SfxEvent::Glide { - SfxEvent::Fall - } else { - SfxEvent::GliderClose - } - } + (MovementState::Jump, ..) => SfxEvent::Jump, + (MovementState::Fall, _, SfxEvent::Glide) => SfxEvent::GliderClose, + (MovementState::Stand, _, SfxEvent::Fall) => SfxEvent::Run, + (MovementState::Fall, _, SfxEvent::Jump) => SfxEvent::Idle, + (MovementState::Fall, _, _) => SfxEvent::Fall, (MovementState::Glide, _, previous_event) => { if previous_event != SfxEvent::GliderOpen && previous_event != SfxEvent::Glide { SfxEvent::GliderOpen @@ -142,13 +140,7 @@ impl MovementEventMapper { SfxEvent::Glide } } - (MovementState::Stand, _, previous_event) => { - if previous_event == SfxEvent::Glide { - SfxEvent::GliderClose - } else { - SfxEvent::Idle - } - } + (MovementState::Stand, _, SfxEvent::Glide) => SfxEvent::GliderClose, _ => SfxEvent::Idle, } } @@ -287,12 +279,25 @@ mod tests { movement: MovementState::Fall, action: ActionState::Idle, }, - SfxEvent::Idle, + SfxEvent::Fall, ); assert_eq!(result, SfxEvent::Fall); } + #[test] + fn maps_land_on_ground_to_run() { + let result = MovementEventMapper::map_movement_event( + &CharacterState { + movement: MovementState::Stand, + action: ActionState::Idle, + }, + SfxEvent::Fall, + ); + + assert_eq!(result, SfxEvent::Run); + } + #[test] fn maps_glider_open() { let result = MovementEventMapper::map_movement_event(