#ifndef _RUFUSION_TREKKER_H_
#define _RUFUSION_TREKKER_H_

// Base types
#include "../Fusion/RuFusion_Trekker_Interface.h"
#include "../Scene/Terrain/RuEntityOptimalTerrain.h"

#pragma unmanaged

// ************************************************************************************************************************************************************

class CRuFusion_Trekker : public IRuFusion_Trekker_Interface
{
	ruRTTI_DECLARE
	ruHEAP_DECLARE
	ruCLASSGUID_DECLARE

protected:
	CRuOptimalTerrain*					m_terrain;
	CRuGaia_Base*						m_gaiaObject;
	IRuPathHierarchy_Base*				m_pathHierarchy;

	// Settings
	REAL								m_defaultNodeSearchRadius;
	REAL								m_defaultLocationSearchRange;
	INT32								m_pathMaximumExpansion;

	// Runtime temporaries
	IRuPathFinder_Base*					m_runTime_PathFinder;
	CRuCollisionQuery_Segment_Nearest	m_runtime_NearestSegQuery;
	CRuCollisionQuery_Segment_HitTest	m_runtime_SegQuery;
	CRuArrayList<INT32>					m_runTime_PathGraphKeys;
	CRuArrayList<INT32>					m_runTime_PathNodeKeys;

public:
										CRuFusion_Trekker(const char *terrainPath);
										CRuFusion_Trekker(CRuOptimalTerrain *terrain);
	virtual								~CRuFusion_Trekker();

	// Collision testing
	virtual BOOL						TestPathValidity(const CRuVector3 &origin, const CRuVector3 &destination);

	// Location query
	virtual BOOL						TestRestingValidity(const CRuVector3 &origin);
	virtual BOOL						TestRestingHeight(const CRuVector3 &origin, REAL testDistance, REAL &restingHeightOut);

	// Path finding
	virtual BOOL						SetPathMaximumExpansion(INT32 pathMaximumExpansion);
	virtual BOOL						FindNearestNodeKey(const CRuVector3 &position, REAL radius, INT32 &nodeKeyOut);
	virtual BOOL						FindPath(INT32 originNodeKey, INT32 destinationNodeKey, CRuArrayList<CRuVector3> *pathPositionOut, CRuArrayList<INT32> *pathNodeKeysOut);
	virtual BOOL						FindPath(const CRuVector3 &origin, const CRuVector3 &destination, CRuArrayList<CRuVector3> *pathPositionOut, CRuArrayList<INT32> *pathNodeKeysOut);
};

// ************************************************************************************************************************************************************

#pragma managed

#endif
