
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_ClientActor_Human.h
// Author : Andy Tate
// Modified to Human : Chris Wallace
// Date   : 3-Oct-2006
//
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __AVP_CLIENTACTOR_HUMAN_H__
#define __AVP_CLIENTACTOR_HUMAN_H__

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Actor/Vertebrates/Human/AVP_Human_AIAnimStateMachine.h"
#include "Actor/Vertebrates/Human/AVP_Human_Description.h"
#include "Blueprint/AVP_Blueprint_HashIDs.h"
#include "Entity/PhysicalObject/Actor/Vertebrates/AVP_ClientActor_Vertebrate.h"
#include "GUIMenu/Asura_GUIMenu_Element_Text.h"
#include "Sound/Asura_Sound_Event_System.h"

////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////

class AVP_Actor_Selector;
class AVP_InventoryItem_Torch;
class AVP_Message_ActorClientPickup;
class AVP_Message_HumanClientUpdate;
class AVP_Message_HumanClientCreate;

////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_ClientActor_Human
// Author       : Andy Tate
// Date         : 3-Oct-2006
//
// Description  : This class handles the operation of the Alien actor, the
//				  Predator can be either player controlled or AI controlled.
////////////////////////////////////////////////////////////////////////////////
class AVP_ClientActor_Human : public AVP_ClientActor_Vertebrate
{

public:

	// Public functions...
	static	AVP_ClientActor_Human*	Create	(const Asura_Message* pxMessage);
	
	// Public Virtual Overridden functions...
	virtual	void	Update					(void);
	virtual	bool	HandleMessage			(const Asura_Message* pxMessage);
	virtual	void	RenderHUD				(void) const;
	virtual void 	MakePlayer				(Asura_Guid uPlayerGuid);
	virtual	void	MakeAI		            (void);
	virtual void	PostCreateInitialise	(void);
	virtual void	Render					(void);

	virtual void	AddPermenantlyActiveItems(AVP_Inventory_Group* pxGroup);

	virtual u_int GetMaxWeapons(void) const { return 3u; }

	virtual void ReadFromClientCreateStream(Asura_Chunk_Memory_Stream& xStream, float fServerTime);

	AVP_Actor_Selector*			GetWeaponSelector(void)						{ return(m_pxWeaponSelector); }

	// Accessors functions...

	// Access Functions...
	u_int						GetWeapon(void) const				{ return m_uWeapon; }
	float						GetArmour(void) const				{ return m_fArmour; }

	AVP_InventoryItem_Torch*	GetTorchItem(void) const;

	void						SetCrouching(const bool bSet, const bool bCheckIfPossible);
	virtual bool				IsCrouching(void) const				{ return(m_bCrouching); }
	bool						IsStanding(void) const				{ return(!m_bCrouching); }

	void						SetAiming(const bool bSet);
	bool						IsAiming(void) const				{ return(m_bAiming); }

	virtual bool				IsBoneInTorso( const int iBoneID );

	virtual bool				MakeRagdoll();

	virtual void				GetFootPosition( u_int uFootItr, Asura_Vector_3& xFootPos );

	void						ToggleADS() { m_fTargetADSValue = 1.0f - m_fTargetADSValue; }

	AVP_Human_AIAnimStateMachine::CoverType	GetCoverType() const { return m_eCoverType; }
	void						SetCoverType( const AVP_Human_AIAnimStateMachine::CoverType eCoverType ) { m_eCoverType = eCoverType; }

	virtual const AVP_Actor_AnimStateData* GetAnimStateDataForWeapon( const Asura_Hash_ID uWeaponBPHash ) const;

	Asura_GUIMenu_Element_Text& GetNameText() { return m_xNameText;}
	const Asura_GUIMenu_Element_Text& GetNameText() const { return m_xNameText;}

	Asura_Guid GetPickedUpBuddyGuid() const { return m_uPickedUpBuddyGuid; }
	bool IsCarryingBudddy() const { return m_uPickedUpBuddyGuid != ASURA_GUID_UNREGISTERED; }

	bool IsPickupAble() const { return m_bPickUpAble; }
	bool IsDroppable() const { return m_bDroppable; }

	void OnThrowFlare() { ++m_uNumFlaresActive; }
	void OnFlareExpire() { Asura_Assert( m_uNumFlaresActive > 0, "" ); if ( m_uNumFlaresActive > 0 ){ --m_uNumFlaresActive; } }
	u_int GetNumActiveFlares() const { return m_uNumFlaresActive; }

