/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A.  All Rights Reserved.                         *
*                                                                          *
***************************************************************************/

#pragma once

#include "glmSDKAPI.h"
#include "glmSpatialEnvironment.h"
#include "glmNavigationMeshLocation.h"

namespace glm
{
	class PathContext;
	class NavigationData;
	class SpatialEnvironment;

	//-------------------------------------------------------------------------
	// PathEntityComponentLocation : Spatial Location used for PathEntity (uses PathEntityComponent data)
	//-------------------------------------------------------------------------
	class GLM_SDK_API PathEntityComponentLocation //: public ISpatialEnvironmentLocation
	{
	public:

		GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation)

		SimuEntityHandle	_entityHandle;
		SpatialEnvironment*	_spatialEnvironment;
        NavigationMeshLocation _location;
        glm::PODArray<IDDistancePairPOD> _coveredCells;

    public:
        PathEntityComponentLocation();

        virtual ~PathEntityComponentLocation();

        inline bool isValid() const;
        inline Vector3 getNavigationPositionWorld() const;
        inline const Vector3& getNavigationPositionLocal() const;
        inline const NavigationMeshCellId& getCellId() const;
        /**
         * \brief Updates the cells covered by the entity
         */
        void updateCoveredCells(float radius);
    };

    //-----------------------------------------------------------------------------
    inline bool PathEntityComponentLocation::isValid() const
    {
        return _location.isValid();
    }

    //-----------------------------------------------------------------------------
    inline Vector3 PathEntityComponentLocation::getNavigationPositionWorld() const
    {
        return _location.getNavigationPositionWorld(*(_spatialEnvironment->_navigationMesh));
    }

    //-----------------------------------------------------------------------------
    inline const Vector3& PathEntityComponentLocation::getNavigationPositionLocal() const
    {
		return _location.getNavigationPositionLocal();
	}
	
	//-----------------------------------------------------------------------------
	inline const NavigationMeshCellId& PathEntityComponentLocation::getCellId() const
	{
		return _location.getCellId();
	}

}
