//////////////////////////////////////////////////////////////////////////////
//
// AVP_RoomNode_ExitLink.h
//
// Created by AJK 02/02/2009
//
// Copyright (c) 2009 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef AVP_ROOMNODE_EXITLINK
#define AVP_ROOMNODE_EXITLINK

#include "Core/Asura_Maths.h"
#include "Network/Asura_Guid.h"

class AVP_RoomNode_ExitLink
{
public:

#ifdef ASURA_TOOLS
	AVP_RoomNode_ExitLink();
#endif
 
	AVP_RoomNode_ExitLink(    u_int uMyID
							, u_int uLinkedExitLinkID
							, Asura_Guid uRoom
							, const Asura_Vector_3& xPosition
							, u_int uFlags );

	AVP_RoomNode_ExitLink(    u_int uMyID
							, const Asura_Vector_3& xPosition
							, Asura_Guid uRoom1
							, Asura_Guid uRoom2
							, u_int uFlags );

	bool IsUsedByPredator() const { return IsFlagged(FLAG_USEBY_PREDATOR); }
	bool IsUsedByAlien()    const { return IsFlagged(FLAG_USEBY_ALIEN);    }
	bool IsUsedByMarine()   const { return IsFlagged(FLAG_USEBY_MARINE);   }

	void SetUseByPredator  (bool bTrue) { bTrue ? AddFlag(FLAG_USEBY_PREDATOR ) : RemoveFlag(FLAG_USEBY_PREDATOR ); }
	void SetUseByAlien     (bool bTrue) { bTrue ? AddFlag(FLAG_USEBY_ALIEN    ) : RemoveFlag(FLAG_USEBY_ALIEN    ); }
	void SetUseByMarine    (bool bTrue) { bTrue ? AddFlag(FLAG_USEBY_MARINE   ) : RemoveFlag(FLAG_USEBY_MARINE   ); }

	Asura_Guid GetLinkedRoomGuid()  const { return m_uLinkedRoomGuid; }
	Asura_Guid GetLinkedRoom2Guid() const { return m_uLinkedRoom2Guid; }

	void SetLinkedRoomGuid( Asura_Guid uGuid) { m_uLinkedRoomGuid = uGuid; }
	void SetLinkedRoom2Guid( Asura_Guid uGuid) { m_uLinkedRoom2Guid = uGuid; }

	const Asura_Vector_3& GetPosition() const { return m_xPosition; }
	      Asura_Vector_3& GetPosition() { return m_xPosition; }
	void                  SetPosition( Asura_Vector_3& xPos) { m_xPosition = xPos; }
	void                  SetFlags   ( u_int uFlags ) { m_uFlags = uFlags; }
	u_int                 GetFlags() const { return m_uFlags; }
	u_int                 GetMyID() const { return m_uMyID; }
	void                  SetMyID ( u_int uID ) { m_uMyID = uID; }
	u_int                 GetLinkedExitLinkID() const { return m_uLinkedExitLinkID; }
	void                  SetLinkedExitLinkID ( u_int uID ) { m_uLinkedExitLinkID = uID; }
	bool                  IsConverted() const { return m_bConverted; }
	void                  SetConverted ( bool bConverted ) { m_bConverted = bConverted; }
private:
	enum 
	{ 
		FLAG_USEBY_PREDATOR =  0x00000001,
		FLAG_USEBY_ALIEN    =  0x00000002,
		FLAG_USEBY_MARINE   =  0x00000004
	};

	void AddFlag    (u_int uFlag) { m_uFlags |= uFlag;                      }
	void RemoveFlag (u_int uFlag) { m_uFlags &= ~uFlag;						}
	bool IsFlagged  (u_int uFlag) const { return ((m_uFlags & uFlag) != 0); }

	u_int          m_uMyID;
	u_int          m_uLinkedExitLinkID;
	Asura_Guid     m_uLinkedRoomGuid;
	Asura_Guid     m_uLinkedRoom2Guid;
	Asura_Vector_3 m_xPosition;
	u_int          m_uFlags;
	bool           m_bConverted;

#ifdef ASURA_TOOLS
	friend class ToolsAVP_Object_ExitLink;
#endif

};

#endif // #ifndef AVP_ROOMNODE_EXITLINK