//Copyright (C) 2007 SiegeLord
//See ReadMe.txt and License.txt for copying information

#pragma once

#include "objectex.h"

struct SParticle
{
	vector2d position;
	vector2d velocity;
	zColor color;
	float life;
	float val1;
	SParticle()
	{
		life = 0;
		val1 = 0;
	}
};

struct SParticleHolder : SObjectEx
{
	SParticleHolder() :
	num_particles(0)
	{
		type = particleholder_type;
	}
	SParticleHolder(int num_parts) :
	num_particles(num_parts)
	{
		type = particleholder_type;
	}

	virtual ~SParticleHolder();
	virtual int Handle() {return 0;};
	virtual void Draw() {};

	SParticle* particles;
	const int num_particles;
	int num_alive_particles;

	float* vertices;
	int* colors;
	float* tcoords;

	bool restart;

	SBitmap* bmp;

	void UpdateBuffers();
	void CreateBuffers();
};

struct SAuraParticleHolder : SParticleHolder
{
	SAuraParticleHolder()
	{
		type = auraparticle_type;
	}

	SAuraParticleHolder(int num_parts) :
	SParticleHolder(num_parts)
	{
		type = auraparticle_type;
	}

	virtual int Handle();
	virtual void Draw();

	float radius;
	float acceleration;
	float min_speed;
	float max_speed;
	float dampening;
	float max_life;
	float min_life;
	int throttle;
};

struct SSmokeParticleHolder : SParticleHolder
{
	SSmokeParticleHolder()
	{
		type = smokeparticle_type;
	}

	SSmokeParticleHolder(int num_parts) :
	SParticleHolder(num_parts)
	{
		type = smokeparticle_type;
	}
	//virtual ~SSmokeParticleHolder();
	virtual int Handle();
	virtual void Draw();

	float dampening;
	float random_vel_x;
	float random_vel_y;
	float max_life;
	float min_life;
	float acceleration;
	int throttle;
};

SParticleHolder* InitParticleHolder(SParticleHolder* holder, SObject* parent);

SSmokeParticleHolder* CreateSmokeParticle(SObject* parent, SBitmap* bmp);
SAuraParticleHolder* CreateAuraParticle(SObject* parent, SBitmap* bmp);
