//===========================================================================//
// File:	Mech.hpp												
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 09/09/98  JSE  Inital base class based off of Shadowrun/Adept             //
// 09/22/98  BDD  Inital base Mech class based off Vehicle					 //
//---------------------------------------------------------------------------//
// 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 Adept
{
	class Effect;
}

namespace MechWarrior4
{
	class Hovercraft;
	class Subsystem;

	//##########################################################################
	//#####################    Hovercraft::ModelResource   #######################
	//##########################################################################

	class Hovercraft__GameModel:
		public Vehicle__GameModel
	{
	public:
		typedef Vehicle__GameModel BaseClass;

		Stuff::Scalar
			hoverVehicleHeight,
			maxHoverVehicleHeight;

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

		static void
			ConstructGameModel(Script *script);

		enum {
			HoverVehicleHeightAttributeID = Vehicle__GameModel::NextAttributeID,
			MaxHoverVehicleHeightAttributeID,
			NextAttributeID
		};
	};

	//##########################################################################
	//############################    Hovercraft   ###############################
	//##########################################################################

	//-------------------------------------------------------------------------
	// The following helper classes must always be typedef'd or overriden by an
	// inheritor
	//
	typedef Vehicle__ClassData							Hovercraft__ClassData;
	typedef Vehicle__Message							Hovercraft__Message;
	typedef Vehicle__ExecutionStateEngine				Hovercraft__ExecutionStateEngine;
	typedef Vehicle__CreateMessage						Hovercraft__CreateMessage;
	
	extern DWORD Executed_Hovercraft_Count;

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

	class Hovercraft:
		public Vehicle
	{
		friend class MovementClass;

	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		typedef Vehicle BaseClass;

	//##########################################################################
	// Inheritance support
	//
	public:
		typedef Hovercraft__ClassData					ClassData;
		typedef Hovercraft__GameModel					GameModel;
		typedef Hovercraft__Message					Message;
		typedef Hovercraft__ExecutionStateEngine		ExecutionStateEngine;
		typedef Hovercraft__CreateMessage				CreateMessage;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Run-time Construction and Destruction Support
	//
	public:
		static Hovercraft*
			Make(
				CreateMessage *message,
				ReplicatorID *base_id
			);

		void
			Respawn(Adept::Entity::CreateMessage *message);
		void
			CommonCreation(CreateMessage *message);

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

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

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// 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
			TurnOn();
		void
			PreCollisionExecute(Stuff::Time till);

	protected:
		void
			UpdateHoverVehiclePosition(const Stuff::Scalar time_slice);

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

	};

}
