summaryrefslogtreecommitdiff
path: root/src/particle
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-03 20:32:53 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-03 20:32:53 +0300
commitbccb486d184b26638d3e47507bc6260383950b8b (patch)
tree40c574e150fcd5e84063fdfd2eb250b5e384c15b /src/particle
parent4f276b2cf2ae45928eeab9b96e31343c45868afb (diff)
downloadplus-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')
-rw-r--r--src/particle/particle.cpp27
-rw-r--r--src/particle/particle.h2
2 files changed, 23 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();
diff --git a/src/particle/particle.h b/src/particle/particle.h
index 72c40493d..eff89553e 100644
--- a/src/particle/particle.h
+++ b/src/particle/particle.h
@@ -281,6 +281,8 @@ class Particle notfinal : public Actor
{ mDeathEffect = effectFile; mDeathEffectConditions = conditions; }
protected:
+ void updateSelf() restrict2;
+
// Opacity of the graphical representation of the particle
float mAlpha;