From 825cf98a005473aea0b271f9d353793872b0f1e7 Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Mon, 15 Jun 2020 06:23:39 +1000 Subject: [PATCH] Fixes a bug where run sfx were being played during a roll. --- CHANGELOG.md | 1 + voxygen/src/audio/sfx/event_mapper/movement/mod.rs | 9 ++++++--- voxygen/src/audio/sfx/event_mapper/movement/tests.rs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca61daa7d7..b624a58167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Lanterns now stop glowing if you throw a lit one out of your inventory - Fixed a crash caused by certain audio devices on OSX - Bow animations now show held arrows +- Fixed a bug where walk/run sfx played while a character rolled/dodged ### Removed diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 88d183a349..e3292fb071 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -149,16 +149,19 @@ impl MovementEventMapper { previous_state: &PreviousEntityState, vel: Vec3, ) -> SfxEvent { - // Match run state + // Match run / roll state if physics_state.on_ground && vel.magnitude() > 0.1 || !previous_state.on_ground && physics_state.on_ground { - return SfxEvent::Run; + return if character_state.is_dodge() { + SfxEvent::Roll + } else { + SfxEvent::Run + }; } // Match all other Movemement and Action states match (previous_state.event, character_state) { - (_, CharacterState::Roll { .. }) => SfxEvent::Roll, (_, CharacterState::Climb { .. }) => SfxEvent::Climb, (SfxEvent::Glide, CharacterState::Idle { .. }) => SfxEvent::GliderClose, (previous_event, CharacterState::Glide { .. }) => { diff --git a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs index ae7a3f26ff..836973b645 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs @@ -183,7 +183,7 @@ fn maps_roll() { time: Instant::now(), on_ground: true, }, - Vec3::zero(), + Vec3::new(0.5, 0.5, 0.0), ); assert_eq!(result, SfxEvent::Roll);