	// Static Public Functions...
	static	AVP_ClientActor_Human*							FindEntity	(const Asura_Guid uGuid)	{ return(s_xList.FindEntity(uGuid)); }
	static	const Asura_Hashed_List<AVP_ClientActor_Human>*	GetList		(void)						{ return(&s_xList); }

protected:		
	// Protected variables...
	AVP_Actor_Selector*			m_pxWeaponSelector;
	float						m_fArmour;
	Asura_GUIMenu_Element_Text  m_xNameText;
	// Protected functions...
	AVP_ClientActor_Human          (void);
	virtual ~AVP_ClientActor_Human ();

	void	UpdateAimDownSights();

	void	PlayDialogue(Asura_Hash_ID uDialogueHash);

	// Overridden functions...
	virtual	void	OnApplyDamage(const AVP_EntityDamage_ApplyToEntity& xDamage);
	virtual	void	OnDeath(const AVP_EntityDamage_ApplyToEntity& xDamage);
	virtual void CreateAnimationHandler();

	// Protected Member Functions...
	virtual u_int	GetElementFromBoneID(int iBoneID) const { return AVP_Human_Description::GetElementFromBoneID(iBoneID); }
	virtual int		GetAnyBoneIDFromElement(u_int uElement) const { return AVP_Human_Description::GetAnyBoneIDFromElement(uElement); } // Since bones->elements is a many->one mapping, this function will return one of the bones associated with the given element, but not necessarily the only one.

	// Overridden initialisation functions...
	virtual bool	InitialiseInventory(void);
	virtual bool	InitialiseMoves( void );

	// Function to handle the client-update message...
	void	ProcessClientUpdate	(const AVP_Message_HumanClientUpdate* pxData, const float fServerTime, const bool bProcessPosAndOri = true);

	virtual void GetCurrentBlockBlueprintHashes(Asura_Hash_ID& uBlueprintTypeHash, Asura_Hash_ID& uFirstPersonBlueprintHash, Asura_Hash_ID& uThirdPersonBlueprintHash) const;

private:

	// Private typedefs...
	typedef AVP_ClientActor_Vertebrate PARENT;

	virtual const AVP_Actor_AnimStateData* GetStateDataFromMesssageData( const u_int uState, const AVP_Message_Actor_ClientUpdate* pxActorData );
	virtual const AVP_Actor_AnimStateData* GetStateData( const u_int uState, const u_int uGroundType, const u_int uLimbDamage, const bool bIsAiming, const u_int uCoverType );

	// Private variables...
	
	AVP_Human_AIAnimStateMachine::CoverType			m_eCoverType;
	u_int			m_uType;				// The type of Human
	u_int			m_uWeapon;				// The humans weapon.
	Asura_Hash_ID	m_uTorchHash;			// the hash of our torch inv item

	Asura_Guid		m_uPickedUpBuddyGuid;

	u_int			m_uNumFlaresActive;

	float			m_fTargetADSValue;
	float			m_fCurrentADSValue;
	float			m_fStoredNearClip;
   
	union
	{
		u_int		m_uHumanFlags;			// Single access point for the flags.

		struct
		{
			u_int	m_bCrouching			: 1,	// Flag to say that we're crouching.
					m_bAiming				: 1,
					m_bIsBeingFaceHugged	: 1,
					m_bDroppable			: 1,
					m_bPickUpAble			: 1,
					m_bHasMotionTracker		: 1,
											: 0;	// 29 spare-bits.		
		};
	};

	// Static Private Member variables
	static	Asura_Hashed_List<AVP_ClientActor_Human>	s_xList;

#if defined(ASURA_USE_DIALOGUE_SYSTEM)
	static	Asura_Handle s_iActorDialogueHandle;
#endif	//defined(ASURA_USE_DIALOGUE_SYSTEM)

	// Private functions...
	AVP_ClientActor_Human (const AVP_ClientActor_Human& xOther);
	AVP_ClientActor_Human&	operator=	(const AVP_ClientActor_Human& xOther);

};   // End of class 'AVP_ClientActor_Human'.


#endif   // ifndef __AVP_CLIENTACTOR_HUMAN_H__


/// End of file. ///
