~ubuntu-branches/ubuntu/trusty/manaplus/trusty-proposed

« back to all changes in this revision

Viewing changes to src/particle/particleemitter.h

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-09-17 10:35:51 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130917103551-az7p3nz9jgxwqjfn
Tags: 1.3.9.15-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  The ManaPlus Client
 
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
 
6
 *
 
7
 *  This file is part of The ManaPlus Client.
 
8
 *
 
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
 
12
 *  any later version.
 
13
 *
 
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.
 
18
 *
 
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/>.
 
21
 */
 
22
 
 
23
#ifndef PARTICLE_PARTICLEEMITTER_H
 
24
#define PARTICLE_PARTICLEEMITTER_H
 
25
 
 
26
#include "particle/particleemitterprop.h"
 
27
 
 
28
#include "resources/animation.h"
 
29
 
 
30
#include "utils/xml.h"
 
31
 
 
32
#include <list>
 
33
 
 
34
class Image;
 
35
class ImageSet;
 
36
class Map;
 
37
class Particle;
 
38
 
 
39
/**
 
40
 * Every Particle can have one or more particle emitters that create new
 
41
 * particles when they are updated
 
42
 */
 
43
class ParticleEmitter final
 
44
{
 
45
    public:
 
46
        ParticleEmitter(const XmlNodePtr emitterNode, Particle *const target,
 
47
                        Map *const map, const int rotation = 0,
 
48
                        const std::string& dyePalettes = std::string());
 
49
 
 
50
        /**
 
51
         * Copy Constructor (necessary for reference counting of particle images)
 
52
         */
 
53
        ParticleEmitter(const ParticleEmitter &o);
 
54
 
 
55
        /**
 
56
         * Assignment operator that calls the copy constructor
 
57
         */
 
58
        ParticleEmitter & operator=(const ParticleEmitter &o);
 
59
 
 
60
        /**
 
61
         * Destructor.
 
62
         */
 
63
        ~ParticleEmitter();
 
64
 
 
65
        /**
 
66
         * Spawns new particles
 
67
         * @return: a list of created particles
 
68
         */
 
69
        std::list<Particle *> createParticles(const int tick);
 
70
 
 
71
        /**
 
72
         * Sets the target of the particles that are created
 
73
         */
 
74
        void setTarget(Particle *const target)
 
75
        { mParticleTarget = target; }
 
76
 
 
77
        /**
 
78
         * Changes the size of the emitter so that the effect fills a
 
79
         * rectangle of this size
 
80
         */
 
81
        void adjustSize(const int w, const int h);
 
82
 
 
83
    private:
 
84
        template <typename T> ParticleEmitterProp<T>
 
85
            readParticleEmitterProp(XmlNodePtr propertyNode, T def);
 
86
 
 
87
        ImageSet *getImageSet(XmlNodePtr node);
 
88
 
 
89
        /**
 
90
         * initial position of particles:
 
91
         */
 
92
        ParticleEmitterProp<float> mParticlePosX, mParticlePosY, mParticlePosZ;
 
93
 
 
94
        /**
 
95
         * initial vector of particles:
 
96
         */
 
97
        ParticleEmitterProp<float> mParticleAngleHorizontal,
 
98
                                   mParticleAngleVertical;
 
99
 
 
100
        /**
 
101
         * Initial velocity of particles
 
102
         */
 
103
        ParticleEmitterProp<float> mParticlePower;
 
104
 
 
105
        /*
 
106
         * Vector changing of particles:
 
107
         */
 
108
        ParticleEmitterProp<float> mParticleGravity;
 
109
        ParticleEmitterProp<int> mParticleRandomness;
 
110
        ParticleEmitterProp<float> mParticleBounce;
 
111
 
 
112
        /*
 
113
         * Properties of targeting particles:
 
114
         */
 
115
        Particle *mParticleTarget;
 
116
        ParticleEmitterProp<float> mParticleAcceleration;
 
117
        ParticleEmitterProp<float> mParticleDieDistance;
 
118
        ParticleEmitterProp<float> mParticleMomentum;
 
119
 
 
120
        /*
 
121
         * Behavior over time of the particles:
 
122
         */
 
123
        ParticleEmitterProp<int> mParticleLifetime;
 
124
        ParticleEmitterProp<int> mParticleFadeOut;
 
125
        ParticleEmitterProp<int> mParticleFadeIn;
 
126
 
 
127
        // Map the particles are spawned on
 
128
        Map *mMap;
 
129
 
 
130
        // Number of particles spawned per update
 
131
        ParticleEmitterProp<int> mOutput;
 
132
 
 
133
        // Pause in frames between two spawns
 
134
        ParticleEmitterProp<int> mOutputPause;
 
135
 
 
136
        /*
 
137
         * Graphical representation of the particles
 
138
         */
 
139
        // Particle image, if used
 
140
        Image *mParticleImage;
 
141
 
 
142
        // Filename of particle animation file
 
143
        Animation mParticleAnimation;
 
144
 
 
145
        // Filename of particle rotation file
 
146
        Animation mParticleRotation;
 
147
 
 
148
        // Opacity of the graphical representation of the particles
 
149
        ParticleEmitterProp<float> mParticleAlpha;
 
150
 
 
151
        /*
 
152
         * Death effect of the particles
 
153
         */
 
154
        std::string mDeathEffect;
 
155
 
 
156
        // List of emitters the spawned particles are equipped with
 
157
        std::list<ParticleEmitter> mParticleChildEmitters;
 
158
 
 
159
        std::vector<ImageSet*> mTempSets;
 
160
 
 
161
        int mOutputPauseLeft;
 
162
 
 
163
        signed char mDeathEffectConditions;
 
164
 
 
165
        bool mParticleFollow;
 
166
};
 
167
#endif  // PARTICLE_PARTICLEEMITTER_H