ManaPlus
Public Member Functions | Protected Attributes
ParticleList Class Reference

#include <particlelist.h>

Inheritance diagram for ParticleList:
ParticleContainer

Public Member Functions

 ParticleList (ParticleContainer *const parent=0, const bool delParent=true)
 
 ~ParticleList ()
 
void addLocally (Particle *const particle)
 
void removeLocally (const Particle *const particle)
 
void clearLocally ()
 
void moveTo (const float x, const float y)
 
size_t size () const
 
- Public Member Functions inherited from ParticleContainer
 ParticleContainer (ParticleContainer *const parent=0, const bool delParent=true)
 
virtual ~ParticleContainer ()
 
void clear ()
 

Protected Attributes

std::list< Particle * > mElements
 
size_t mSize
 
- Protected Attributes inherited from ParticleContainer
ParticleContainermNext
 
bool mDelParent
 

Detailed Description

Linked list of particle effects.

Definition at line 37 of file particlelist.h.

Constructor & Destructor Documentation

◆ ParticleList()

ParticleList::ParticleList ( ParticleContainer *const  parent = 0,
const bool  delParent = true 
)
explicit

Definition at line 34 of file particlelist.cpp.

35  :
36  ParticleContainer(parent, delParent),
37  mElements(),
38  mSize(0U)
39 {}
ParticleContainer(ParticleContainer *const parent=0, const bool delParent=true)
size_t mSize
Definition: particlelist.h:66
std::list< Particle * > mElements
Definition: particlelist.h:65

◆ ~ParticleList()

ParticleList::~ParticleList ( )

Definition at line 41 of file particlelist.cpp.

42 {
43 }

Member Function Documentation

◆ addLocally()

void ParticleList::addLocally ( Particle *const  particle)

Takes control of and adds a particle

Definition at line 45 of file particlelist.cpp.

References mElements, and mSize.

Referenced by ActorSprite::controlAutoParticle(), and ActorSprite::controlCustomParticle().

46 {
47  if (particle != nullptr)
48  {
49  mElements.push_back(particle);
50  mSize ++;
51  }
52 }
size_t mSize
Definition: particlelist.h:66
std::list< Particle * > mElements
Definition: particlelist.h:65

◆ clearLocally()

void ParticleList::clearLocally ( )
virtual

Kills and removes all particle effects (only in this container)

Reimplemented from ParticleContainer.

Definition at line 74 of file particlelist.cpp.

References FOR_EACH, mElements, and mSize.

75 {
77  {
78  (*it)->kill();
79  (*it)->prepareToDie();
80  }
81 
82  mElements.clear();
83  mSize = 0U;
84 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
size_t mSize
Definition: particlelist.h:66
std::list< Particle * > mElements
Definition: particlelist.h:65
std::list< Particle * >::const_iterator ParticleListCIter

◆ moveTo()

void ParticleList::moveTo ( const float  x,
const float  y 
)
virtual

Sets the positions of all elements

Reimplemented from ParticleContainer.

Definition at line 86 of file particlelist.cpp.

References Particle::isExtinct(), Particle::kill(), mElements, ParticleContainer::moveTo(), Particle::moveTo(), and mSize.

Referenced by ActorSprite::logic().

87 {
89 
90  for (std::list<Particle *>::iterator it = mElements.begin();
91  it != mElements.end(); )
92  {
93  Particle *const p = *it;
94  p->moveTo(x, y);
95  if (p->isExtinct())
96  {
97  p->kill();
98  it = mElements.erase(it);
99  mSize --;
100  }
101  else
102  {
103  ++it;
104  }
105  }
106 }
void kill()
Definition: particle.h:219
size_t mSize
Definition: particlelist.h:66
bool isExtinct() const
Definition: particle.h:213
virtual void moveTo(const float x, const float y)
void moveTo(const Vector &pos)
Definition: particle.h:106
std::list< Particle * > mElements
Definition: particlelist.h:65

◆ removeLocally()

void ParticleList::removeLocally ( const Particle *const  particle)

`kills' and removes a particle

Definition at line 54 of file particlelist.cpp.

References Particle::kill(), mElements, mSize, and Particle::prepareToDie().

Referenced by ActorSprite::controlParticleDeleted(), Being::recreateItemParticles(), Being::removeItemParticles(), Being::removeSpecialEffect(), Being::removeSpiritBalls(), and LocalPlayer::setTestParticle().

55 {
56  for (std::list<Particle *>::iterator it = mElements.begin();
57  it != mElements.end(); )
58  {
59  Particle *const p = *it;
60  if (p == particle)
61  {
62  p->kill();
63  p->prepareToDie();
64  it = mElements.erase(it);
65  mSize --;
66  }
67  else
68  {
69  ++it;
70  }
71  }
72 }
void prepareToDie()
Definition: particle.cpp:564
void kill()
Definition: particle.h:219
size_t mSize
Definition: particlelist.h:66
std::list< Particle * > mElements
Definition: particlelist.h:65

◆ size()

size_t ParticleList::size ( ) const
inline

Definition at line 61 of file particlelist.h.

References mSize.

Referenced by ActorSprite::getParticlesCount().

62  { return mSize; }
size_t mSize
Definition: particlelist.h:66

Field Documentation

◆ mElements

std::list<Particle *> ParticleList::mElements
protected

Contained particle effects

Definition at line 65 of file particlelist.h.

Referenced by addLocally(), clearLocally(), moveTo(), and removeLocally().

◆ mSize

size_t ParticleList::mSize
protected

Definition at line 66 of file particlelist.h.

Referenced by addLocally(), clearLocally(), moveTo(), removeLocally(), and size().


The documentation for this class was generated from the following files: