//---------------------------------------------------------------------------
// File			: AVP_Behaviour_Marine_Attack.h
// Created		: 30 / 05 / 08
// Created By	: Gareth Thomas
// Copyright (C) 2007 Rebellion. All Rights Reserved.
//---------------------------------------------------------------------------

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

//---------------------------------------------------------------------------
// INCLUDES
//---------------------------------------------------------------------------
// Asura
#include "Core/Asura_LinkList.h"

// Axon
#include "Behaviour/Axon_Project_Behaviour.h"

// AVP Axon
#include "Core/AVP_PositionEvaluation.h"
#include "Core/BrainTypes/AVP_Brain_Actor_Marine.h"

//---------------------------------------------------------------------------
// FORWARD DECLARATIONS
//---------------------------------------------------------------------------
class AVP_ServerActor_Human;
class AVP_Knowledge_System_Actor;
class AVP_Tactical_System;
class AVP_ServerNode_CoverpointNode;

//---------------------------------------------------------------------------
// Class			: AVP_Behaviour_Marine_Attack
// Last Modified	: 30 / 05 / 08
//---------------------------------------------------------------------------
class AVP_Behaviour_Marine_Attack : public Axon_Project_Behaviour
{
	typedef Axon_Project_Behaviour PARENT;

public:

	enum UpdateState
	{
		UNSET,
		POSITION_EVALUATION,
		MOVE_TO_COVER,
		COVER,
		MAX_STATES
	};

	// Construction / Deconstruction
	AVP_Behaviour_Marine_Attack( AVP_Brain_Actor_Marine* pxBrain );
	virtual ~AVP_Behaviour_Marine_Attack( void );

	// Public Member Virtual Functions...
	virtual bool 					Activate( void );
	virtual void 					Deactivate( void );
	virtual void					PerFrameUpdate( const float fTimeslice );
#ifndef ASURA_NO_DEBUG_OUTPUT
	virtual void					RenderDebugInfo( void );
#endif

protected:

	typedef u_int( WaypointScoringFn( const AVP_ServerActor_Human* pxOurActor, u_int uCurrentWaypointID, float fEvaluationRange, float fMinFightingRange, float fMaxFightingRange ) );

	// Protected Member Accessors...
	UpdateState						GetUpdateState( void ) const					{ return m_eUpdateState; }
	void							SetUpdateState( UpdateState eState )			{ m_eUpdateState = eState; }
	AVP_Brain_Actor_Marine*			GetMarineBrain( void )							{ return m_pxMarineBrain; }
	AVP_ServerActor_Human*			GetOurActor( void ) const						{ return m_pxMarineBrain->GetHumanActor(); }
	AVP_Tactical_System*			GetTacticalSystem( void )						{ return m_pxMarineBrain->GetTacticalSystem(); }
	AVP_Knowledge_System_Actor*		GetKnowledgeSystem( void )						{ return m_pxMarineBrain->GetKnowledgeSystem(); }

	// Protected Member Functions...
	void							SwitchToState( UpdateState eState );
	void							PositionEvaluation( const float fTimeslice );
	void							FindBestWaypoint( AVP_Navigation::PosEvalFunctor* pxPosEval );
	static u_int					GetAttackingScoreForWaypoint( AVP_Navigation::AVP_PosEvalParams xPosEvalParams );
	static u_int					GetDefendingScoreForWaypoint( AVP_Navigation::AVP_PosEvalParams xPosEvalParams );

	void	CalculateEngagementRange(float* fMinEngagementRange, float* fMaxEngagementRange);

	bool	DoesWaypointContainCoverAndItsNotOccupied( u_int uWaypointID );

	void	ModifyDefensiveTimeout();

private:

	enum RouteTimeOutState
	{
		RD_TINY,
		RD_SHORT,
		RD_MEDIUM_SHORT,
		RD_MEDIUM,
		RD_MEDIUM_LONG,
		RD_LONG,
		RD_HUGE,
		MAX_ROUTE_TIMEOUTS
	};

	// Private Member Variables...
	UpdateState												m_eUpdateState;
	AVP_Brain_Actor_Marine*									m_pxMarineBrain;
	float													m_fPosEvalUpdateTimer;
	u_int													m_uPosEvalCounter;
	bool													m_bBeingDefensive;
	bool													m_bDefenseDamageReset;
	bool													m_bAttackDamageReset;
	AVP_ServerNode_CoverpointNode*							m_pxBestCoverPoint;
	Asura_Guid												m_uBestCoverPoint;
	float													m_fDefensiveStanceTimeout;
	u_int													m_uRouteTimeOutState;
	float													m_fDefensiveRouteDistance;

	enum { CURRENT_CHUNK_VERSION = 0 };

};

#endif //__AVP_BEHAVIOUR_MARINE_ATTACK_H__

/// End Of File 'AVP_Behaviour_Marine_Attack.h'
