From ba3c01738cba3a842b2fe02f6b0f4e5fec454179 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 23 Nov 2013 15:31:34 +0000 Subject: Play sounds when getting hit. --- src/client/soundext.cc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/client') diff --git a/src/client/soundext.cc b/src/client/soundext.cc index 09c83d8..dd86a70 100644 --- a/src/client/soundext.cc +++ b/src/client/soundext.cc @@ -295,6 +295,18 @@ void SoundExt::frame(float elapsed) pitch = 1.0f; gain = 0.0f; // loop buffer gain + } else if (controlable->state() == core::Entity::Docked) { + + if (state_engineloopbuffer) { + audio::stop(state_engineloopsource); + state_engineloopbuffer = 0; + } + if (state_engineeventbuffer) { + audio::stop(state_engineeventsource); + state_engineeventbuffer = 0; + } + gain = 0.0f; // loop buffer gain + } else { if ((state_engineeventbuffer == state_impulsestartbuffer) || (state_engineeventbuffer == state_impulseloopbuffer)) { @@ -310,11 +322,13 @@ void SoundExt::frame(float elapsed) } } - audio::update_source(state_engineloopsource, - controlable->location() - controlable->axis().forward() * r ,velocity, pitch, gain); + if (state_engineloopbuffer) { + audio::update_source(state_engineloopsource, controlable->location() - controlable->axis().forward() * r ,velocity, pitch, gain); + } - audio::update_source(state_engineeventsource, - controlable->location() - controlable->axis().forward() * r , velocity); + if (state_engineeventbuffer) { + audio::update_source(state_engineeventsource, controlable->location() - controlable->axis().forward() * r , velocity); + } } else if (entity()->type() == core::Entity::Dynamic) { -- cgit v1.2.3