
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Vertebrate_HUDHandler.h
// Author : Andy Tate
// Date   : 4-Oct-2007
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __AVP_VERTEBRATE_HUDHANDLER_H__
#define __AVP_VERTEBRATE_HUDHANDLER_H__

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

#include "Actor/AVP_Actor_HUDHandler.h"
#include "Actor/AVP_Actor_DamageDirectionIndicator.h"
#include "Rendering/Asura_Colour.h"
////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////

class AVP_ClientEntity_Actor;
class AVP_ClientActor_Vertebrate;
class Asura_Blueprint;

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

enum AVP_VERTEBRATE_HUDHANDLER_ACTIVEGRAPPLE_RESULT
{
	AVP_VERTEBRATE_ACTIVEGRAPPLE_RESULT_UNDECIDED,
	AVP_VERTEBRATE_ACTIVEGRAPPLE_RESULT_CRITICALSUCCESS,
	AVP_VERTEBRATE_ACTIVEGRAPPLE_RESULT_SUCCESS,
	AVP_VERTEBRATE_ACTIVEGRAPPLE_RESULT_FAILURE,

	AVP_VERTEBRATE_ACTIVEGRAPPLE_NUMRESULTS,
};

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_Vertebrate_HUDHandler
// Author       : Andy Tate
// Date         : 4-Oct-2007
//
// Description  : Class to handle the HUD code for vertebrates.
////////////////////////////////////////////////////////////////////////////////

class AVP_Vertebrate_HUDHandler : public AVP_Actor_HUDHandler
{
public:
	// Public functions...
	AVP_Vertebrate_HUDHandler(AVP_ClientEntity_Actor& xClient);
	virtual ~AVP_Vertebrate_HUDHandler();

	virtual void	Update( const AVP_ClientEntity_Actor& xClient );
	virtual	void	Reset () { PARENT::Reset(); m_xDDI.Reset(); }

	// Event functions...
	virtual void	OnApplyDamage( const AVP_EntityDamage_ApplyToEntity& xDamage );

	virtual void	OnBeginJump(void);

	virtual void 	OnBeginMeleeJump(void);
	virtual void 	OnEndMeleeJump(void);

	virtual void	OnBeginFocus(void);
	virtual void	OnEndFocus(void);

	static void     SetGrabTargetInRange( bool bGrabTargetInRange ){ s_bGrabTargetInRange = bGrabTargetInRange; }
	static void     SetPounceTargetInRange( bool bPounceTargetInRange ){ s_bPounceTargetInRange = bPounceTargetInRange; }

	void StartActiveGrapple( Asura_Hash_ID uActiveGrappleBlueprint, Asura_Hash_ID uSoundsBlueprint, Asura_Hash_ID uActiveGrappleBlueprintType ); // The sounds blueprint can be unset, in which case the active grapple blueprint will be used.
	void SetActiveGrappleResult(AVP_VERTEBRATE_HUDHANDLER_ACTIVEGRAPPLE_RESULT eResult);
	void FinaliseActiveGrappleResult();
	void SetHealthDSP ( bool bOn ) const;

	static float	GetFocusMode()		{return s_fFocusModeActive;}

#if defined(ASURA_SUPPORT_COMMAND_CONSOLE)
	static void CreateConsoleVars();
#endif //#if defined(ASURA_SUPPORT_COMMAND_CONSOLE)

	static u_int s_auWeaponSelectorDispCondIndex[8];
	static u_int s_uCurrentWeaponDispCondIndex;
	static u_int s_uCurrentWeaponDispCondSlot;

protected:
	
	// Protected functions...

	virtual void GetReticlePosition(float& fX, float& fY);


	// Melee counter grapple system.
	void UpdateActiveGrapple( const AVP_ClientEntity_Actor& xClient );
	void SetShowActiveGrappleBar( bool bShow );
	void SendActiveGrappleMessageToServer( const AVP_ClientEntity_Actor& xClient, float fResultValue );
	float CalculateActiveGrappleSliderPosFromSliderTimer()	{	return m_fActiveGrapple_BarSliderTimer / m_fActiveGrapple_Duration;	}	// It will return value between zero and one.

