
#pragma once

#include "MW4.hpp"
#include "Subsystem.hpp"

namespace MechWarrior4
{
	class Vehicle;

	typedef Subsystem__ClassData							Beagle__ClassData;
	typedef Subsystem__Message								Beagle__Message;
	typedef Subsystem__ExecutionStateEngine					Beagle__ExecutionStateEngine;
	typedef Subsystem__CreateMessage						Beagle__CreateMessage;

	//##########################################################################
	//###########################   ECM GameModel    ###########################
	//##########################################################################

	class Beagle__GameModel:
		public Subsystem::GameModel
	{
	public:
		typedef Subsystem::GameModel BaseClass;

		Stuff::Scalar
			m_targeterMissileLockPercent,	//This is against us
			m_holderMissileLockPercent;		//This is our gain

		enum {
			TargeterMissileLockPercentAttributeID = Subsystem__GameModel::NextAttributeID,
			HolderMissileLockPercentAttributeID,
			NextAttributeID
		};

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


		static void
			ConstructGameModel(Script *script);

	};

	//##########################################################################
	//###########################   Beagle    ##################################
	//##########################################################################

	class Beagle:
		public Subsystem
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

	//##########################################################################
	// Inheritance support
	//
	public:
		typedef Beagle__ClassData						ClassData;
		typedef Beagle__GameModel						GameModel;
		typedef Beagle__Message							Message;
		typedef Beagle__ExecutionStateEngine			ExecutionStateEngine;
		typedef Beagle__CreateMessage					CreateMessage;


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

		~Beagle();

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

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Simulation Support
	//
	public:
		void
			DestroySubsystem();

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


