#pragma once

#include "MW4.hpp"
#include "ProjectileWeapon.hpp"

namespace MechWarrior4
{
	
	typedef ProjectileWeapon__CreateMessage				LBXWeaponSub__CreateMessage;
	typedef ProjectileWeapon__ExecutionStateEngine		LBXWeaponSub__ExecutionStateEngine;
	typedef ProjectileWeapon__Message					LBXWeaponSub__Message;
	typedef ProjectileWeapon__ClassData					LBXWeaponSub__ClassData;

	//##########################################################################
	//#####################   LBXWeaponSub::GameModel    #######################
	//##########################################################################

	class LBXWeaponSub__GameModel:
		public ProjectileWeapon::GameModel
	{
	public:
		typedef ProjectileWeapon::GameModel BaseClass;

		Stuff::Scalar 
			m_disipationStart;
		Stuff::Scalar
			m_maxDisipation;

		enum {
			DisipationStartAttributeID = ProjectileWeapon__GameModel::NextAttributeID,
			MaxDisipationAttributeID,
			NextAttributeID
		};

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

		static void
			ConstructGameModel(Script *script);
	};

	//##########################################################################
	//###########################   LBXWeaponSub    ############################
	//##########################################################################


	class LBXWeaponSub:
		public ProjectileWeapon
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

	//##########################################################################
	// Inheritance support
	//
	public:
		typedef LBXWeaponSub__ClassData							ClassData;
		typedef LBXWeaponSub__GameModel							GameModel;
		typedef LBXWeaponSub__Message							Message;
		typedef LBXWeaponSub__ExecutionStateEngine				ExecutionStateEngine;
		typedef LBXWeaponSub__CreateMessage						CreateMessage;


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

		~LBXWeaponSub();

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

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

	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Simulation Support
	//
	public:
		void
			CreateProjectile(Stuff::Time till);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Test Support
	//
	public:
		void
      		TestInstance() const;
	};
}