	// Protected variables...
	AVP_Actor_DamageDirectionIndicator_System m_xDDI;
	float			m_fReticleFadeout;

	Asura_Handle	m_iAdrenalineLoopHandle;
	Asura_Handle	m_iBreathingLoopHandle;
	Asura_Handle	m_iMeleeJumpLoopSoundHandle;
	Asura_Handle	m_iFocusSoundLoopHandle;

	static float	s_fFocusModeActive;

	// For Active Grapple
	float			m_fActiveGrapple_BarSliderTimer;
	float			m_fActiveGrapple_BarSliderPosSendToServer;	// Once the player will hit key, slider bar will stop and wait a while. (And so even when timer will go on, the graphics of slider will stay on same place.)
	float			m_fActiveGrapple_CriticalSuccess_Start;		// Value between 0.0 and 1.0. It should be smaller that m_fActiveGrapple_CriticalSuccess_Start.
	float			m_fActiveGrapple_CriticalSuccess_End;		// Value between 0.0 and 1.0. It should be bigger that m_fActiveGrapple_CriticalSuccess_End.
	float			m_fActiveGrapple_Success_Start;				// Value between 0.0 and 1.0. It should be smaller that m_fActiveGrapple_Success_End.
	float			m_fActiveGrapple_Success_End;				// Value between 0.0 and 1.0. It should be bigger that m_fActiveGrapple_Success_Start.
	float			m_fActiveGrapple_Duration;					// Time taken (in seconds) for the swingometer to move from left to right.
	float			m_fActiveGrapple_InitialDelay;				// Time (in seconds) between the grapple bar appearing and the swingometer starting.
	float			m_fActiveGrapple_CompletedDelay;			// Time (in seconds) between deciding the result and the grapple bar disappearing.
	float			m_fActiveGrapple_MultiplayerResultWaitTimer;// In multiplayer we may end up not sure what the result is for a while longer than we should do. Wait a bit of time before giving our best guess.
	Asura_Hash_ID	m_uActiveGrapple_StartGrappleSoundEvent;
	Asura_Hash_ID	m_uActiveGrapple_StartMarkerSoundEvent;
	Asura_Hash_ID	m_uActiveGrapple_WinSoundEvent;
	Asura_Hash_ID	m_uActiveGrapple_LoseSoundEvent;
	
	// DSP effect
	Asura_Hash_ID   m_uSoundMixerPreset;

	AVP_VERTEBRATE_HUDHANDLER_ACTIVEGRAPPLE_RESULT m_eStoredActiveGrappleResult;

	union
	{
		u_int m_uFlags;
		struct
		{
			u_int	m_bActiveGrapple_IsWaitingForUserInput	: 1,
					m_bActiveGrapple_ResultFinalised		: 1,
															: 0;
		};
	};

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

	// Private functions...
	AVP_Vertebrate_HUDHandler(void);
	AVP_Vertebrate_HUDHandler(const AVP_Vertebrate_HUDHandler& xOther);

	AVP_Vertebrate_HUDHandler&	operator=(const AVP_Vertebrate_HUDHandler& xOther);

	const Asura_RGBA* GetReticuleColorArray(Asura_Guid uTargetGuid);

	void UpdateHudFlags( const AVP_ClientEntity_Actor& xClient );

	// Private variables...
	Asura_RGBA m_xOriginalReticleColors[ 5 ];                    // Original reticule colors, this will turn red if targeting friends

	static bool s_bGrabTargetInRange;
	static bool s_bPounceTargetInRange;	
	static bool s_bShowReticle;
};   // End of class 'AVP_Vertebrate_HUDHandler'.


#endif   // ifndef __AVP_VERTEBRATE_HUDHANDLER_H__


/// End of file. ///
