reorganize the code a bit

This commit is contained in:
Erik Hofman
2017-01-12 11:43:46 +01:00
parent 1b793a127c
commit de9b329115
2 changed files with 10 additions and 11 deletions

View File

@@ -74,8 +74,7 @@ SGXmlSound::SGXmlSound()
_dt_play(0.0),
_dt_stop(0.0),
_delay(0.0),
_stopping(0.0),
_initialized(false)
_stopping(0.0)
{
}
@@ -337,19 +336,12 @@ SGXmlSound::update (double dt)
if (_property)
curr_value = _property->getDoubleValue();
if (!_initialized)
{
// update initial value before detecting changes
_prev_value = curr_value;
_initialized = true;
}
// If a condition is defined, test whether it is FALSE,
// else
// if a property is defined then test if it's value is FALSE
// or if the mode is IN_TRANSIT then
// test whether the current value matches the previous value.
if ( // Lisp, anyone?
if ( // Lisp, anyone?
(_condition && !_condition->test()) ||
(!_condition && _property &&
(

View File

@@ -116,6 +116,14 @@ public:
*/
virtual void update (double dt);
/**
* Start taking action on the pre-defined events.
*/
void start() {
if (_property) _prev_value = _property->getDoubleValue();
_active = false;
}
/**
* Stop taking action on the pre-defined events.
*/
@@ -158,7 +166,6 @@ private:
double _delay; // time after which the sound should be started (default: 0)
double _stopping; // time after the sound should have stopped.
// This is useful for lost packets in in-transit mode.
bool _initialized;
// sound system version 1.0
std::vector<_snd_prop> _volume;