
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_ClientActor_Predator.h
// Author : Andy Tate
// 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_PREDATOR_H__
#define __AVP_CLIENTACTOR_PREDATOR_H__

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

#include "Actor/Vertebrates/Predator/AVP_Predator_Description.h"
#include "Blueprint/AVP_Blueprint_HashIDs.h"
#include "Entity/PhysicalObject/Actor/Vertebrates/AVP_ClientActor_Vertebrate.h"

#include "Sound/Asura_Sound_Event_System.h"
#include "Actor/Vertebrates/Predator/AVP_Predator_Description.h"


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

class Asura_Blueprint;
class AVP_Actor_Selector;
class AVP_Message_ActorClientPickup;
class AVP_Message_PredatorClientUpdate;

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

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

class AVP_ClientActor_Predator : public AVP_ClientActor_Vertebrate
{
public:
	// Public functions...
	static	AVP_ClientActor_Predator*	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	AddPermenantlyActiveItems(AVP_Inventory_Group* pxGroup);

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

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

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

	// Public Member Functions...
	void	AttachWeaponToBody(Asura_Guid uWeaponGuid, Asura_Hash_ID uMarkerHash);

	// Public Event Functions...
	virtual	void	OnBeginTargetedJump(void);
	virtual	void	OnEndTargetedJump(void);
	virtual void	OnBeginJumping(void);
	virtual	void	OnBeginLanding(void);
	virtual void	OnCountering(void);

	// Access functions...
	void							SetPanicAttacked			(bool bAttacked)	{ m_bAttacked = bAttacked; }
	bool							GetPanicAttacked 			(void)const			{ return(m_bAttacked); }

	virtual AVP_Actor_DynamicStat*			GetDynamicEnergy	()			{ return(&m_xDynamicEnergy); }
	virtual const AVP_Actor_DynamicStat*	GetDynamicEnergy	() const	{ return(&m_xDynamicEnergy); }

	Asura_Guid									GetDiscGuid					(void) const							{ return(m_uDiscGuid); }
	Asura_Guid									GetHeldProjectileGuid		(void) const							{ return(m_uHeldProjectileGuid); }
	void										SetHeldProjectileGuid		(Asura_Guid uGuid)						{ m_uHeldProjectileGuid = uGuid; }

	Asura_Guid									GetTargetGuid				(void) const							{ return m_uTargetGuid; }
	void										SetTargetGuid				(Asura_Guid uTargetGuid)				{ m_uTargetGuid = uTargetGuid; }

	bool										IsLockOn					(void) const							{ return m_bLockOn; }
	void										SetLockOn					(bool bLockOn)							{ m_bLockOn = bLockOn; }

	AVP_Actor_Selector*				GetWeaponSelector(void)					{ return(m_pxWeaponSelector); }
	//AVP_Actor_Selector*				GetVisionSelector(void)					{ return(m_pxVisionSelector); }

	// Static list accessors...
	static	AVP_ClientActor_Predator*							FindEntity	(const Asura_Guid uGuid)	{ return(s_xList.FindEntity(uGuid)); }
	static	const Asura_Hashed_List<AVP_ClientActor_Predator>*	GetList		(void)						{ return(&s_xList); }

	virtual bool	IsBoneInTorso( const int iBoneID );
	
	virtual void	GetFootPosition( u_int uFootItr, Asura_Vector_3& xFootPos );

	bool GetCanUseTargetedJump(const Asura_Vector_3& xTargetPosition, int& iJumpVariation) const;
	void GetTargetedJumpAnimationsForVariation(const int iJumpVariation, Asura_Hash_ID& uFirstPersonAnim, Asura_Hash_ID& uThirdPersonAnim) const;

	void RegainEnergyFromTrophyKill( AVP_ENTITY_CLASSIFICATION eClass );

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

protected:
	// Protected variables...
	AVP_Actor_Selector*			m_pxWeaponSelector;
	//AVP_Actor_Selector*			m_pxVisionSelector;

	Asura_Guid					m_uDiscGuid;					// The GUID of this Predator's disc.
	Asura_Guid					m_uHeldProjectileGuid;			// The GUID of the projectile currently held, not disc of spear, they are one offs.
	Asura_Guid					m_uTargetGuid;					// The GUID of the current target

	bool						m_bLockOn;						// Flag to tell if this actor has a lock on someone

	AVP_Actor_DynamicStat		m_xDynamicEnergy;				// The dynamic energy handler for this Predator.

	float						m_fEnergyRechargePerSec;
	float						m_fEnergyDurationBeforeRefill;

	float						m_fFallingSpeedThreshold;
	float						m_fEnergyLossDueToFall;
	float						m_fEnergyLossOnTargetedJump;

	float						m_fCloakedEnergyDrainStanding;
	float						m_fCloakedEnergyDrainWalking;
	float						m_fCloakedEnergyDrainRunning;
	float						m_fCloakedEnergyDrainSprinting;

	union
	{
		u_int		m_uPredatorFlags;	// Single access point for the Predator's flags.

		struct
		{
			u_int	m_bAttacked				: 1,	// Flag to say we have been attacked
					m_bCrouching			: 1,
											: 0;	// 30 spare bits.
		};
	};

	// Protected functions...
	AVP_ClientActor_Predator          ();
	virtual ~AVP_ClientActor_Predator ();

	// Function to handle the client messages...
	void	ProcessClientUpdate(const AVP_Message_PredatorClientUpdate* pxData, const float fServerTime, const bool bProcessPosAndOri = true);
	void	ProcessClientPickup(const AVP_Message_ActorClientPickup* pxData, const float fServerTime);

	void	UpdateLock(void);

	virtual void CreateAnimationHandler();

	// Protected Virtual Overridden Functions...
	virtual u_int	GetElementFromBoneID(int iBoneID) const { return AVP_Predator_Description::GetElementFromBoneID(iBoneID); }
	virtual int		GetAnyBoneIDFromElement(u_int uElement) const { return AVP_Predator_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.
	virtual void	OnApplyDamage(const AVP_EntityDamage_ApplyToEntity& xDamage);

    virtual void InitialiseFromBlueprint( const Asura_Blueprint& xBlueprint );

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

	
	void UpdatePredatorEnergy(void);

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

private:
	// Private typedefs...
	typedef AVP_ClientActor_Vertebrate PARENT;

	// Private variables...
					
	static	Asura_Hashed_List<AVP_ClientActor_Predator>		s_xList;

	// Private functions...
	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 );

	const Asura_Blueprint* GetCurrentTargetedJumpBlueprint() const;

	AVP_ClientActor_Predator (const AVP_ClientActor_Predator& xOther);
	AVP_ClientActor_Predator&	operator=	(const AVP_ClientActor_Predator& xOther);

	// Stats update functions...
	static float	RefillEnergy(const float fTimeStep, const float fCurrent, const float fDifference, const float fChargeParameter);

};   // End of class 'AVP_ClientActor_Predator'.


#endif   // ifndef __AVP_CLIENTACTOR_PREDATOR_H__


/// End of file. ///
