//////////////////////////////////////////////////////////////////////////////
//
// AVP_ServerNode_OrientedNode.h
//
// (Stuart Perry - 18.04.2007) 
//
// Copyright (c) 2007 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 AVP_SERVERNODE_ORIENTEDNODE_H___
#define AVP_SERVERNODE_ORIENTEDNODE_H___ 1

// I N C L U D E S ///////////////////////////////////////////////////////////
#include "Entity/Locations/OrientedNode/Asura_ServerNode_OrientedNode.h"

class Tools_EntityTemplateInstance;

//////////////////////////////////////////////////////////////////////////////
//
// AVP_ServerNode_OrientedNode
//
//////////////////////////////////////////////////////////////////////////////
class AVP_ServerNode_OrientedNode : public Asura_ServerNode_OrientedNode
{
private:
	typedef Asura_ServerNode_OrientedNode PARENT;
	
	friend class ToolsAVP_Node_OrientedNode;

public:

	enum NodeType
	{
		GUARD_NODE = 0,
		MARINE_FORMATION_NODE,
		MARINE_LOOKAT_NODE,
		MAX_NODE_TYPES
	};

	// Constructor / Destructor
	AVP_ServerNode_OrientedNode( Asura_Guid uGuid );
	virtual ~AVP_ServerNode_OrientedNode();

	// Statics
	static void CreateFromChunkStream ( Asura_Guid uGUID, Asura_Chunk_Stream& xStream );
	virtual void InitialiseFromChunkStream ( Asura_Chunk_Stream& xStream );
	virtual void						WriteToChunkStream			( Asura_Chunk_Stream& xStream ) const;
	virtual void						ReadFromChunkStream			( Asura_Chunk_Stream& xStream );
	static AVP_ServerNode_OrientedNode*	Create						(const Asura_Guid uGuid);
	static AVP_ServerNode_OrientedNode* FindEntity					(Asura_Guid uGuid) { return s_xList.FindEntity(uGuid); }
	static const Asura_Hashed_List<AVP_ServerNode_OrientedNode>* GetList() { return &s_xList; }

#ifdef ASURA_TOOLS
	virtual bool IsBaseOrDerivativeOf( u_short usClassification ) const;
	virtual bool CanBeIncludedInTemplate() const;
#endif

	// Accessors
	u_int		GetPatrolOrder			(void) const		{ return m_uPatrolOrder; }
	u_int		GetRandomWeighting		(void) const		{ return m_uRandomWeighting; }
	float		GetWaitTime				(void) const		{ return m_fWaitTime; }
	bool		GetRandomOffsetBool		(void) const		{ return m_bWaitTimeRandomOffset; }
	float		GetWaitTimeRandomOffset (void) const		{ return m_fWaitTimeRandomOffset; }

	void		SetPatrolOrder			(u_int uIndex)		{ m_uPatrolOrder = uIndex; }

	u_int		GetNodeType				(void)				{ return m_eNodeType; }
	void		SetNodeType				(u_int eNodeType)	{ m_eNodeType = eNodeType; }

protected:

private:
	static const u_int uCURRENT_CHUNK_VERSION = 2;

	// Statics
	static Asura_Hashed_List<AVP_ServerNode_OrientedNode> s_xList;

	// Private Variables
	u_int			m_uRandomWeighting;
	u_int			m_uPatrolOrder;
	float			m_fWaitTime;
	float			m_fWaitTimeRandomOffset;
	u_int			m_eNodeType;
	union
	{
		u_int		m_uFlags;
		struct
		{
			u_int	m_bWaitTimeRandomOffset : 1;
		};
	};
};

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

#endif // #ifndef AVP_SERVERNODE_ORIENTEDNODE_H___
