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

#pragma once

#include "neonz.h"
#include "objectex.h"

struct SShip;

struct SWeaponSlot;

struct SWeapon : SObject
{
	SWeapon()
	{
		type = genericweapon_type;
		range = 0.0f;
		target_ship_id = -2;
	}
	vector2d target_loc;
	int target_ship_id;
	float range;
	float min_damage;
	float max_damage;

	//where we are attached
	SWeaponSlot* slot;

	virtual void Engage(vector2d& target, int ship) = 0;
	virtual void DisEngage() = 0;
	//virtual ~SWeapon();
	//virtual int Handle() = 0;
	//virtual void Draw() = 0;
};

struct SRocketLauncher : SWeapon
{
	SRocketLauncher()
	{
		type = rocketweapon_type;
		rotation_vel = 0;
		rotation_acc = 0;
	}

	float max_rotation_vel;
	float rotation_vel;
	float rotation_acc;

	float timer;
	float reload_time;

	SBitmap* image;

	//pass -1 as the ship id if we are attacking ground
	virtual void Engage(vector2d& target, int ship = -1);
	virtual void DisEngage();
	virtual int Handle();
	virtual void Draw();
};

struct SPlasmaLauncher : SWeapon
{
	SPlasmaLauncher()
	{
		type = plasmaweapon_type;
		rotation_vel = 0;
		rotation_acc = 0;
	}

	float max_rotation_vel;
	float rotation_vel;
	float rotation_acc;

	SBitmap* image;

	float timer;
	float reload_time;

	//pass -1 as the ship id if we are attacking ground
	virtual void Engage(vector2d& target, int ship = -1);
	virtual void DisEngage();
	virtual int Handle();
	virtual void Draw();
};

struct SIonBeamCannon : SWeapon
{
	SIonBeamCannon()
	{
		type = ionbeamweapon_type;
		rotation_vel = 0;
		rotation_acc = 0;
	}

	float max_rotation_vel;
	float rotation_vel;
	float rotation_acc;

	SBitmap* image;

	float timer;
	float reload_time;

	//pass -1 as the ship id if we are attacking ground
	virtual void Engage(vector2d& target, int ship = -1);
	virtual void DisEngage();
	virtual int Handle();
	virtual void Draw();
};

SRocketLauncher* CreateRocketLauncher(SObject* parent, SWeaponSlot* slot);
SPlasmaLauncher* CreatePlasmaLauncher(SObject* parent, SWeaponSlot* slot);
SIonBeamCannon* CreateIonBeamCannon(SObject* parent, SWeaponSlot* slot);

struct SWeaponSlot
{
	SWeaponSlot()
	{
		weapon = 0;
		rotation = 0;
	}
	SWeapon* weapon;
	vector2d position;
	float rotation;
};
