ManaPlus
Public Member Functions | Protected Attributes
ParticleList Class Reference

#include <particlelist.h>

Inheritance diagram for ParticleList:
ParticleContainer

Public Member Functions

 ParticleList (ParticleContainer *const parent, const bool delParent)
 
 ~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, const bool delParent)
 
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 38 of file particlelist.h.

Constructor & Destructor Documentation

◆ ParticleList()

ParticleList::ParticleList ( ParticleContainer *const  parent,
const bool  delParent 
)

Definition at line 35 of file particlelist.cpp.

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

◆ ~ParticleList()

ParticleList::~ParticleList ( )

Definition at line 42 of file particlelist.cpp.

43 {
44 }

Member Function Documentation

◆ addLocally()

void ParticleList::addLocally ( Particle *const  particle)

Takes control of and adds a particle

Definition at line 46 of file particlelist.cpp.

47 {
48  if (particle != nullptr)
49  {
50  mElements.push_back(particle);
51  mSize ++;
52  }
53 }

References mElements, and mSize.

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

◆ clearLocally()

void ParticleList::clearLocally ( )
virtual

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

Reimplemented from ParticleContainer.

Definition at line 75 of file particlelist.cpp.

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

References FOR_EACH, mElements, and mSize.

◆ moveTo()

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

Sets the positions of all elements

Reimplemented from ParticleContainer.

Definition at line 87 of file particlelist.cpp.

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

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

Referenced by ActorSprite::logic().

◆ removeLocally()

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

‘kills’ and removes a particle

Definition at line 55 of file particlelist.cpp.

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

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

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

◆ size()

size_t ParticleList::size ( ) const
inline

Definition at line 62 of file particlelist.h.

63  { return mSize; }

References mSize.

Referenced by ActorSprite::getParticlesCount().

Field Documentation

◆ mElements

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

Contained particle effects

Definition at line 66 of file particlelist.h.

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

◆ mSize

size_t ParticleList::mSize
protected

Definition at line 67 of file particlelist.h.

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


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