//--------------------------------------------------------------------------------------
//	File	:	AVP_Behaviour_FaceHugger_SearchForPrey.h
//	Created	:	29 / 06 / 07
//	Author	:	Gaz Thomas
//	Copyright (C) 2006 Rebellion, All Rights Reserved.
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// BEGIN FILE WRAPPER
//--------------------------------------------------------------------------------------
#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif
#ifndef __AVP_BEHAVIOUR_FACEHUGGER_SEARCHFORPREY_H__
#define __AVP_BEHAVIOUR_FACEHUGGER_SEARCHFORPREY_H__ 1
//--------------------------------------------------------------------------------------
// END FILE WRAPPER
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
//	INCLUDES
//--------------------------------------------------------------------------------------
//	Asura
#include "Core/Asura_Maths.h"
//	Axon
#include "Behaviour/BehaviourTypes/AVP_Behaviour_Shared_RouteHelper.h"

//--------------------------------------------------------------------------------------
//	FORWARD DECLARATIONS
//--------------------------------------------------------------------------------------
class AVP_Behaviour_FaceHugger;
class Axon_Project_Brain;

//--------------------------------------------------------------------------------------
//	Class	:	AVP_Behaviour_FaceHugger_SearchForPrey
//	Created	:	29 / 06 / 07
//	Author	:	Gaz Thomas
//--------------------------------------------------------------------------------------
class AVP_Behaviour_FaceHugger_SearchForPrey : public AVP_Behaviour_Shared_RouteHelper
{	
	typedef AVP_Behaviour_Shared_RouteHelper PARENT;

public:

	AVP_Behaviour_FaceHugger_SearchForPrey( Axon_Project_Brain* pxBrain );
	virtual ~AVP_Behaviour_FaceHugger_SearchForPrey();  

	enum UpdateState
	{
		US_UNSET,
		US_SEARCH,
		US_FIND_SEEK_POINT,
		US_SEEK,
		US_FACE_NEW_DIRECTTION,
		NUM_UPDATE_STATES
	};

protected:

	// Overridden functions
	virtual bool		Activate();
	virtual void		Deactivate();
	virtual void		PerFrameUpdate	(const float fTimeslice);	

	//	State Update Functions
	void	Search_PerFrameUpdate						(const float fTimeslice);
	void	Seek_PerFrameUpdate							(const float fTimeslice);
	void	FindSeekPoint_PerFrameUpdate				(const float fTimeslice);
	void	ChooseNewFacingDirection_PerFrameUpdate		(const float fTimeslice);

	bool	FindSeekPosition();

	void	SetUpdateState(UpdateState uNextState)		{m_uUpdateState = uNextState;}

#ifndef ASURA_NO_DEBUG_OUTPUT
	virtual void RenderDebugInfo();
#endif

private:

	//	Behaviour Common Variables
	UpdateState			m_uUpdateState;						//	Search For Prey Behaviour Update State
	Asura_Vector_3		m_xSeekMoveToPos;					//	Position to move to while seeking
	bool				m_bShouldWalk;						//	Flag to store if the face hugger should walk or run when moving in this behaviour
	//	Choose New Facing Direction Variables
	Asura_Vector_3		m_xPositionToFace;					//	A position that we use to change the facing direction of the Face Hugger
	bool				m_bNewFacingDirectionCalculated;	//	A flag to tell us that we have chosen a new facing direction
	//	Seek Variables
	float				m_fFaceNewDirTimer;					//	Timer value to see how long we have been Trying to face a new directiob for
	float				m_fFaceNewDirTimeoutTime;			//	Timeout Value to tell us when to stop Facing a new direction
	//	Search Variables
	float				m_fSearchTimer;						//	Timer value to see how long we have been Searching for;
	float				m_fSearchTimeoutTime;				//	Timeout Value to tell us when to stop searching and go Seek instead
	//	Seek Variables
	float				m_fSeekTimer;						//	Timer value to see how long we have been Seeking for
	float				m_fSeekTimeoutTime;					//	Timeout Value to tell us when to stop seeking and to stop and Search instead
};
#endif //__AVP_BEHAVIOUR_FACEHUGGER_SEARCHFORPREY_H__
