summaryrefslogtreecommitdiff
path: root/src/particle
diff options
context:
space:
mode:
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;