//////////////////////////////////////////////////////////////////////////////
//
// AVP_Behaviour_GS2Node_Marine_Combat.h
//
// Copyright (C) 2008 Rebellion. All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif
#ifndef __AVP_BEHAVIOUR_GS2NODE_MARINE_COMBAT_H__
#define __AVP_BEHAVIOUR_GS2NODE_MARINE_COMBAT_H__ 1

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

// axon
#include "Behaviour/BehaviourTypes/Axon_Behaviour_GS2Interface.h"
#include "Behaviour/Axon_BehaviourParams.h"

// Avp Axon
#include "Core/BrainTypes/AVP_Brain_Actor_Marine.h"

// F O R W A R D   D E C L A R A T I O N S ///////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//
// AVP_Behaviour_GS2Node_Marine_Combat
//
//////////////////////////////////////////////////////////////////////////////

class AVP_Behaviour_GS2Node_Marine_Combat : public Axon_Behaviour_GS2Interface
{
	typedef Axon_Behaviour_GS2Interface PARENT;

public:
	AVP_Behaviour_GS2Node_Marine_Combat( AVP_Brain_Actor_Marine* pxBrain );

	virtual bool       HasNextGuidControl();
	virtual Asura_Guid GetNextGamesceneEntityGuid();

protected:

	virtual bool			Activate( void );
	virtual void			Deactivate( void );
	virtual void			PostLoadInitialise();
	virtual void			PerFrameUpdate( const float fTimeslice );
	virtual void			HandleParams( const Axon_BehaviourParams* pxParams );
	virtual bool			HandleMessage( const Asura_Message* pxMessage );
	virtual void			WriteToChunkStream( Asura_Chunk_Stream& xStream ) const;
	virtual void			ReadFromChunkStream( Asura_Chunk_Stream& xStream );

	void DoLooking(const float fTimeslice);
	void LookInNodesDirection();
	void LeaveNode();

#ifndef ASURA_NO_DEBUG_OUTPUT
	virtual void RenderDebugInfo( void );
#endif

private:

	enum { CURRENT_CHUNK_VERSION = 1 };

	AVP_Brain_Actor_Marine*	GetMarineBrain( void ) const;
#ifndef ASURA_NO_DEBUG_OUTPUT
	float					GetDbgOutputPosX() const		{ return GetMarineBrain()->GetDebugOutputPos().x; }
	float					GetDbgOutputPosY() const		{ return GetMarineBrain()->GetDebugOutputPos().y; }
#endif

	bool			m_bCrouched;
	bool			m_bExitOnTimeOut;
	float			m_fTimeOut;
	float			m_fTimeOutTimer;
	bool			m_bExitCalled;
	Asura_Guid		m_uCurrentGS2NodeGuid;
	Asura_Guid		m_uGS2LinkGuid;

	bool			m_bAlertSet;
	float 			m_fAlertTimer;
	Asura_Vector_3	m_xAlertPosition;
	float			m_fLookTimeOut;
	Asura_Guid		m_uLookAtGuid;
	float			m_fScanTimer;

	static const u_int uCURRENT_CHUNK_VERSION = 0;
};

//////////////////////////////////////////////////////////////////////////////
//
// AVP_BehaviourParams_Marine_Combat
//
//////////////////////////////////////////////////////////////////////////////
class AVP_BehaviourParams_Marine_Combat : public Axon_BehaviourParams
{
	typedef Axon_BehaviourParams PARENT;

public:
	AVP_BehaviourParams_Marine_Combat( const u_int uBehaviourType );

	virtual bool IsBaseOrDerivativeOf( const u_int uParamsType ) const;

#ifdef ASURA_TOOLS
	void DoAddOverlayControls( Asura_Tabs_Dialog* pxTabsDialog, Asura_Vector_2& xOffset );
#endif

	bool	m_bCrouched;
	bool	m_bExitOnTimeOut;
	float	m_fTimeOut;

protected:
	virtual void ReadFromChunkStream( Asura_Chunk_Stream& xStream );
	virtual void WriteToChunkStream( Asura_Chunk_Stream& xStream ) const;

#ifdef ASURA_TOOLS
	virtual void AddOverlayControls( Asura_Tabs_Dialog* pxTabsDialog, Asura_Vector_2& xOffset );
	virtual Axon_BehaviourParams* Clone() const;
	virtual bool GetParameter( const Asura_Hash_ID uParamID, Tools_Parameter* pxParam ) const;
	virtual bool SetParameter( const Asura_Hash_ID uParamID, const Tools_Parameter* pxParam );
	void UpdateWhileSelected();
#endif

private:

	enum { CURRENT_CHUNK_VERSION = 2 };

	u_char	m_ucCrouched;
	u_char  m_ucExitOnTimeOut;

	// Statics
	static bool s_bTimeOutChanged;
};

//////////////////////////////////////////////////////////////////////////////
//
// 
//
//////////////////////////////////////////////////////////////////////////////

#endif //__AVP_BEHAVIOUR_GS2NODE_MARINE_COMBAT_H__
