GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/particle/particleengine.h Lines: 0 1 0.0 %
Date: 2018-06-18 21:15:20 Branches: 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-2018  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,
96
                            const int pixelY,
97
                            const int rotation) restrict2;
98
99
        /**
100
         * Creates a standalone text particle.
101
         */
102
        Particle *addTextSplashEffect(const std::string &restrict text,
103
                                      const int x,
104
                                      const int y,
105
                                      const Color *restrict const color,
106
                                      Font *restrict const font,
107
                                      const bool outline)
108
                                      restrict2 A_NONNULL(5, 6);
109
110
        /**
111
         * Creates a standalone text particle.
112
         */
113
        Particle *addTextRiseFadeOutEffect(const std::string &restrict text,
114
                                           const int x,
115
                                           const int y,
116
                                           const Color *restrict const color,
117
                                           Font *restrict const font,
118
                                           const bool outline)
119
                                           restrict2 A_NONNULL(5, 6);
120
121
        void setMap(Map *const map)
122
        { mMap = map; }
123
124
    private:
125
        // List of particles controlled by this particle
126
        Particles mChildParticles;
127
        Particles mChildMoveParticles;
128
        Map *mMap;
129
};
130
131
extern ParticleEngine *particleEngine;
132
133
#endif  // PARTICLE_PARTICLEENGINE_H