diff options
author | Fate <fate-tmw@googlemail.com> | 2008-12-06 12:20:16 -0700 |
---|---|---|
committer | Fate <fate-tmw@googlemail.com> | 2008-12-06 12:20:16 -0700 |
commit | 704f58c9033599c871c176df68ffe7ac3bc8c969 (patch) | |
tree | e77f4e40ada9df44e49aab752a62fb5a503907e0 /src/being.cpp | |
parent | 9559fdb347054e945940980efdbbe83615ce9733 (diff) | |
download | mana-704f58c9033599c871c176df68ffe7ac3bc8c969.tar.gz mana-704f58c9033599c871c176df68ffe7ac3bc8c969.tar.bz2 mana-704f58c9033599c871c176df68ffe7ac3bc8c969.tar.xz mana-704f58c9033599c871c176df68ffe7ac3bc8c969.zip |
Added particle containers and refactored beings to use them (to clean up responsibilities a little)
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 34 |
1 files changed, 5 insertions, 29 deletions
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<Particle *>::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<Particle *>::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 |