#pragma once

#include "MW4.hpp"
#include "WeaponMover.hpp"

namespace Adept{class Effect;}

namespace MechWarrior4
{	

	class Explosive;

	//##########################################################################
	//###########################   Explosive::GameModel    ####################
	//##########################################################################

	class Explosive__GameModel:
		public WeaponMover__GameModel
	{
	public:
		
		Stuff::Scalar
			timerLength;

		enum {
			TimerLengthAttributeID = WeaponMover__GameModel::NextAttributeID,
			NextAttributeID
		};

		static bool
			ReadAndVerify(
				Explosive__GameModel *model,
				ModelAttributeEntry *attribute_entry, 
				const char *data,
				char **error,
				int error_buffer = 128
			);

		static void
			ConstructGameModel(Script *script);
	};

	
	//##########################################################################
	//############################    Explosive    #############################
	//##########################################################################

	//-------------------------------------------------------------------------
	// The following helper classes must always be typedef'd or overriden by an
	// inheritor
	//
	typedef WeaponMover__ClassData						Explosive__ClassData;
	typedef WeaponMover__Message						Explosive__Message;
	typedef WeaponMover__CreateMessage					Explosive__CreateMessage;
	typedef WeaponMover__ExecutionStateEngine			Explosive__ExecutionStateEngine;
	
	//-----------------------  End of inheritance stuff ------------------------

	class Explosive:
		public WeaponMover
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		typedef WeaponMover BaseClass;

	//##########################################################################
	// Inheritance support
	//
	public:
		typedef Explosive__ClassData						ClassData;
		typedef Explosive__GameModel						GameModel;
		typedef Explosive__Message							Message;
		typedef Explosive__ExecutionStateEngine				ExecutionStateEngine;
		typedef Explosive__CreateMessage					CreateMessage;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Run-time Construction and Destruction Support
	//
	public:
		static Explosive* 
			Make(
				CreateMessage *message,
				ReplicatorID *base_id
			);
	
		Explosive(
			ClassData *class_data,
			CreateMessage *message,
			ReplicatorID *base_id,
			ElementRenderer::Element *element
		);

		~Explosive();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Class Data support
	//
	public:
		static ClassData
			*DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Game Model support
	//
	public:
		const GameModel*
			GetGameModel()
				{return Cast_Pointer(const GameModel*, gameModelResource.GetPointer());}

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Execution Support
	//
	public:
		void
			PreCollisionExecute(Stuff::Time till);
		void
			PostCollisionExecute(Stuff::Time till);
		void
			DealSplashDamage(const CollisionData *data);
	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Test Support
	//
	public:
		void
      		TestInstance() const;
	};
}
