diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-03 20:32:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-03 20:32:53 +0300 |
commit | bccb486d184b26638d3e47507bc6260383950b8b (patch) | |
tree | 40c574e150fcd5e84063fdfd2eb250b5e384c15b /src/particle/particle.cpp | |
parent | 4f276b2cf2ae45928eeab9b96e31343c45868afb (diff) | |
download | plus-bccb486d184b26638d3e47507bc6260383950b8b.tar.gz plus-bccb486d184b26638d3e47507bc6260383950b8b.tar.bz2 plus-bccb486d184b26638d3e47507bc6260383950b8b.tar.xz plus-bccb486d184b26638d3e47507bc6260383950b8b.zip |
Split particles update into two functions.
Diffstat (limited to 'src/particle/particle.cpp')
-rw-r--r-- | src/particle/particle.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index f6b951004..4e583d0ab 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -106,16 +106,11 @@ void Particle::draw(Graphics *restrict const, { } -bool Particle::update() restrict2 +void Particle::updateSelf() restrict2 { - if (!mMap) - return false; - if (mLifetimeLeft == 0 && mAlive == AliveStatus::ALIVE) mAlive = AliveStatus::DEAD_TIMEOUT; - const Vector oldPos = mPos; - if (mAlive == AliveStatus::ALIVE) { // calculate particle movement @@ -235,9 +230,29 @@ bool Particle::update() restrict2 } mAlive = AliveStatus::DEAD_LONG_AGO; } +} + +bool Particle::update() restrict2 +{ + if (!mMap) + return false; + + const Vector oldPos = mPos; + + updateSelf(); const Vector change = mPos - oldPos; + if (mChildParticles.empty()) + { + if (mAlive != AliveStatus::ALIVE && + mAutoDelete) + { + return false; + } + return true; + } + // Update child particles const int cameraX = viewport->getCameraX(); |