summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/particle/particle.cpp17
-rw-r--r--src/particle/particle.h2
-rw-r--r--src/particle/particlelist.cpp4
3 files changed, 22 insertions, 1 deletions
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index b487e5ffb..dc566bb4e 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -477,6 +477,23 @@ void Particle::adjustEmitterSize(const int w, const int h)
}
}
+void Particle::prepareToDie()
+{
+ FOR_EACH (ParticleIterator, p, mChildParticles)
+ {
+ Particle *const particle = *p;
+ if (!particle)
+ continue;
+ particle->prepareToDie();
+ if (particle->isAlive() &&
+ particle->mLifetimeLeft == -1 &&
+ particle->mAutoDelete)
+ {
+ particle->kill();
+ }
+ }
+}
+
void Particle::clear()
{
delete_all(mChildEmitters);
diff --git a/src/particle/particle.h b/src/particle/particle.h
index 7f3a743bf..e33bb986c 100644
--- a/src/particle/particle.h
+++ b/src/particle/particle.h
@@ -248,6 +248,8 @@ class Particle notfinal : public Actor
bool isAlive() const A_WARN_UNUSED
{ return mAlive == ALIVE; }
+ void prepareToDie();
+
/**
* Determines whether the particle and its children are all dead
*/
diff --git a/src/particle/particlelist.cpp b/src/particle/particlelist.cpp
index c95bec9e6..6c2818681 100644
--- a/src/particle/particlelist.cpp
+++ b/src/particle/particlelist.cpp
@@ -36,7 +36,8 @@ ParticleList::ParticleList(ParticleContainer *const parent,
{}
ParticleList::~ParticleList()
-{}
+{
+}
void ParticleList::addLocally(Particle *const particle)
{
@@ -57,6 +58,7 @@ void ParticleList::removeLocally(const Particle *const particle)
if (p == particle)
{
p->kill();
+ p->prepareToDie();
it = mElements.erase(it);
}
else