GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/particle/particleengine.h Lines: 0 1 0.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
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-2017  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_PARTICLEENGINE_H
24
#define PARTICLE_PARTICLEENGINE_H
25
26
#include "enums/particle/particlephysics.h"
27
28
#include <list>
29
#include <string>
30
31
#include "localconsts.h"
32
33
class Color;
34
class Font;
35
class Map;
36
class Particle;
37
class ParticleEmitter;
38
39
typedef std::list<Particle *> Particles;
40
typedef Particles::iterator ParticleIterator;
41
typedef Particles::const_iterator ParticleConstIterator;
42
typedef std::list<ParticleEmitter *> Emitters;
43
typedef Emitters::iterator EmitterIterator;
44
typedef Emitters::const_iterator EmitterConstIterator;
45
46
class ParticleEngine final
47
{
48
    public:
49
        static const float PARTICLE_SKY;  // Maximum Z position of particles
50
        static ParticlePhysicsT fastPhysics;  // Mode of squareroot calculation
51
        static int particleCount;         // Current number of particles
52
        static int maxCount;              // Maximum number of particles
53
        static int emitterSkip;           // Duration of pause between two
54
                                          // emitter updates in ticks
55
        static bool enabled;  // true when non-crucial particle effects
56
                              // are disabled
57
58
        ParticleEngine();
59
60
        A_DELETE_COPY(ParticleEngine)
61
62
        /**
63
         * Destructor.
64
         */
65
        ~ParticleEngine();
66
67
        /**
68
         * Deletes all child particles and emitters.
69
         */
70
        void clear() restrict2;
71
72
        /**
73
         * Gives a particle the properties of an engine root particle and loads
74
         * the particle-related config settings.
75
         */
76
        void setupEngine() restrict2;
77
78
        /**
79
         * Updates particle position, returns false when the particle should
80
         * be deleted.
81
         */
82
        bool update() restrict2;
83
84
        /**
85
         * Creates a blank particle as a child of the current particle
86
         * Useful for creating target particles
87
         */
88
        Particle *createChild() restrict2;
89
90
        /**
91
         * Creates a child particle that hosts some emitters described in the
92
         * particleEffectFile.
93
         */
94
        Particle *addEffect(const std::string &restrict particleEffectFile,
95
                            const int pixelX, const int pixelY,
96
                            const int rotation = 0) restrict2;
97
98
        /**
99
         * Creates a standalone text particle.
100
         */
101
        Particle *addTextSplashEffect(const std::string &restrict text,
102
                                      const int x, const int y,
103
                                      const Color *restrict const color,
104
                                      Font *restrict const font,
105
                                      const bool outline = false)
106
                                      restrict2 A_NONNULL(5, 6);
107
108
        /**
109
         * Creates a standalone text particle.
110
         */
111
        Particle *addTextRiseFadeOutEffect(const std::string &restrict text,
112
                                           const int x, const int y,
113
                                           const Color *restrict const color,
114
                                           Font *restrict const font,
115
                                           const bool outline = false)
116
                                           restrict2 A_NONNULL(5, 6);
117
118
        void setMap(Map *const map)
119
        { mMap = map; }
120
121
    private:
122
        // List of particles controlled by this particle
123
        Particles mChildParticles;
124
        Particles mChildMoveParticles;
125
        Map *mMap;
126
};
127
128
extern ParticleEngine *particleEngine;
129
130
#endif  // PARTICLE_PARTICLEENGINE_H