summaryrefslogtreecommitdiff
path: root/src/particle
diff options
context:
space:
mode:
Diffstat (limited to 'src/particle')
-rw-r--r--src/particle/animationparticle.cpp10
-rw-r--r--src/particle/animationparticle.h4
-rw-r--r--src/particle/imageparticle.cpp4
-rw-r--r--src/particle/imageparticle.h2
-rw-r--r--src/particle/particle.cpp26
-rw-r--r--src/particle/particle.h7
-rw-r--r--src/particle/particleemitter.cpp12
-rw-r--r--src/particle/rotationalparticle.cpp10
-rw-r--r--src/particle/rotationalparticle.h4
-rw-r--r--src/particle/textparticle.cpp4
-rw-r--r--src/particle/textparticle.h2
11 files changed, 42 insertions, 43 deletions
diff --git a/src/particle/animationparticle.cpp b/src/particle/animationparticle.cpp
index bfa1d6c7f..6fba399c8 100644
--- a/src/particle/animationparticle.cpp
+++ b/src/particle/animationparticle.cpp
@@ -26,17 +26,15 @@
#include "debug.h"
-AnimationParticle::AnimationParticle(Map *const map,
- Animation *const animation) :
- ImageParticle(map, nullptr),
+AnimationParticle::AnimationParticle(Animation *const animation) :
+ ImageParticle(nullptr),
mAnimation(new SimpleAnimation(animation))
{
}
-AnimationParticle::AnimationParticle(Map *const map,
- XmlNodePtr const animationNode,
+AnimationParticle::AnimationParticle(XmlNodePtr const animationNode,
const std::string& dyePalettes):
- ImageParticle(map, nullptr),
+ ImageParticle(nullptr),
mAnimation(new SimpleAnimation(animationNode, dyePalettes))
{
}
diff --git a/src/particle/animationparticle.h b/src/particle/animationparticle.h
index 3bfdea0b6..eb864ea86 100644
--- a/src/particle/animationparticle.h
+++ b/src/particle/animationparticle.h
@@ -34,9 +34,9 @@ class SimpleAnimation;
class AnimationParticle final : public ImageParticle
{
public:
- AnimationParticle(Map *const map, Animation *const animation);
+ AnimationParticle(Animation *const animation);
- AnimationParticle(Map *const map, XmlNodePtr const animationNode,
+ AnimationParticle(XmlNodePtr const animationNode,
const std::string& dyePalettes = std::string());
A_DELETE_COPY(AnimationParticle)
diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp
index b3ff2fd18..7e7139292 100644
--- a/src/particle/imageparticle.cpp
+++ b/src/particle/imageparticle.cpp
@@ -30,8 +30,8 @@
std::map<std::string, int> ImageParticle::imageParticleCountByName;
-ImageParticle::ImageParticle(Map *const map, Image *const image):
- Particle(map),
+ImageParticle::ImageParticle(Image *const image):
+ Particle(),
mImage(image)
{
if (mImage)
diff --git a/src/particle/imageparticle.h b/src/particle/imageparticle.h
index 7c768525d..26a5ac651 100644
--- a/src/particle/imageparticle.h
+++ b/src/particle/imageparticle.h
@@ -42,7 +42,7 @@ class ImageParticle : public Particle
* @param map the map this particle appears on
* @param image an Image instance, may not be NULL
*/
- ImageParticle(Map *const map, Image *const image);
+ ImageParticle(Image *const image);
A_DELETE_COPY(ImageParticle)
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index 1427ffae0..7bdc24345 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -52,7 +52,7 @@ int Particle::emitterSkip = 1;
bool Particle::enabled = true;
const float Particle::PARTICLE_SKY = 800.0F;
-Particle::Particle(Map *const map) :
+Particle::Particle() :
Actor(),
mAlpha(1.0F),
mLifetimeLeft(-1),
@@ -76,7 +76,6 @@ Particle::Particle(Map *const map) :
mAllowSizeAdjust(false),
mFollow(false)
{
- setMap(map);
Particle::particleCount++;
}
@@ -276,7 +275,8 @@ void Particle::moveTo(const float x, const float y)
Particle *Particle::createChild()
{
- Particle *const newParticle = new Particle(mMap);
+ Particle *const newParticle = new Particle();
+ newParticle->setMap(mMap);
mChildParticles.push_back(newParticle);
return newParticle;
}
@@ -314,13 +314,15 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
// Animation
if ((node = XML::findFirstChildByName(effectChildNode, "animation")))
{
- newParticle = new AnimationParticle(mMap, node, dyePalettes);
+ newParticle = new AnimationParticle(node, dyePalettes);
+ newParticle->setMap(mMap);
}
// Rotational
else if ((node = XML::findFirstChildByName(
effectChildNode, "rotation")))
{
- newParticle = new RotationalParticle(mMap, node, dyePalettes);
+ newParticle = new RotationalParticle(node, dyePalettes);
+ newParticle->setMap(mMap);
}
// Image
else if ((node = XML::findFirstChildByName(effectChildNode, "image")))
@@ -331,12 +333,14 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
Dye::instantiate(imageSrc, dyePalettes);
Image *const img = resman->getImage(imageSrc);
- newParticle = new ImageParticle(mMap, img);
+ newParticle = new ImageParticle(img);
+ newParticle->setMap(mMap);
}
// Other
else
{
- newParticle = new Particle(mMap);
+ newParticle = new Particle();
+ newParticle->setMap(mMap);
}
// Read and set the basic properties of the particle
@@ -415,8 +419,8 @@ Particle *Particle::addTextSplashEffect(const std::string &text,
gcn::Font *const font,
const bool outline)
{
- Particle *const newParticle = new TextParticle(
- mMap, text, color, font, outline);
+ Particle *const newParticle = new TextParticle(text, color, font, outline);
+ newParticle->setMap(mMap);
newParticle->moveTo(static_cast<float>(x), static_cast<float>(y));
newParticle->setVelocity(
static_cast<float>((rand() % 100) - 50) / 200.0F, // X
@@ -439,8 +443,8 @@ Particle *Particle::addTextRiseFadeOutEffect(const std::string &text,
gcn::Font *const font,
const bool outline)
{
- Particle *const newParticle = new TextParticle(
- mMap, text, color, font, outline);
+ Particle *const newParticle = new TextParticle(text, color, font, outline);
+ newParticle->setMap(mMap);
newParticle->moveTo(static_cast<float>(x), static_cast<float>(y));
newParticle->setVelocity(0.0F, 0.0F, 0.5F);
newParticle->setGravity(0.0015F);
diff --git a/src/particle/particle.h b/src/particle/particle.h
index 7c891dd86..a22fe7041 100644
--- a/src/particle/particle.h
+++ b/src/particle/particle.h
@@ -72,12 +72,7 @@ class Particle : public Actor
static bool enabled; // true when non-crucial particle effects
// are disabled
- /**
- * Constructor.
- *
- * @param map the map this particle will add itself to, may be nullptr
- */
- explicit Particle(Map *const map);
+ Particle();
A_DELETE_COPY(Particle)
diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp
index 089fa31de..bddd43f54 100644
--- a/src/particle/particleemitter.cpp
+++ b/src/particle/particleemitter.cpp
@@ -584,21 +584,25 @@ std::list<Particle *> ParticleEmitter::createParticles(const int tick)
if (ImageParticle::imageParticleCountByName[name] > 200)
break;
- newParticle = new ImageParticle(mMap, mParticleImage);
+ newParticle = new ImageParticle(mParticleImage);
+ newParticle->setMap(mMap);
}
else if (!mParticleRotation.mFrames.empty())
{
Animation *const newAnimation = new Animation(mParticleRotation);
- newParticle = new RotationalParticle(mMap, newAnimation);
+ newParticle = new RotationalParticle(newAnimation);
+ newParticle->setMap(mMap);
}
else if (!mParticleAnimation.mFrames.empty())
{
Animation *const newAnimation = new Animation(mParticleAnimation);
- newParticle = new AnimationParticle(mMap, newAnimation);
+ newParticle = new AnimationParticle(newAnimation);
+ newParticle->setMap(mMap);
}
else
{
- newParticle = new Particle(mMap);
+ newParticle = new Particle();
+ newParticle->setMap(mMap);
}
const Vector position(mParticlePosX.value(tick),
diff --git a/src/particle/rotationalparticle.cpp b/src/particle/rotationalparticle.cpp
index c16baf391..4cf726c32 100644
--- a/src/particle/rotationalparticle.cpp
+++ b/src/particle/rotationalparticle.cpp
@@ -31,17 +31,15 @@
static const double PI = M_PI;
static const float PI2 = 2 * M_PI;
-RotationalParticle::RotationalParticle(Map *const map,
- Animation *const animation) :
- ImageParticle(map, nullptr),
+RotationalParticle::RotationalParticle(Animation *const animation) :
+ ImageParticle(nullptr),
mAnimation(new SimpleAnimation(animation))
{
}
-RotationalParticle::RotationalParticle(Map *const map,
- const XmlNodePtr animationNode,
+RotationalParticle::RotationalParticle(const XmlNodePtr animationNode,
const std::string& dyePalettes):
- ImageParticle(map, nullptr),
+ ImageParticle(nullptr),
mAnimation(new SimpleAnimation(animationNode, dyePalettes))
{
}
diff --git a/src/particle/rotationalparticle.h b/src/particle/rotationalparticle.h
index a32decb72..6f07f51d5 100644
--- a/src/particle/rotationalparticle.h
+++ b/src/particle/rotationalparticle.h
@@ -34,9 +34,9 @@ class SimpleAnimation;
class RotationalParticle final : public ImageParticle
{
public:
- RotationalParticle(Map *const map, Animation *const animation);
+ RotationalParticle(Animation *const animation);
- RotationalParticle(Map *const map, const XmlNodePtr animationNode,
+ RotationalParticle(const XmlNodePtr animationNode,
const std::string& dyePalettes = std::string());
A_DELETE_COPY(RotationalParticle)
diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp
index 35bef33d5..0a1798c21 100644
--- a/src/particle/textparticle.cpp
+++ b/src/particle/textparticle.cpp
@@ -31,10 +31,10 @@
#include "debug.h"
-TextParticle::TextParticle(Map *const map, const std::string &text,
+TextParticle::TextParticle(const std::string &text,
const gcn::Color *const color,
gcn::Font *const font, const bool outline) :
- Particle(map),
+ Particle(),
mText(text),
mTextFont(font),
mColor(color),
diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h
index 16dfd9158..272f1c6e1 100644
--- a/src/particle/textparticle.h
+++ b/src/particle/textparticle.h
@@ -31,7 +31,7 @@ class TextParticle final : public Particle
/**
* Constructor.
*/
- TextParticle(Map *const map, const std::string &text,
+ TextParticle(const std::string &text,
const gcn::Color *const color,
gcn::Font *const font, const bool outline = false);