//////////////////////////////////////////////////////////////////////////////
//
// AVP_RoomNode_AStar.h
//
// Created by AJK on 16-01-2009 from NJD Axon_Gamescene_AStar
//
// Copyright (C) 2009 Rebellion, All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __AVP_ROOMNODE_ASTAR__
#define __AVP_ROOMNODE_ASTAR__

// Asura
#include "Core/Asura_HashedList.h"
#include "Core/Asura_LinkList.h"
#include "Core/Asura_Mempool.h"

class AVP_ServerEntity_Actor;
class AVP_ServerEntity_RoomNode;

class AVP_RoomNode_AStar
{
public:
	static void GetRouteTo( const Asura_Guid uDestNodeGuid, const Asura_Guid uCurrNodeGuid, const AVP_ServerEntity_Actor& xActor, Asura_LinkList< Asura_Guid >& xRoute );

private:
	struct AStarNode
	{
		const AVP_ServerEntity_RoomNode*  m_pxNode;
		float                             m_fCostToHere;
		float                             m_fCostToGoal;
		float                             m_fTotalCost;
		bool                              m_bOpen;
		bool                              m_bClosed;
		AStarNode*						  m_pxParent;
		const AVP_ServerEntity_RoomNode*  m_pxNodeToHere;

		Asura_Guid GetGuid() const;
		bool IsDestroyed() const { return false; }
	};

	static AStarNode* GetAStarNode( const Asura_Guid uNodeGuid );
	static int CompareAStarNodes( AStarNode* const & pxAStarNodeOne, AStarNode* const & pxAStarNodeTwo );
	static void InsertNodeInOpenList( AStarNode* pxAStarNode );
	static AStarNode* GetOpenListHead();

	static float EstCostToGoal     ( const AVP_ServerEntity_RoomNode* pxCurrNode, const AVP_ServerEntity_RoomNode* pxDestNode );
	static float EstCostOfTraversal( const AVP_ServerEntity_RoomNode* pxLink );

private:
	static Asura_LinkList< AStarNode* > s_xOpenList;
	static Asura_Hashed_List< AStarNode > s_xAStarNodeList;
	static Asura_ResizingMempool s_xAStarNodeMempool;
};

#endif //__AVP_ROOMNODE_ASTAR__
