3
* Copyright (C) 2008-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_PARTICLECONTAINER_H
24
#define PARTICLE_PARTICLECONTAINER_H
29
#include "localconsts.h"
34
* Set of particle effects. May be stacked with other ParticleContainers. All
35
* operations herein affect such stacked containers, unless the operations end
38
class ParticleContainer
42
* Constructs a new particle container and assumes responsibility for
43
* its parent (for all operations defined herein, except when ending in `Locally')
45
* delParent means that the destructor should also free the parent.
47
explicit ParticleContainer(ParticleContainer *const parent = nullptr,
48
const bool delParent = true);
50
A_DELETE_COPY(ParticleContainer)
52
virtual ~ParticleContainer();
55
* Kills and removes all particle effects
60
* Kills and removes all particle effects (only in this container)
62
virtual void clearLocally()
66
* Sets the positions of all elements
68
virtual void moveTo(const float x, const float y);
71
ParticleContainer *mNext; /**< Contained container, if any */
72
bool mDelParent; /**< Delete mNext in destructor */
76
* Linked list of particle effects.
78
class ParticleList final : public ParticleContainer
81
explicit ParticleList(ParticleContainer *const parent = nullptr,
82
const bool delParent = true);
84
A_DELETE_COPY(ParticleList)
86
virtual ~ParticleList();
89
* Takes control of and adds a particle
91
void addLocally(Particle *const particle);
94
* `kills' and removes a particle
96
void removeLocally(const Particle *const particle);
98
virtual void clearLocally() override;
100
virtual void moveTo(const float x, const float y) override;
103
std::list<Particle *> mElements; /**< Contained particle effects */
107
* Particle container with indexing facilities
109
class ParticleVector final : public ParticleContainer
112
explicit ParticleVector(ParticleContainer *const parent = nullptr,
113
const bool delParent = true);
115
A_DELETE_COPY(ParticleVector)
117
virtual ~ParticleVector();
120
* Sets a particle at a specified index. Kills the previous particle
123
virtual void setLocally(const int index, Particle *const particle);
126
* Removes a particle at a specified index
128
virtual void delLocally(const int index);
130
virtual void clearLocally() override;
132
virtual void moveTo(const float x, const float y) override;
135
std::vector<Particle *> mIndexedElements;
138
#endif // PARTICLE_PARTICLECONTAINER_H