summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2008-12-06 21:00:46 -0700
committerFate <fate-tmw@googlemail.com>2008-12-06 21:00:46 -0700
commita7c21e6f8add37af7412449742ec55c8daa8571a (patch)
tree81d7b3eb74f7694aae8a64dd91e1e674e8b326a7
parent28fa707f1ab22e7cac8abff703d534aec3228d5c (diff)
downloadmana-client-a7c21e6f8add37af7412449742ec55c8daa8571a.tar.gz
mana-client-a7c21e6f8add37af7412449742ec55c8daa8571a.tar.bz2
mana-client-a7c21e6f8add37af7412449742ec55c8daa8571a.tar.xz
mana-client-a7c21e6f8add37af7412449742ec55c8daa8571a.zip
Defrobnicated ParticleContainer inheritance hierarchy
-rw-r--r--src/being.h4
-rw-r--r--src/particlecontainer.cpp51
-rw-r--r--src/particlecontainer.h45
3 files changed, 69 insertions, 31 deletions
diff --git a/src/being.h b/src/being.h
index 568d51c7..15e1e6f9 100644
--- a/src/being.h
+++ b/src/being.h
@@ -424,9 +424,9 @@ class Being : public Sprite
std::vector<AnimatedSprite*> mSprites;
std::vector<int> mSpriteIDs;
std::vector<std::string> mSpriteColors;
- ParticleContainer mStunParticleEffects;
+ ParticleList mStunParticleEffects;
ParticleVector mStatusParticleEffects;
- ParticleContainer mChildParticleEffects;
+ ParticleList mChildParticleEffects;
private:
/**
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index 4df45b26..12ef5733 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -37,7 +37,30 @@ ParticleContainer::~ParticleContainer()
}
void
-ParticleContainer::addLocally(Particle *particle)
+ParticleContainer::clear()
+{
+ clearLocally();
+ if (mNext)
+ mNext->clear();
+}
+
+
+void
+ParticleContainer::setPositions(float x, float y)
+{
+ if (mNext)
+ mNext->setPositions(x, y);
+}
+
+// -- particle list ----------------------------------------
+
+ParticleList::ParticleList(ParticleContainer *parent, bool delParent) :
+ ParticleContainer(parent, delParent) {};
+
+ParticleList::~ParticleList() {}
+
+void
+ParticleList::addLocally(Particle *particle)
{
if (particle)
{
@@ -48,7 +71,7 @@ ParticleContainer::addLocally(Particle *particle)
}
void
-ParticleContainer::removeLocally(Particle *particle)
+ParticleList::removeLocally(Particle *particle)
{
for (std::list<Particle *>::iterator it = mElements.begin();
it != mElements.end(); it++)
@@ -59,15 +82,7 @@ ParticleContainer::removeLocally(Particle *particle)
}
void
-ParticleContainer::clear()
-{
- clearLocally();
- if (mNext)
- mNext->clear();
-}
-
-void
-ParticleContainer::clearLocally()
+ParticleList::clearLocally()
{
for (std::list<Particle *>::iterator it = mElements.begin();
it != mElements.end(); it++)
@@ -77,8 +92,10 @@ ParticleContainer::clearLocally()
}
void
-ParticleContainer::setPositions(float x, float y)
+ParticleList::setPositions(float x, float y)
{
+ ParticleContainer::setPositions(x, y);
+
for (std::list<Particle *>::iterator it = mElements.begin();
it != mElements.end();)
{
@@ -96,10 +113,12 @@ ParticleContainer::setPositions(float x, float y)
-ParticleVector::ParticleVector(ParticleContainer *next, bool delParent)
-{
- ParticleContainer::ParticleContainer(next, delParent);
-}
+// -- particle vector ----------------------------------------
+
+ParticleVector::ParticleVector(ParticleContainer *parent, bool delParent) :
+ ParticleContainer(parent, delParent) {};
+
+ParticleVector::~ParticleVector() {};
void
ParticleVector::setLocally(int index, Particle *particle)
diff --git a/src/particlecontainer.h b/src/particlecontainer.h
index a6a1b1c8..cf002fbc 100644
--- a/src/particlecontainer.h
+++ b/src/particlecontainer.h
@@ -42,38 +42,56 @@ public:
*
* delParent means that the destructor should also free the parent.
*/
- ParticleContainer(ParticleContainer *parent = NULL, bool delParent = true);
- ~ParticleContainer();
+ ParticleContainer(ParticleContainer *parent = NULL, bool delParent = true);
+ virtual ~ParticleContainer();
/**
- * Takes control of and adds a particle
+ * Kills and removes all particle effects
*/
- void addLocally(Particle *);
+ void clear();
/**
- * `kills' and removes a particle
+ * Kills and removes all particle effects (only in this container)
*/
- void removeLocally(Particle *);
+ virtual void clearLocally() {};
/**
- * Kills and removes all particle effects
+ * Sets the positions of all elements
*/
- void clear();
+ virtual void setPositions(float x, float y);
+
+protected:
+ bool mDelParent; /**< Delete mNext in destructor */
+ ParticleContainer *mNext; /**< Contained container, if any */
+};
+
+
+
+/**
+ * Linked list of particle effects.
+ */
+class ParticleList : public ParticleContainer
+{
+public:
+ ParticleList(ParticleContainer *parent = NULL, bool delParent = true);
+ virtual ~ParticleList();
/**
- * Kills and removes all particle effects (only in this container)
+ * Takes control of and adds a particle
*/
- virtual void clearLocally();
+ void addLocally(Particle *);
/**
- * Sets the positions of all elements
+ * `kills' and removes a particle
*/
+ void removeLocally(Particle *);
+
+ virtual void clearLocally();
+
virtual void setPositions(float x, float y);
protected:
- bool mDelParent; /**< Delete mNext in destructor */
std::list<Particle *> mElements; /**< Contained particle effects */
- ParticleContainer *mNext; /**< Contained container, if any */
};
@@ -84,6 +102,7 @@ class ParticleVector : public ParticleContainer
{
public:
ParticleVector(ParticleContainer *parent = NULL, bool delParent = true);
+ virtual ~ParticleVector();
/**
* Sets a particle at a specified index. Kills the previous particle