#ifdef ASURA_USE_AXON
//////////////////////////////////////////////////////////////////////////////
//
// Asura_ServerNode_GS2Attractor.h
//
// Copyright (C) 2008 Rebellion. All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __ASURA_SERVERNODE_GS2ATTRACTOR_H__
#define __ASURA_SERVERNODE_GS2ATTRACTOR_H__ 1

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

// I N C L U D E S ///////////////////////////////////////////////////////////

// asura
#include "Entity/Locations/OrientedNode/GamesceneNode/Asura_ServerNode_GS2Node.h"

// F O R W A R D   D E C L A R A T I O N S ///////////////////////////////////

class Asura_ServerEntity_PhysicalObject;

//////////////////////////////////////////////////////////////////////////////
//
// Axon_GS2_AttractorAttractType
//
//////////////////////////////////////////////////////////////////////////////

enum Axon_GS2_AttractorAttractType
{
	AXON_GS2_AAT_ANYTHING = 0,
	AXON_GS2_AAT_SPECIFIC_GUID = 1,

	AXON_GS2_AAT_FIRST_PROJECT_SPECIFIC = 1000
};

//////////////////////////////////////////////////////////////////////////////
//
// Asura_ServerNode_GS2Attractor
//
//////////////////////////////////////////////////////////////////////////////

class Asura_ServerNode_GS2Attractor : public virtual Asura_ServerNode_GS2Node
{
	friend class Tools_EntityNode_GS2Attractor;
	typedef Asura_ServerNode_GS2Node PARENT;

public:
	Asura_ServerNode_GS2Attractor( Asura_Guid uGuid );
	virtual ~Asura_ServerNode_GS2Attractor();

	virtual void OnEntityActivateMessage();
	virtual void OnEntityDeactivateMessage();
	virtual void Update();
	virtual bool HandleMessage( const Asura_Message* pxMessage );
	virtual void ReadFromChunkStream( Asura_Chunk_Stream& xStream );
	virtual void WriteToChunkStream( Asura_Chunk_Stream& xStream ) const;
	virtual bool IsBaseOrDerivativeOf( u_short usClassification ) const;

	int					  GetEnRouteBehaviourSet()    const { return m_iEnRouteBehaviourSet; }
	Axon_BehaviourParams* GetEnRouteBehaviourParams() const { return m_pxEnRouteBehaviourParams; }

	float	   GetAttractRange() const { return m_fAttractRange; }
	int		   GetAttractType() const { return m_iAttractType; }
	Asura_Guid GetSpecificGuid() const { return m_uSpecificGuid; }
	void	   SetAttractedGuid( const Asura_Guid uAttractedGuid ) { m_uAttractedGuid = uAttractedGuid; }
	Asura_Guid GetAttractedGuid() const { return m_uAttractedGuid; }
	bool       IsAttractingSomething() const { return ( m_uAttractedGuid != ASURA_GUID_UNREGISTERED ); }
	void	   StopAttractingMe( const Asura_Guid uAttractedGuid );

	static void Create( const Asura_Guid uGuid, Asura_Chunk_Stream& xStream );
	static Asura_Hashed_List< Asura_ServerNode_GS2Attractor >* GetList() { return &s_xList; }
	static Asura_ServerNode_GS2Attractor* FindEntity( const Asura_Guid uGuid ) { return s_xList.FindEntity( uGuid ); }

#ifdef ASURA_TOOLS
	void SetEnRouteBehaviourSet( int iBehaviourSet );
	virtual bool UpdateBehaviourTree();

	virtual void ApplyChangesForTemplateInstance( Tools_EntityTemplateInstance* pxInstance );
	virtual bool CanBeIncludedInTemplate() const;

	void SetAttractRange( float fRange ) { m_fAttractRange = fRange; }
	void SetAttractType( int iType );
	void SetSpecificGuid( Asura_Guid uSpecificGuid ) { m_uSpecificGuid = uSpecificGuid; }
#endif

protected:
	virtual void SendAttractionPulse();
	virtual void CancelAttraction();
	virtual void SendAttractionPulseToEntity( const Asura_ServerEntity_PhysicalObject* const pxPhysicalObject ) const;

protected:
	u_int m_uGuidMask;

private:
	float				  m_fPulseTimer;
	// Range within which to attract entities, if any.
	float				  m_fAttractRange;
	int					  m_iAttractType;
	// Specific guid to attract, if any.
	Asura_Guid			  m_uSpecificGuid;
	// Guid that has responded to our attraction pulse.
	Asura_Guid			  m_uAttractedGuid;
#if defined ASURA_TOOLS && defined ASURA_USE_GAMESCENE
public:
#endif
	int	                  m_iEnRouteBehaviourSet;
	Axon_BehaviourParams* m_pxEnRouteBehaviourParams;

private:
	static const u_int uCURRENT_CHUNK_VERSION = 1;
	static Asura_Hashed_List< Asura_ServerNode_GS2Attractor > s_xList;
};

//////////////////////////////////////////////////////////////////////////////
//
// 
//
//////////////////////////////////////////////////////////////////////////////

#endif //__ASURA_SERVERNODE_GS2ATTRACTOR_H__
#endif // ASURA_USE_AXON
