summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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