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

#pragma once

#include <glmBox2.h>
#include "glmNavigationData.h"

namespace glm
{
	class PathContext;

	/** 
	* \brief Path component for a simulated entity.
	*
	* \ingroup Navigation
	*
	* \author Golaem <dev@golaem.com>
	*/
	class GLM_SDK_API PathGroupComponent
	{
		friend class PathContext;
		template<class TValue> friend class Array;

	public:
        GLM_CLASS_STAT_ID(glm::MemoryStatIds::Simulation);

        PathGroupComponent(float laxness = 0.f);
        virtual ~PathGroupComponent();

        //Group& getGroup() const;
		//Entity& getEntity(SimuEntityHandle) const;

		const Vector3& getMinPos() const { return _minPos; }
		const Vector3& getMaxPos() const { return _maxPos; }

		///**
		//* \brief Retrieve the bounding box of the group.
		//* This bounding box is computed during the components update. It is the bounding box of the member's slots or positions if they have no slots.
		//* It takes into account the radii of the members.
		//*/
		//const Box2& getBoundingBox() const;
		
		float _groupLaxness; /// groupLaxness = 0 : group formation / cohesion is strict. groupLaxness = 1 : group completely accept to be deformed
		NavigationData _navigationData;

	protected:

		/**
		* \name Component method definitions.
		*/
		//@{
		void doInit(PathContext& pathContext, Group& group);
		void doUpdate(PathContext& pathContext, Group& group, Time dt);
		void doFinish();
        //@}

    private:
        //GLM_DISALLOW_COPY_AND_ASSIGN(PathGroupComponent);
		void doPositionLocationOrientationInit(PathContext& pathContext, Group& group);
		void doPositionLocationOrientationUpdate(PathContext& pathContext, Group& group, Time dt);
        bool refreshGroupAttributes(PathContext& pathContext, Group& group, bool updatePosition);

        Vector3 _minPos;
        Vector3 _maxPos;


		unsigned int _leaderGroupMember;
    };
}
