GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/particle/particleengine.h Lines: 0 1 0.0 %
Date: 2021-03-17 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-2019  The ManaPlus Developers
6
 *  Copyright (C) 2019-2021  Andrei Karas
7
 *
8
 *  This file is part of The ManaPlus Client.
9
 *
10
 *  This program is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  any later version.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU General Public License
21
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
24
#ifndef PARTICLE_PARTICLEENGINE_H
25
#define PARTICLE_PARTICLEENGINE_H
26
27
#include "enums/particle/particlephysics.h"
28
29
#include <list>
30
#include <string>
31
32
#include "localconsts.h"
33
34
class Color;
35
class Font;
36
class Map;
37
class Particle;
38
class ParticleEmitter;
39
40
typedef std::list<Particle *> Particles;
41
typedef Particles::iterator ParticleIterator;
42
typedef Particles::const_iterator ParticleConstIterator;
43
typedef std::list<ParticleEmitter *> Emitters;
44
typedef Emitters::iterator EmitterIterator;
45
typedef Emitters::const_iterator EmitterConstIterator;
46
47
class ParticleEngine final
48
{
49
    public:
50
        static const float PARTICLE_SKY;  // Maximum Z position of particles
51
        static ParticlePhysicsT fastPhysics;  // Mode of squareroot calculation
52
        static int particleCount;         // Current number of particles
53
        static int maxCount;              // Maximum number of particles
54
        static int emitterSkip;           // Duration of pause between two
55
                                          // emitter updates in ticks
56
        static bool enabled;  // true when non-crucial particle effects
57
                              // are disabled
58
59
        ParticleEngine();
60
61
        A_DELETE_COPY(ParticleEngine)
62
63
        /**
64
         * Destructor.
65
         */
66
        ~ParticleEngine();
67
68
        /**
69
         * Deletes all child particles and emitters.
70
         */
71
        void clear() restrict2;
72
73
        /**
74
         * Gives a particle the properties of an engine root particle and loads
75
         * the particle-related config settings.
76
         */
77
        static void setupEngine();
78
79
        /**
80
         * Updates particle position, returns false when the particle should
81
         * be deleted.
82
         */
83
        bool update() restrict2;
84
85
        /**
86
         * Creates a blank particle as a child of the current particle
87
         * Useful for creating target particles
88
         */
89
        Particle *createChild() restrict2;
90
91
        /**
92
         * Creates a child particle that hosts some emitters described in the
93
         * particleEffectFile.
94
         */
95
        Particle *addEffect(const std::string &restrict particleEffectFile,
96
                            const int pixelX,
97
                            const int pixelY,
98
                            const int rotation) restrict2;
99
100
        /**
101
         * Creates a standalone text particle.
102
         */
103
        Particle *addTextSplashEffect(const std::string &restrict text,
104
                                      const int x,
105
                                      const int y,
106
                                      const Color *restrict const color,
107
                                      Font *restrict const font,
108
                                      const bool outline)
109
                                      restrict2 A_NONNULL(5, 6);
110
111
        /**
112
         * Creates a standalone text particle.
113
         */
114
        Particle *addTextRiseFadeOutEffect(const std::string &restrict text,
115
                                           const int x,
116
                                           const int y,
117
                                           const Color *restrict const color,
118
                                           Font *restrict const font,
119
                                           const bool outline)
120
                                           restrict2 A_NONNULL(5, 6);
121
122
        void setMap(Map *const map)
123
        { mMap = map; }
124
125
    private:
126
        // List of particles controlled by this particle
127
        Particles mChildParticles;
128
        Particles mChildMoveParticles;
129
        Map *mMap;
130
};
131
132
extern ParticleEngine *particleEngine;
133
134
#endif  // PARTICLE_PARTICLEENGINE_H