/*
Solar Conquest
Copyright (C) 2006 Greg Beaman

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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#define PROJECTILE_TYPE_BULLET 1
#define PROJECTILE_TYPE_ROCKET 2
#define PROJECTILE_TYPE_LASER 3
#define PROJECTILE_TYPE_FLAK 4
#define PROJECTILE_TYPE_SMALLROCKET 5
#define PROJECTILE_TYPE_PLASMA 6

class CProjectileData
{
private:
public:
	int id;
	int type;
	int damage;
	float colorR;
	float colorG;
	float colorB;
	float colorA;
	float lifeTime;
	float fireDelay;
	float maxSpeed;
	float strafeSpeed;
	float turnRate;
	float radius;

	bool lockonProjectile;

	CProjectileData* prevData;
	CProjectileData* nextData;
	
	CSoundListNode* sound;
	
	CProjectileData();
	~CProjectileData();
};

CProjectileData::CProjectileData()
{
	prevData = NULL;
	nextData = NULL;
	
	sound = NULL;

	lockonProjectile = false;
}

CProjectileData::~CProjectileData()
{
}

CProjectileData* g_firstProjectileData = NULL;

//Just quickly places the Projectile data at the beginning of the linked list
CProjectileData* AddProjectileData(int id)
{
	CProjectileData* newData;
	newData = new CProjectileData();
	if (!newData)
		return NULL;
	newData->nextData = g_firstProjectileData;
	if (g_firstProjectileData)
		g_firstProjectileData->prevData = newData;
	g_firstProjectileData = newData;
	newData->id = id;
	return newData;
}

void DeleteProjectileData(CProjectileData* data)
{
	if (!data)
		return;

	if (data->prevData)
		data->prevData->nextData = data->nextData;
	else
		g_firstProjectileData = data->nextData;
	if (data->nextData)
		data->nextData->prevData = data->prevData;
	delete data;
}

CProjectileData* FindProjectileData(int id)
{
	CProjectileData* data = g_firstProjectileData;
	while (data)
	{
		if (data->id == id)
			return data;
		data = data->nextData;
	}
	return NULL;
}

void DeleteAllProjectileData()
{
	CProjectileData* curData;
	CProjectileData* tmpData;
	curData = g_firstProjectileData;
	while (curData)
	{
		tmpData = curData->nextData;
		delete curData;
		curData = tmpData;
	}
	g_firstProjectileData = NULL;
}
