//===========================================================================//
// File:	mover.hh                                                            //
// Project: MUNGA           Brick: Model Manager                             //
// Contents: Interface specification for moving entity class                 //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 01/21/95  JMA  Initial coding.                                            //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc.                     //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#if !defined(DROPZONE_HPP)
#	define DROPZONE_HPP

#	if !defined(ENTITY_HPP)
#		include <entity.hpp>
#	endif

#	if !defined(CSTR_HPP)
#		include <cstr.hpp>
#	endif

	//##########################################################################
	//#####################    Mover::ModelResource    #########################
	//##########################################################################

	class DropZone__MakeMessage:
		public Entity::MakeMessage
	{
   public:
		char dropZoneName[32];
		int dropZoneCount;
	};

	//##########################################################################
	//#################    DropZone::AssignDropZoneMessage    ##################
	//##########################################################################

	class DropZone__AssignDropZoneMessage:
		public Entity::Message
	{
	public:
		EntityID
			requestingEntity;
		Receiver::MessageID
			replyMessageID;
		int
			deathCount;

		DropZone__AssignDropZoneMessage(
			Receiver::MessageID message_ID,
			size_t length,
			const EntityID &reply_to,
			Receiver::MessageID reply_ID,
			int death_count
		):
			Entity::Message(message_ID, length),
			requestingEntity(reply_to),
			replyMessageID(reply_ID),
			deathCount(death_count)
				{}
	};

	//##########################################################################
	//#####################    DropZone::ReplyMessage    ##########################
	//##########################################################################

	class DropZone__ReplyMessage:
		public Entity::Message
	{
	public:
		Origin
			dropZoneLocation;
		int
			deathCount;

		DropZone__ReplyMessage(
			Receiver::MessageID message_ID,
			size_t length,
			const Origin &location,
			int death_count
		):
			Entity::Message(message_ID, length),
			dropZoneLocation(location),
			deathCount(death_count)
				{}
	};

	//##########################################################################
	//###########################    DropZone    ################################
	//##########################################################################

	class DropZone:
		public Entity
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Shared Data support
	//
	public:
		static Derivation ClassDerivations;

		static SharedData DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Message Support
	//
	public:
		enum {
			AssignDropZoneMessageID = Entity::NextMessageID,
			NextMessageID
		};

	private:
		static const HandlerEntry MessageHandlerEntries[];

	protected:
		static MessageHandlerSet MessageHandlers;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Construction and Destruction
	//
	public:
		typedef DropZone__MakeMessage MakeMessage;

		static DropZone*
			Make(MakeMessage *creation_message);

		static Logical
			CreateMakeMessage(
				MakeMessage *creation_message,
				const char* model_name,
				const char* resource_name,
				NotationFile *map_file
			);

		DropZone(
			MakeMessage *creation_message,
			SharedData &virtual_data = DefaultData
		);
		~DropZone();

		Logical
			TestInstance() const;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Dropzone assignment
	//
	public:
		typedef DropZone__AssignDropZoneMessage AssignDropZoneMessage;
		typedef DropZone__ReplyMessage ReplyMessage;

		const char*
			GetDropZoneName()
				{Check(this); return dropZoneName;}

		Logical
			IsAvailable(int index);

	protected:
		int dropZoneCount;
		char dropZoneName[32];
		Origin *dropZones;
		Time *lastUsageTime;
		EntityID *lastUsedBy;
      int *lastDeathCount;

		void
			AssignDropZoneMessageHandler(AssignDropZoneMessage *message);
	};

#endif
