//===========================================================================//
// File:	mechai.hpp																	     //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
//	07/13/99  AHF	Created File                  //
//---------------------------------------------------------------------------//
// Copyright (C) 1999, Microsoft										 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#pragma once

#include "CombatAI.hpp"
#include "mech.hpp"

namespace MechWarrior4
{

	typedef CombatAI__CreateMessage				MechAI__CreateMessage;

	//##########################################################################
	//###########################   MechAI    ##################################
	//##########################################################################

	class MechAI
		: public CombatAI
	{
		typedef CombatAI inherited;
	public:
		static void	InitializeClass();
		static void	TerminateClass();

		static ClassData *DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Inheritance Support
	//
	public:
		typedef MechAI__CreateMessage					CreateMessage;


	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Run-time Construction and Destruction Support
	//
	public:
		static MechAI* Make(CreateMessage *message,ReplicatorID *base_id);
		virtual void Save (MemoryStream *stream);
		virtual void Load (MemoryStream *stream);

		static void NotifyShutDownMechsShotFired(const Adept::Entity::CollisionQuery& query, MWObject& shooter);

	protected:
		MechAI(
			ClassData *class_data,
			CreateMessage *message,
			ReplicatorID *base_id,
			ElementRenderer::Element *element
		);

		virtual ~MechAI();

		static std::list<MechAI*>* m_gShutdownMechAIs;
		static int m_gShutdownMechAIs_RefCount;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Message Support
	//
	public:

		enum {
			DebugTextMessageID = MechWarrior4::CombatAI::NextMessageID,
			NextMessageID
		};

		void DebugTextMessageHandler(Adept::ReceiverDataMessageOf<int> *message);

		virtual bool GetLeaderAlignment(int& alignment);

		protected:

			static const MessageEntry	MessageEntries[];

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Execution Support
	//
	protected:
		MechWarrior4::Mech *m_Mech;

	public:
		virtual void PreCollisionExecute(Stuff::Time till);
		virtual bool ReactToCollision(Stuff::DynamicArrayOf<CollisionData> *collisions,bool& shoulddamage);

		virtual void Shutdown (void);
		virtual void Startup (void);
		virtual void SetOrderSpeed (Stuff::Scalar newvalue);

		virtual bool ShouldRunScript();

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

