From 704f58c9033599c871c176df68ffe7ac3bc8c969 Mon Sep 17 00:00:00 2001 From: Fate Date: Sat, 6 Dec 2008 12:20:16 -0700 Subject: Added particle containers and refactored beings to use them (to clean up responsibilities a little) --- src/being.cpp | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'src/being.cpp') diff --git a/src/being.cpp b/src/being.cpp index ef257f43..7c6d91e7 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -74,7 +74,9 @@ Being::Being(int id, int job, Map *map): mPx(0), mPy(0), mSprites(VECTOREND_SPRITE, NULL), mSpriteIDs(VECTOREND_SPRITE, 0), - mSpriteColors(VECTOREND_SPRITE, "") + mSpriteColors(VECTOREND_SPRITE, ""), + mStatusParticleEffects(&mStunParticleEffects, false), + mChildParticleEffects(&mStatusParticleEffects, false) { setMap(map); @@ -95,13 +97,6 @@ Being::~Being() std::for_each(mSprites.begin(), mSprites.end(), make_dtor(mSprites)); clearPath(); - for ( std::list::iterator i = mChildParticleEffects.begin(); - i != mChildParticleEffects.end(); - i++) - { - (*i)->kill(); - } - setMap(NULL); instances--; @@ -233,12 +228,7 @@ Being::setMap(Map *map) void Being::controlParticle(Particle *particle) { - if (particle) - { - // The effect may not die without the beings permission or we segfault - particle->disableAutoDelete(); - mChildParticleEffects.push_back(particle); - } + mChildParticleEffects.addLocally(particle); } void @@ -413,21 +403,7 @@ Being::logic() } //Update particle effects - for ( std::list::iterator i = mChildParticleEffects.begin(); - i != mChildParticleEffects.end(); - - ) - { - (*i)->setPosition((float)mPx + 16.0f, (float)mPy + 32.0f); - if ((*i)->isExtinct()) - { - (*i)->kill(); - i = mChildParticleEffects.erase(i); - } - else { - i++; - } - } + mChildParticleEffects.setPositions((float)mPx + 16.0f, (float)mPy + 32.0f); } void -- cgit v1.2.3-70-g09d2