
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Predator_LockOn.h
// Author : Chris Wallace
// Date   : 26-Feb-2007
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __AVP_Predator_LockOn_H__
#define __AVP_Predator_LockOn_H__

#define TARGET_NUM_POINTS			4
#define TARGET_NUM_POLYS			3
#define TARGET_MAX_UNLOCK_TIME		1.0f

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

#include "Entity/PhysicalObject/Actor/AVP_ClientEntity_Actor.h"

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


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

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_Predator_LockOn
// Author       : Chris Wallace
// Date         : 26-Feb-2007
////////////////////////////////////////////////////////////////////////////////

class AVP_Predator_LockOn
{
public:

	enum TargetState
	{
		TARGET_LOCKED,
		TARGET_LOCKING,
		TARGET_UNLOCKING,
		TARGET_UNLOCKED,
	};

	static AVP_Predator_LockOn& GetSingleton() { return s_xSingleton; }

	// Public functions...
	//~AVP_Predator_LockOn ();

	// Charge functions...
	//void	LockingOn	(void);

	// Render functions...
	void	Reset	(void);
	void	Render	(void) const;
	void	Shutdown();
	void	Update ();
	void	SetLockTarget(Asura_Guid uTarget, Asura_Hash_ID uMarkerHash);
	void	MoveLockTarget(Asura_Guid uTarget, Asura_Hash_ID uMarkerHash);
	void	UnLock( void );

	void	SetUpTargetPositions( void );

	void	SetOwnerGuid( const Asura_Guid uGuid );

	// Accessor functions...
	u_int						GetLockTargetGuid		(void) const	{ return(m_uLockTargetGuid); }
	AVP_ClientEntity_Actor*		GetLockTarget			(void) const	{ return(AVP_ClientEntity_Actor::FindEntity(m_uLockTargetGuid)); }

	bool						IsLockedOn				(void) const;

	void						SetLockTime				(float fPlasmaTime)			{ m_fPlasmaLockLength = fPlasmaTime; }
	void						SetMaxRange				(float fMaxRange)			{ m_fMaxRange = fMaxRange; }
	void						SetLockDist				(float fPlasmaDist)			{ m_fPlasmaLockStartDist = fPlasmaDist; }
	void						SetLockScale			(float fPlasmaScale)		{ m_fPlasmaLockStartScale = fPlasmaScale; }

	//Colour functions
	u_char						GetDefaultColourR		(void) const			{ return m_xLockDefaultColourR; }
	u_char						GetDefaultColourG		(void) const			{ return m_xLockDefaultColourG; }
	u_char						GetDefaultColourB		(void) const			{ return m_xLockDefaultColourB; }
	u_char						GetDefaultColourA		(void) const			{ return m_xLockDefaultColourA; }

	void						SetDefaultColourR		(u_char ucIn)			{ m_xLockDefaultColourR = ucIn; }
	void						SetDefaultColourG		(u_char ucIn)			{ m_xLockDefaultColourG = ucIn; }
	void						SetDefaultColourB		(u_char ucIn)			{ m_xLockDefaultColourB = ucIn; }
	void						SetDefaultColourA		(u_char ucIn)			{ m_xLockDefaultColourA = ucIn; }

	u_char						GetColourR				(void) const			{ return m_xLockColourR; }
	u_char						GetColourG				(void) const			{ return m_xLockColourG; }
	u_char						GetColourB				(void) const			{ return m_xLockColourB; }
	u_char						GetColourA				(void) const			{ return m_xLockColourA; }

	void						SetColourR				(u_char ucIn)			{ m_xLockColourR = ucIn; }
	void						SetColourG				(u_char ucIn)			{ m_xLockColourG = ucIn; }
	void						SetColourB				(u_char ucIn)			{ m_xLockColourB = ucIn; }
	void						SetColourA				(u_char ucIn)			{ m_xLockColourA = ucIn; }

	void						GetLockTargetPosition	(Asura_Vector_3& xOutPut) const;

	u_int						GetLockState			() const				{ return m_uLockState; }
	void						SetLockState			(u_int uState)			{ m_uLockState = uState; }

	// Static vars for GUIMenu

#if defined(ASURA_SUPPORT_COMMAND_CONSOLE)
	void UpdateStaticGUIVars();
	static void CreateConsoleVars();
#endif
	static float s_fLockOnParametric;
	static u_int s_uState;
	static Asura_Vector_3 s_xTargetPos;


protected:
	// Protected variables...
	Asura_Guid m_uPlayerGuid;
	Asura_Guid m_uLockTargetGuid;
	Asura_Hash_ID m_uLockedTargetMarkerPointHash;

	float m_fLockCounter;
	static float s_fRotCounter; // used to sync rotation of all pred lock on reticles

	float m_fTargetScreenPosX;
	float m_fTargetScreenPosY;

	float m_fPlasmaLockLength;
	float m_fPlasmaLockStartDist;
	float m_fPlasmaLockStartScale;

	float m_fMaxRange;

	unsigned char m_xLockColourR;
	unsigned char m_xLockColourG;
	unsigned char m_xLockColourB;
	unsigned char m_xLockColourA;

	unsigned char m_xLockDefaultColourR;
	unsigned char m_xLockDefaultColourG;
	unsigned char m_xLockDefaultColourB;
	unsigned char m_xLockDefaultColourA;

	// Protected functions...


private:
	// Private variables...
	Asura_Vector_2 m_xPoint[3][4];
	Asura_Vector_2 m_xBlurPoint[3][4];

	float m_fScale;
	float m_fDistance;
	float m_fRot;
	u_int m_uLockState;
	bool  m_bWasCancelled;
	float m_fTimeToDie;
	float m_fTargetPosZ;
	float m_fLockTime;

	Asura_Vector_3			m_xTargetPosition;			// The end position of the plasma.

	float					m_fTimeLocking;				// The amount of time we've spent locking on.

	const Asura_Sound_Event*	m_pxLockSound;
	const Asura_Sound_Event*	m_pxLockCancelSound;
	const Asura_Sound_Event*	m_pxLockConfirmedSound;
	const Asura_Sound_Event*	m_pxLockStartSound;
	const Asura_Sound_Event*	m_pxLockingLoopSound;

	Asura_Handle m_iSoundHandle;

	// Private functions...
	AVP_Predator_LockOn  (const Asura_Guid uGuid = ASURA_GUID_UNREGISTERED);
	AVP_Predator_LockOn  (const AVP_Predator_LockOn& xOther);
	AVP_Predator_LockOn&	operator=	(const AVP_Predator_LockOn& xOther);

	void	ResetColour( void );

	void	PlayLockAquiredSound( void );
	void	PlayLockCancelledSound( void );
	void	PlayLockConfirmedSound( void );
	void	PlayLockStartSound( void );
	void	PlayLockLoopedSound( void );

	void	UpdateLockLoopedSound( void );

	static	AVP_Predator_LockOn s_xSingleton;

};   // End of class 'AVP_Predator_LockOn'.


#endif   // ifndef __AVP_Predator_LockOn_H__


/// End of file. ///
