#ifndef __NUKE_H__
#define __NUKE_H__

#include "g_local.h"
#include "item.h"
#include "weapon.h"
#include "misc.h"
#include "player.h"

// nukeball state flags
#define NBS_EVIL        -1
#define NBS_FLYING      0
#define NBS_COLLAPSING  1
#define NBS_EXPLODING   2
#define NBS_RING1       3
#define NBS_RING2       4

// takes care of applying the flash to players
class NukeFlash : public Entity
{
private:
	Vector fblend;
	float falpha;
public:
	CLASS_PROTOTYPE( NukeFlash );

	virtual void Flash( Event *ev );
	virtual void Setup( Vector pos, float delay );

	virtual void Archive( Archiver &arc );
	virtual void Unarchive( Archiver &arc );
};

inline void NukeFlash::Archive( Archiver &arc )
{
	Entity::Archive( arc );

	arc.WriteVector( fblend );
	arc.WriteFloat( falpha );
}

inline void NukeFlash::Unarchive( Archiver &arc )
{
	Entity::Unarchive( arc );

	arc.ReadVector( &fblend );
	falpha = arc.ReadFloat();
}

// the visual fireballs that the player sees
//class NukeFireball : public Entity
class NukeFireball : public Projectile
{
private:
	int owner;
public:
	CLASS_PROTOTYPE( NukeFireball );

	virtual void Animate( Event *ev );
	virtual void DoDamage( Event *ev );
	virtual void Setup( Entity *owner, Vector pos, float life, int type );
	virtual void Fade( Event *ev );

	virtual void Archive( Archiver &arc );
	virtual void Unarchive( Archiver &arc );
};

inline void NukeFireball::Archive( Archiver &arc )
{
	Projectile::Archive( arc );

	arc.WriteInteger( owner );
}

inline void NukeFireball::Unarchive( Archiver &arc )
{
	Projectile::Unarchive( arc );

	owner = arc.ReadInteger();
}

// this is the ball fired our of the gun
class NukeBall : public Projectile
{
private:
	float speed;
	int ballstate;

public:
	CLASS_PROTOTYPE( NukeBall );

	void Animate( Event *ev );
	void Collapse( Event *ev );
	void Explode( Event *ev );
	void ThrowRing( Event *ev );
	void ExplosionBall( Event *ev );
	void Setup( Entity *owner, Vector pos, Vector dir );
	void EvilSetup( Entity *owner, Vector pos, Vector dir ); // for devious purposes...

	virtual void Archive( Archiver &arc );
	virtual void Unarchive( Archiver &arc );
};

inline void NukeBall::Archive( Archiver &arc )
{
	Projectile::Archive( arc );

	arc.WriteFloat( speed );
	arc.WriteInteger( ballstate );
}

inline void NukeBall::Unarchive( Archiver &arc )
{
	Projectile::Unarchive( arc );

	speed = arc.ReadFloat();
	ballstate = arc.ReadInteger();
}

class IP36 : public Weapon
{
public:
	CLASS_PROTOTYPE( IP36 );

	IP36();
	virtual void Shoot( Event *ev ); // starts the actual firing event
	virtual void Launch( Event *ev ); // does the actual firing
};

#endif /* nuke.h */
