//===========================================================================//
// File:	cultural.hh                                                         //
// Project: MUNGA           Brick: Model Manager                             //
// Contents: Interface specification for Cultural Icon Class                 //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 12/11/95  JM   Initial coding.                                            //
// 01/10/96  JM	Added Landmark Terrain												  //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc.                     //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#if 	!defined (CULTURAL_HPP)
#	define CULTURAL_HPP

#if 	!defined(TERRAIN_HPP)
#     include<terrain.hpp>
#endif

#if 	!defined(MEMSTRM_HPP)
#     include<memstrm.hpp>
#endif

#if 	!defined(RESOURCE_HPP)
#     include<resource.hpp>
#endif

#if 	!defined(NOTATION_HPP)
#     include<notation.hpp>
#endif

#if 	!defined(TEAM_HPP)
#     include<team.hpp>
#endif

	class ScenarioRole;



	//##########################################################################
	//##################  CulturalIcon::ModelResource    #######################
	//##########################################################################

	struct CulturalIcon__ModelResource
	{
		Scalar
			destroyedYTranslation;

		Scalar
			timeDelay;

		ResourceDescription::ResourceID
			explosionResourceID;

		ResourceDescription::ResourceID
			crunchExplosionResourceID;

		Logical
			sinkCollisionVolume, stoppingCollisionVolume;
	};

	//##########################################################################
	//#####################    Class CulturalIcon     ##########################
	//##########################################################################

	class CulturalIcon :
		public UnscalableTerrain
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Shared Data support
	//
	public:

		static Derivation ClassDerivations;

		static SharedData DefaultData;


	private:
		static const HandlerEntry MessageHandlerEntries[];

	protected:
		static MessageHandlerSet MessageHandlers;

	public:
		enum {
			SetBurningStateMessageID = UnscalableTerrain::NextMessageID,
			NextMessageID
		};

		void
			TakeDamageMessageHandler(TakeDamageMessage *damage_message);
		void
			SetBurningStateMessageHandler(Message *burning_message);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Collision Volume Support
	//
	protected:

		void
			UpdateCollisionVolumes();

		enum {
			RemoveCollisionVolumeOnDeathBit = UnscalableTerrain::NextBit,
			StoppingCollisionVolumeBit,
			NextBit
		};

		enum {
			RemoveCollisionVolumeOnDeathFlag = 1 << RemoveCollisionVolumeOnDeathBit,
			StoppingCollisionVolumeFlag = 1 << StoppingCollisionVolumeBit
		};

		void
			SetRemoveCollisionVolumeFlag()
		{Check(this); simulationFlags |= RemoveCollisionVolumeOnDeathFlag;}

		Logical
			RemoveCollisionVolumeOnDeath() const
		{Check(this); return (simulationFlags&RemoveCollisionVolumeOnDeathFlag);}

		void
			SetStoppingCollisionVolumeFlag()
		{Check(this); simulationFlags |= StoppingCollisionVolumeFlag; }

		ResourceDescription::ResourceID
			explosionResourceID;

		ResourceDescription::ResourceID
			crunchExplosionResourceID;


		Scalar
			destroyedYTranslation;

      Scalar
			timeDelay;


	public:

		Logical
			IsStoppingCollisionVolume() const
		{Check(this); return (simulationFlags&StoppingCollisionVolumeFlag);}



	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Attribute Support
	//
	public:

		enum {
			TeamNameAttributeID = UnscalableTerrain::NextAttributeID,
			NextAttributeID
		};

      enum {
			BurningState = UnscalableTerrain::StateCount,
         WaitingToBurn,
			StateCount
		};

		char
			teamName[64];

	private:
		static const IndexEntry AttributePointers[];

	protected:
		static AttributeIndexSet	AttributeIndex;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Construction and Destruction
	//
	public:

		typedef CulturalIcon__ModelResource	ModelResource;

		CulturalIcon(
			MakeMessage *creation_message,
			SharedData &shared_data = DefaultData
		);
		~CulturalIcon();

      void
			ReadUpdateRecord(Simulation::UpdateRecord *message);

		Logical
			TestInstance() const;

		static Logical
			CreateMakeMessage (
				MakeMessage *creation_message,
				NotationFile 					*model_file,
				const ResourceDirectories	*directories
			);

		static CulturalIcon*
			Make(MakeMessage *creation_message);

		static int
			CreateModelResource (
				ResourceFile *resource_file,
				const char *model_name,
				NotationFile *model_file,
				const ResourceDirectories *directories,
				ModelResource* model = NULL
			);

		static int
			CreateDamageZoneStream (
				ResourceFile *resource_file,
				const char *model_name,
				NotationFile *model_file,
				const ResourceDirectories *directories
			);
	};
	//##########################################################################
	//##################  Landmark::MakeMessage    #############################
	//##########################################################################
	class Landmark__MakeMessage :
		public CulturalIcon::MakeMessage
	{
		public:

		int
			landmarkID;

		char
			roleName[64];
		char
			landmarkName[64];
		char
			teamName[64];

		Landmark__MakeMessage();
		Landmark__MakeMessage(
			Receiver::MessageID message_ID,
			size_t length,
			const EntityID &entity_ID,
			Entity::ClassID class_ID,
			ResourceDescription::ResourceID resource_ID,
			LWord instance_flags,
			const Origin &origin,
			char	*team_name,
			int	landmark_ID,
			CString role_name

		) :
			CulturalIcon::MakeMessage(
				message_ID,
				length,
				entity_ID,
				class_ID,
				EntityID::Null,
				resource_ID,
				instance_flags,
				origin
			),
			landmarkID(landmark_ID)
				{
					Str_Copy(teamName, team_name, sizeof(teamName));
					Str_Copy(roleName, (const char*)role_name, sizeof(roleName));
				}
	};

	//##########################################################################
	//##################  Landmark::ModelResource    #######################
	//##########################################################################

	struct Landmark__ModelResource :
		public CulturalIcon::ModelResource
	{
#if 0
		ResourceDescription::ResourceID
			roleResourceID;
#endif
	};
	//##########################################################################
	//#####################    Class Landmark         ##########################
	//##########################################################################

	class Landmark :
		public CulturalIcon
	{
		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// Shared Data support
		//
		public:

			static Derivation ClassDerivations;

			static SharedData DefaultData;

		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// Message Support
		//
		private:
			static const HandlerEntry MessageHandlerEntries[];

		protected:
			static MessageHandlerSet MessageHandlers;

		public:

			void
				TakeDamageMessageHandler(TakeDamageMessage *damage_message);

		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// Local Data support
		//
		protected:

			ScenarioRole
				*scenarioRole;

			int
				landmarkID;

			 Team
				*owningTeam;

			 char
				teamName[64];

		public:

			const ScenarioRole*
				GetScenarioRole() const
			{Check(this); return scenarioRole; }

			void
				SetScenarioRole(ScenarioRole *scenario_role)
			{ Check(this); scenarioRole = scenario_role; }

			int
				GetLandmarkID() const
			{Check(this); return landmarkID; }

			Team*
				GetOwningTeam()
			{Check(this); return owningTeam; }

		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// Constructor / Destructor support
		//
		public:

			typedef Landmark__MakeMessage MakeMessage;
			typedef Landmark__ModelResource ModelResource;

			Landmark(
				MakeMessage	*creation_message,
				SharedData &shared_data = DefaultData
			);

			~Landmark();

			Logical
				TestInstance() const;

			static Logical
				CreateMakeMessage (
					MakeMessage *creation_message,
					NotationFile 					*model_file,
					const ResourceDirectories	*directories
				);

			static Landmark*
				Make(MakeMessage *creation_message);

			static int
				CreateModelResource (
					ResourceFile *resource_file,
					const char *model_name,
					NotationFile *model_file,
					const ResourceDirectories *directories,
					ModelResource* model = NULL
				);


	};
#endif
