//===========================================================================//
// File:	Tank.hpp											
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 09/09/98  JSE  Inital base class based off of Shadowrun/Adept
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Fasa Interactive										 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#pragma once

#include "MW4.hpp"
#include "Vehicle.hpp"

namespace MechWarrior4
{	
	//##########################################################################
	//############################    Tank    ###############################
	//##########################################################################

	//-------------------------------------------------------------------------
	// The following helper classes must always be typedef'd or overriden by an
	// inheritor
	//
	typedef Vehicle__GameModel				Tank__GameModel;
	typedef Vehicle__Message				Tank__Message;
	typedef Vehicle__UpdateMessage			Tank__UpdateMessage;
	typedef Vehicle__CreateMessage			Tank__CreateMessage;
	typedef Vehicle__ClassData				Tank__ClassData;
	typedef Vehicle__ExecutionStateEngine	Tank__ExecutionStateEngine;

	extern DWORD Executed_Tank_Count;

	//-----------------------  End of inheritance stuff ------------------------

	class Tank:
		public Vehicle
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		typedef Vehicle BaseClass;

	//##########################################################################
	// Inheritance support
	//
	public:
		typedef Tank__ClassData							ClassData;
		typedef Tank__GameModel							GameModel;
		typedef Tank__Message							Message;
		typedef Tank__ExecutionStateEngine				ExecutionStateEngine;
		typedef Tank__CreateMessage						CreateMessage;
	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Run-time Construction and Destruction Support
	//
	public:
		static Tank*
			Make(
				CreateMessage *message,
				ReplicatorID *base_id
			);
	
		void
			SaveInstanceText(Stuff::Page *page);

	protected:
		Tank(
			ClassData *class_data,
			CreateMessage *message,
			ReplicatorID *base_id,
			ElementRenderer::Element *element
		);
		
		void
			Respawn(Adept::Entity::CreateMessage *message);
		void
			CommonCreation(CreateMessage *message);

		void
			Reuse(
				const CreateMessage *message,
				ReplicatorID *base_id
			);

		~Tank();

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

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

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Execution Support
	//
	public:
		void
			PreCollisionExecute(Stuff::Time till);
		void PostCollisionExecute (Stuff::Time time);

		void ReactToDestruction(int damage_mode, int damage_type);

		bool
			CollisionHandler(
				Stuff::LinearMatrix4D *new_position,
				Stuff::DynamicArrayOf<CollisionData> *collisions
			);

// MSL 5.04 Tank
		//should this tank be scored?
		bool m_scoreThisTank;

// MSL 5.06 Armor Mode
		int m_ArmorMode;

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

}
