reorganize the code a bit
This commit is contained in:
@@ -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 &&
|
||||
(
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user