#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef ___ASURA_CLIENTENTITY_DEBUGMESSAGETRIGGER_H___
#define ___ASURA_CLIENTENTITY_DEBUGMESSAGETRIGGER_H___ 1

#ifdef ASURA_USE_DEBUG_MESSAGE_TRIGGER

//Server entity
#include "Entity/Triggers/Asura_ServerEntity_DebugWaypointTrigger.h"

//Asura headers
#include "Core/Asura.h"
#include "Entity/Asura_Entity_Renderable.h"
#include "Shapes/Asura_Shapes.h"
#include "Mesh/Asura_Mesh.h"
#if defined(ASURA_USE_NEW_VISIBILITY_SYSTEM)
#include "Visibility/Asura_Visibility_System.h"
#endif	//defined(ASURA_USE_NEW_VISIBILITY_SYSTEM)

// Forward references
class Asura_ServerEntity_DebugWaypointTrigger;
class Asura_Message_DebugWaypoint_ClientUpdate;

class Asura_ClientEntity_DebugWaypointTrigger : public Asura_Entity_Renderable
{
public:

	//______ Functions _______

	Asura_ClientEntity_DebugWaypointTrigger();
	virtual ~Asura_ClientEntity_DebugWaypointTrigger();
	void Update( void );
	void Render( void );

	void SetPositionAndOrientation( const Asura_Vector_3& xPosition, const Asura_Matrix_3x3& xOrientation );	
	void SetSkinAndAnimID(Asura_Hash_ID uShapeID, Asura_Hash_ID uAnimID, int iAnimFlags, float fAnimTimer);
	void SetShapeID(Asura_Hash_ID uShapeID);
	
	bool HandleMessage( const Asura_Message* pxMsg );
	static Asura_ClientEntity_DebugWaypointTrigger* Create( const Asura_Message* pxMsg );
	static void SendRequestCreateMessage(Asura_Guid uFromGuid); 

	static void SetEnableRender(bool bEnable) { s_bRenderDebugWaypointTriggerShapes = bEnable; }
	static bool GetEnableRender(void) { return s_bRenderDebugWaypointTriggerShapes; }

private:

	//______ Functions _______
	
	void ProcessCreateMessage(const Asura_Message_DebugWaypoint_Create* pxData, float fTime);
	void ProcessClientUpdate(const Asura_Message_DebugWaypoint_ClientUpdate* pxData, float fTime);

	//______ Variables _______
	
	Asura_Message_DebugWaypoint_Create m_xServerData;
	Asura_Shape_Instance	m_xShapeInstance;	
	float					m_fTimer;

#if defined(ASURA_USE_NEW_VISIBILITY_SYSTEM)
	Asura_Visibility_Query	m_xVisibilityQuery;
#endif	//defined(ASURA_USE_NEW_VISIBILITY_SYSTEM)

	union
	{
		u_int m_uFlags;
		struct
		{
			u_int	m_bReady				: 1,
					m_bTestsPassedLastFrame	: 1,
											: 0;
		};
	};

	//______ Typedefs ________

	typedef Asura_Entity_Renderable PARENT;

	//______ Static variables ________
	
	static Asura_Hashed_List<Asura_ClientEntity_DebugWaypointTrigger> s_xList;
	static bool	s_bRenderDebugWaypointTriggerShapes;

};

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

#endif //ASURA_USE_DEBUG_MESSAGE_TRIGGER

#endif // #ifndef ___ASURA_CLIENTENTITY_DEBUGMESSAGETRIGGER_H___

