diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-04-07 11:27:29 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-05-08 14:03:04 +0000 |
commit | 928c1584b67cb93a2c1e180a73574a84b4e7af01 (patch) | |
tree | f1619940e83fb21871a1fd6993c78a2d092759e0 /src/particle.h | |
parent | 13a0a505bde8868e7ac9d50aa7dfe7d6bbae60c4 (diff) | |
download | mana-particle-system.tar.gz mana-particle-system.tar.bz2 mana-particle-system.tar.xz mana-particle-system.zip |
ParticleEmitter cleanupsparticle-system
* Don't needlessly use explicit heap allocation for ParticleEmitter
instances.
* Initialize ParticleEmitter members at the definition.
Diffstat (limited to 'src/particle.h')
-rw-r--r-- | src/particle.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/particle.h b/src/particle.h index 96013b71..aac45e09 100644 --- a/src/particle.h +++ b/src/particle.h @@ -23,6 +23,7 @@ #include "actor.h" #include "guichanfwd.h" +#include "particleemitter.h" #include "vector.h" #include <list> @@ -33,7 +34,6 @@ class Particle; class ParticleEmitter; using Particles = std::list<Particle *>; -using Emitters = std::list<ParticleEmitter *>; /** * A particle spawned by a ParticleEmitter. @@ -41,7 +41,7 @@ using Emitters = std::list<ParticleEmitter *>; class Particle : public Actor { public: - enum AliveStatus + enum AliveStatus : unsigned char { ALIVE = 0, DEAD_TIMEOUT = 1, @@ -119,9 +119,12 @@ class Particle : public Actor /** * Adds an emitter to the particle. */ - void addEmitter(ParticleEmitter *emitter) + void addEmitter(const ParticleEmitter &emitter) { mChildEmitters.push_back(emitter); } + void addEmitter(ParticleEmitter &&emitter) + { mChildEmitters.push_back(std::move(emitter)); } + /** * Sets the position in 3 dimensional space in pixels relative to map. */ @@ -246,7 +249,7 @@ class Particle : public Actor void setAlpha(float alpha) override {} - void setDeathEffect(const std::string &effectFile, char conditions) + void setDeathEffect(const std::string &effectFile, unsigned char conditions) { mDeathEffect = effectFile; mDeathEffectConditions = conditions; } protected: @@ -266,11 +269,11 @@ class Particle : public Actor AliveStatus mAlive = ALIVE; /**< Is the particle supposed to be drawn and updated?*/ // generic properties bool mAutoDelete = true; /**< May the particle request its deletion by the parent particle? */ - Emitters mChildEmitters; /**< List of child emitters. */ + std::list<ParticleEmitter> mChildEmitters; /**< List of child emitters. */ Particles mChildParticles; /**< List of particles controlled by this particle */ bool mAllowSizeAdjust = false; /**< Can the effect size be adjusted by the object props in the map file? */ std::string mDeathEffect; /**< Particle effect file to be spawned when the particle dies */ - char mDeathEffectConditions = 0;/**< Bitfield of death conditions which trigger spawning of the death particle */ + unsigned char mDeathEffectConditions = 0; /**< Bitfield of death conditions which trigger spawning of the death particle */ // dynamic particle float mGravity = 0.0f; /**< Downward acceleration in pixels per game-tick. */ |