//	ParticleGenerator.h - Simple particle generator.
//  ----------------------------------------------------------------------------
//	This file is part of 'NiallsAVLib', base code for any kind of audiovisual
//	apps.
//	Copyright (C) 2012  Niall Moody
//	
//	This program is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program.  If not, see <http://www.gnu.org/licenses/>.
//	----------------------------------------------------------------------------

#ifndef PARTICLEGENERATOR_H_
#define PARTICLEGENERATOR_H_

#include "ThreeFloats.h"
#include "c0xHeaders.h"
#include "TwoFloats.h"

#include <vector>

class Drawer;

///	Simple particle generator.
class ParticleGenerator
{
  public:
	///	Constructor.
	ParticleGenerator();
	///	Destructor.
	~ParticleGenerator();

	///	Moves the particles.
	void update();
	///	Draws the particles.
	void draw(shared_ptr<Drawer>& d, float timestepInterp);

	///	Triggers an explosion of particles at the passed-in position.
	void trigger(const TwoFloats& pos);

	///	Sets the global gravity for this generator.
	void setGravity(const TwoFloats& val);
	///	Sets the global colour for this generator.
	void setColour(const ThreeFloats& val);
	///	Sets the global fade colour for this generator.
	void setFadeColour(const ThreeFloats& val);
  private:
	///	Struct representing a single particle.
	struct Particle
	{
		///	The particle's position.
		TwoFloats position;
		///	The particle's direction.
		TwoFloats direction;
		///	The particle's speed.
		float speed;
		///	The particle's lifespan.
		float life;
	};

	///	All the currently active particles.
	std::vector<Particle> particles;

	///	The minimum speed a particle can move.
	const float minSpeed;
	///	The maximum speed a particle can move.
	const float maxSpeed;

	///	Direction & amount of gravity to apply to particles.
	TwoFloats gravity;
	///	The colour of the particles.
	ThreeFloats colour;
	///	The faded colour of the particles.
	ThreeFloats fadeColour;
};

#endif
