//===========================================================================//
// File:	Driver.hpp																	     //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
//	03/08/99  DPB	Created File                  //
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Fasa Interactive										 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#pragma once

#include "Adept.hpp"
#include "Entity.hpp"
#include "EntityClassData.hpp"
#include "NameTable.hpp"

namespace Adept
{
	class Driver__ReceiveDropZoneMessage;
	class Driver__PollForZoneMessage;

	
	//##########################################################################
	//##################    Driver::CreateMessage    ###########################
	//##########################################################################

	class Driver__CreateMessage:
		public Entity__CreateMessage
	{
	public:
		ObjectID
			dropZone;

		Driver__CreateMessage(
			size_t length,
			int priority,
			int message_flags,
			Stuff::RegisteredClass::ClassID class_id,
			int replicator_flags,
			const ResourceID& data_list_id,
			const Stuff::LinearMatrix4D &creation_matrix,
			Stuff::Scalar age,
			int execution_state,
			int name_id,
			int entity_alignment,
			ObjectID drop_zone
		):
			Entity__CreateMessage(
				length, 
				priority, 
				message_flags, 
				class_id,
				replicator_flags,
				data_list_id,
				creation_matrix,
				age,
				execution_state,
				name_id,
				entity_alignment
			),
				dropZone(drop_zone)
				{}

		static void
			ConstructCreateMessage(Script *script);
	};

	//##########################################################################
	//###########################   Driver    ##################################
	//##########################################################################

	class Driver:
		public Entity
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		typedef Entity BaseClass;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Inheritance Support
	//
		typedef Driver__CreateMessage				CreateMessage;
		typedef Driver__ReceiveDropZoneMessage		ReceiveDropZoneMessage;
		typedef Driver__PollForZoneMessage			PollForZoneMessage;

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

		Replicator::CreateMessage*
			SaveMakeMessage(Stuff::MemoryStream *stream, ResourceFile *res_file);

		void
			Respawn(Entity::CreateMessage *message);

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

		~Driver();

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

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Simulation Support
	//

	public:

	
		bool
			isDropped;
		ObjectID
			dropZone;

		Entity
			*vehicle;
		ResourceID
			vehicleResourceID;

		void
			PostCollisionExecute(Stuff::Time till);

		void ReceiveDropZone(const Stuff::LinearMatrix4D& drop_location);


		virtual Stuff::LinearMatrix4D
			GetEyePoint();

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



}


