//===========================================================================//
// File:    director.hh                                                      //
// Project: Munga                                                     		  //
// Contents: Chooses from a Selection of Camerea's and provides information  //
//	to any number of cameraship's as to which player to follow					  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 08/09/95  JM  Initial coding.                                             //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc.                     //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#if !defined(DIRECTOR_HPP)
#	define DIRECTOR_HPP

#	if !defined(STYLE_HPP)
#		include <style.hpp>
#	endif

#	if !defined(PLAYER_HPP)
#		include <player.hpp>
#	endif

#	if !defined(SCHAIN_HPP)
#		include <schain.hpp>
#	endif

#	if !defined(CAMSHIP_HPP)
#		include <camship.hpp>
#	endif

#	if !defined(GRAPH2D_HPP)
#		include <graph2d.hpp>
#	endif

#	if !defined(SLOT_HPP)
#		include <slot.hpp>
#	endif

	//##########################################################################
	//#################    CameraDirector::AttachCameraShip    #################
	//##########################################################################

	class CameraDirector__AttachCameraShipMessage:
		public Player::Message
	{
		public:

		EntityID
			cameraShipID;

		CameraDirector__AttachCameraShipMessage(
			Receiver::MessageID message_ID,
			size_t length,
			EntityID camera_ship_ID
		):
			Entity::Message(message_ID, length),
			cameraShipID(camera_ship_ID)
				{}
	};

	//##########################################################################
	//############################# CameraDirector #############################
	//##########################################################################

	class CameraDirector:
		public Player
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Shared Data support
	//
	public:

		static Derivation ClassDerivations;
		static SharedData DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Messaging support
	//
	public:
		friend class CameraDirector__AttachCameraShipMessage;

		enum{
			AttachCameraShipMessageID = Entity::NextMessageID,
			NextMessageID
		};

		typedef CameraDirector__AttachCameraShipMessage AttachCameraShipMessage;

		void
			AttachCameraShipMessageHandler(AttachCameraShipMessage *message);

	protected:
		static const HandlerEntry
			MessageHandlerEntries[];
		static MessageHandlerSet
			MessageHandlers;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Simulation Support
	//
	public:
		typedef void
			(CameraDirector::*Performance)(Scalar time_slice);

		void
			SetPerformance(Performance performance)
				{
					Check(this);
					activePerformance = (Simulation::Performance)performance;
				}

		void
			CreateCameraShip(Scalar time_slice);
		void
			BeADirector(Scalar time_slice);
		void
			UpdateHUD(Scalar time_slice);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Construction and Destruction Support
	//
	public:
		CameraDirector(
			MakeMessage	*creation_message,
			SharedData &virtual_data = DefaultData
		);

		static CameraDirector*
			CameraDirector::Make(CameraDirector::MakeMessage *creation_message);

		~CameraDirector();

		Logical
			TestInstance() const;

		enum {
			DefaultFlags = Entity::DefaultFlags | PreRunFlag | CameraShipPlayerFlag
		};

		static Player*
			FindPlayerByRank(int rank_to_find);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Simulation Support Data & Functions
	//
	protected:

		SlotOf<Entity*>
			goalEntity;

		void
			SetGoalEntity(Entity *goal_entity)
				{
					Check(this);
					goalEntity.Remove();
					Check(goal_entity);
					goalEntity.Add(goal_entity);
				}

		Entity*
			GetGoalEntity()
				{Check(this); return goalEntity.GetCurrent(); }

		Scalar
			timeLeftOnPlayer;

		CameraShip
			*cameraShip;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// HUD Support
	//
	public:

		int
			goalPlayerIndex;

		Logical
			displayRankingWindow;

		Scalar
			timeDisplayed,
			timeTillDisplayed,
			displayIntervalOn,
			displayIntervalOff;
	};

#endif
