3
* Copyright (C) 2006-2009 The Mana World Development Team
4
* Copyright (C) 2009-2010 The Mana Developers
5
* Copyright (C) 2011-2013 The ManaPlus Developers
7
* This file is part of The ManaPlus Client.
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#ifndef PARTICLE_PARTICLEEMITTER_H
24
#define PARTICLE_PARTICLEEMITTER_H
26
#include "particle/particleemitterprop.h"
28
#include "resources/animation.h"
30
#include "utils/xml.h"
40
* Every Particle can have one or more particle emitters that create new
41
* particles when they are updated
43
class ParticleEmitter final
46
ParticleEmitter(const XmlNodePtr emitterNode, Particle *const target,
47
Map *const map, const int rotation = 0,
48
const std::string& dyePalettes = std::string());
51
* Copy Constructor (necessary for reference counting of particle images)
53
ParticleEmitter(const ParticleEmitter &o);
56
* Assignment operator that calls the copy constructor
58
ParticleEmitter & operator=(const ParticleEmitter &o);
66
* Spawns new particles
67
* @return: a list of created particles
69
std::list<Particle *> createParticles(const int tick);
72
* Sets the target of the particles that are created
74
void setTarget(Particle *const target)
75
{ mParticleTarget = target; }
78
* Changes the size of the emitter so that the effect fills a
79
* rectangle of this size
81
void adjustSize(const int w, const int h);
84
template <typename T> ParticleEmitterProp<T>
85
readParticleEmitterProp(XmlNodePtr propertyNode, T def);
87
ImageSet *getImageSet(XmlNodePtr node);
90
* initial position of particles:
92
ParticleEmitterProp<float> mParticlePosX, mParticlePosY, mParticlePosZ;
95
* initial vector of particles:
97
ParticleEmitterProp<float> mParticleAngleHorizontal,
98
mParticleAngleVertical;
101
* Initial velocity of particles
103
ParticleEmitterProp<float> mParticlePower;
106
* Vector changing of particles:
108
ParticleEmitterProp<float> mParticleGravity;
109
ParticleEmitterProp<int> mParticleRandomness;
110
ParticleEmitterProp<float> mParticleBounce;
113
* Properties of targeting particles:
115
Particle *mParticleTarget;
116
ParticleEmitterProp<float> mParticleAcceleration;
117
ParticleEmitterProp<float> mParticleDieDistance;
118
ParticleEmitterProp<float> mParticleMomentum;
121
* Behavior over time of the particles:
123
ParticleEmitterProp<int> mParticleLifetime;
124
ParticleEmitterProp<int> mParticleFadeOut;
125
ParticleEmitterProp<int> mParticleFadeIn;
127
// Map the particles are spawned on
130
// Number of particles spawned per update
131
ParticleEmitterProp<int> mOutput;
133
// Pause in frames between two spawns
134
ParticleEmitterProp<int> mOutputPause;
137
* Graphical representation of the particles
139
// Particle image, if used
140
Image *mParticleImage;
142
// Filename of particle animation file
143
Animation mParticleAnimation;
145
// Filename of particle rotation file
146
Animation mParticleRotation;
148
// Opacity of the graphical representation of the particles
149
ParticleEmitterProp<float> mParticleAlpha;
152
* Death effect of the particles
154
std::string mDeathEffect;
156
// List of emitters the spawned particles are equipped with
157
std::list<ParticleEmitter> mParticleChildEmitters;
159
std::vector<ImageSet*> mTempSets;
161
int mOutputPauseLeft;
163
signed char mDeathEffectConditions;
165
bool mParticleFollow;
167
#endif // PARTICLE_PARTICLEEMITTER_H