tibia-client/src/framework/graphics/particlesystem.cpp

33 lines
837 B
C++
Raw Normal View History

2011-12-15 19:20:09 +01:00
#include "particlesystem.h"
bool ParticleSystem::load(const OTMLNodePtr& node)
{
for(const OTMLNodePtr& childNode : node->children()) {
if(childNode->tag() == "Emitter") {
ParticleEmitterPtr emitter = ParticleEmitterPtr(new ParticleEmitter);
emitter->load(childNode);
m_emitters.push_back(emitter);
}
}
return true;
}
void ParticleSystem::render()
{
for(auto it = m_emitters.begin(), end = m_emitters.end(); it != end; ++it)
(*it)->render();
}
void ParticleSystem::update()
{
for(auto it = m_emitters.begin(), end = m_emitters.end(); it != end;) {
const ParticleEmitterPtr& emitter = *it;
if(emitter->hasFinished()) {
it = m_emitters.erase(it);
continue;
}
emitter->update();
++it;
}
}