//////////////////////////////////////////////////////////////////////////////
//
// AVP_Brain_Actor_Marine.h
//
// Copyright (C) 2007 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_BRAIN_ACTOR_MARINE_H__
#define __AVP_BRAIN_ACTOR_MARINE_H__ 1

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

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

#include "Core/BrainTypes/AVP_Brain_Actor.h"

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

class AVP_ServerActor_Human;
class AVP_ServerEntity_Squad_Marine;
class AVP_Behaviour_Marine;
class AVP_Tactical_System;

#define ONE_METER 1.0f

//-------------------------------------------------------------------
// AVP_Brain_Actor_Marine
//-------------------------------------------------------------------
class AVP_Brain_Actor_Marine : public AVP_Brain_Actor
{
	typedef AVP_Brain_Actor PARENT;

public:

	enum LookAtType
	{
		LOOK_AT_TYPE_NONE,
		LOOK_AT_TYPE_PLAYER,
		LOOK_AT_TYPE_ACTOR,
		LOOK_AT_TYPE_NODE,
		MAX_LOOK_AT_TYPES
	};

	AVP_Brain_Actor_Marine(AVP_ServerActor_Human* pxHuman);

	// Public Member Virtual Functions...
	virtual void			ReadFromChunkStream					(Asura_Chunk_Stream& xStream);
	virtual void			WriteToChunkStream					(Asura_Chunk_Stream& xStream) const;
	virtual void			Initialise							(void);
	virtual void			DoPerFrameUpdate					(const float fTimeslice);
	virtual void			Shutdown							(void);
	virtual void			InitialiseFromBlueprint				(const Asura_Blueprint& xBlueprint);
	virtual Axon_Behaviour* CreateBehaviour						(const u_int uBehaviourID, const Asura_Message* pxMessage = NULL);
	virtual void			PostLoadInitialise();

	virtual Asura_Guid		GetPrimaryThreatGuid( void );
	virtual Asura_Guid		GetAlertGuid( void );
	void					GetThreatPos( Asura_Vector_3& xPosition );

	virtual bool CanFidget();

#ifndef ASURA_NO_DEBUG_OUTPUT
	virtual void DoRenderDebugInfo();
#endif

	// Public Member Functions...
	AVP_ServerActor_Human*			GetHumanActor					(void) const;
	AVP_ServerEntity_Squad_Marine*	GetMarineSquad					(void) const;
	AVP_Knowledge_System_Actor*		GetKnowledgeSystem				(void) const		{return m_pxKnowledgeSystem;}
	AVP_Tactical_System*			GetTacticalSystem				(void)				{return m_pxTacticalSystem;}
	void							UpdateKnowledge					(const float fTimeslice);
	bool							DoesHaveThreat					(void);
	bool							DoesHaveAlert					(void);
	Asura_Guid						GetCombatZoneGuid				(void);
	bool							GetIsRestrictedToCombatZone		(void);
	u_int							GetCurrentWeaponType			(void);
	Asura_Guid						GetLookAtGuid					(void) const { return m_uLookAtGuid; }
	void							LookAt_LookAtEntity				( void );

	bool							HasChildWhichIsAlertBehaviour	( void );
	
	

	// Common functions for the behaviours
	void					Crouch						(void);
	void					StandUp						(void);
	void					AimAtThreat					(void);
	void					AimForward					(void);
	void					LookAtThreat				(void);
	void					LookForward					(void);
	void					AimAtPosition				(const Asura_Vector_3& xPosition);
	void					LookAtPlayerHeadPosition	(void);
	void					AimAtPlayerHeadPosition		(void);
	bool					HasValidRoute				(void);
	void					DestroyChildren				(Axon_Behaviour* pxParentBehaviour);
	bool					IsInjured					( void ) const { return m_bInjured; }
	void					SetIsInjured				( bool bVal ) { m_bInjured = bVal; }

	bool	IsTorchOn(void) const;
	void	TorchOn(void);
	void	TorchOff(void);

	// Public Statics
	static u_int				GetLargestBehaviourSize			(void);

#ifndef ASURA_NO_DEBUG_OUTPUT
	static	u_int				s_uHighLevelBehaviourDebugColour;
	static	u_int				s_uPermentantChildDebugColour;
	static	u_int				s_uTemporaryChildDebugColour;
	static	u_int				s_uTemporaryLeadersChildDebugColour;
#endif

protected:
	virtual void RegisterCallbacks(void);
	virtual void UnregisterCallbacks(void);
	virtual bool HandleMessage(const Asura_Message* pxMessage);
	virtual bool RegisterWithTeam();
	virtual bool UnregisterWithTeam();
	virtual float GetNearbyRange() const;


#ifndef ASURA_NO_DEBUG_OUTPUT
	virtual bool Verify();
#endif

	// Protected Member functions...
	bool					IsMarineBehaviour					(const u_int uBehaviourType);
	Axon_Behaviour*			CreateMarineBehaviour				(const u_int uBehaviourType);
	bool					CreateDefaultBehaviour				(void);
	void					CleanUpBehaviours					(void);

private:

	// Private member Functions
	void DoKnowledgeUpdate(const float fTimeslice) {UpdateKnowledge(fTimeslice);}

	// Note: Parent function is public
	virtual void			EstablishNavData					(void);

	Asura_Handle					m_iKnowledgeUpdateHandle;
	AVP_Knowledge_System_Actor*		m_pxKnowledgeSystem;
	AVP_Tactical_System*			m_pxTacticalSystem;
	Asura_Guid						m_uLookAtGuid;
	u_int							m_uLookAtType;
	bool							m_bInjured;
	bool							m_bHadAlertLastFrame;
	bool							m_bHadThreatLastFrame;

	static const u_int uCURRENT_CHUNK_VERSION = 1;
};

#endif //__AVP_BRAIN_ACTOR_MARINE_H__

/// end of file 'AVP_Brain_Actor_Marine.h'
