#ifndef PARTICLESYSTEM_H
#define PARTICLESYSTEM_H
#include "fxsystem.h"
#include "particle.h"
#include <vector>

class ParticleSystem : public FXSystem
{
public:	
	ParticleSystem(int id,int type):FXSystem(id,type){};
	virtual int getNumberOfParticles()=0;	
};

template <class TParticle> class TParticleSystem:public ParticleSystem
{
public:
	TParticleSystem(int id,int type):ParticleSystem(id,type){};
	/**
	 * Adds a particle
	 * @param p the particle to add
	 */
	void addParticle(TParticle p)
	{
		particles.push_back(p);
	}

	/**
	 * Updates the physics for all particles in the system
	 * @param timeDiff time difference since last draw
	 */	 
	virtual void think(float time)
	{
		vector<TParticle>::iterator b = particles.begin();
 		while (b != particles.end())
 		{
  			b->doThink(time);
   			b++;
   		}
 	}

	/**
	 * Updates the physics for all particles in the system
	 */
	virtual void draw()
	{	vector<TParticle>::iterator b = particles.begin();
 		while (b != particles.end())
 		{
  			b->doDraw();
  			b++;
 		}	
	}

	int getNumberOfParticles()
	{	return particles.size();
	}
	
protected:
	std::vector<TParticle>particles;	

};
#endif