
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_InventoryWeapon_SmartGun.h
// Author : Chris Wallace
// Date   : 22-Sept-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __AVP_INVENTORYWEAPON_SMARTGUN_H__
#define __AVP_INVENTORYWEAPON_SMARTGUN_H__

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

#include "Animation/IK/Asura_Animation_IK_Chain_MarkerPoint.h"
#include "Animation/IK/Asura_Animation_IK_Solver.h"

#include "Inventory/Items/Weapons/AVP_InventoryWeapon_RangedWeapon.h"
#include "Inventory/Items/Weapons/AVP_RangedWeapon_SubType.h"
#include "Inventory/Groups/AVP_InventoryGroup_Weapons.h"

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

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

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_InventoryWeapon_SmartGun
// Author       : Chris Wallace
// Date         : 22-Sept-2008
//
// Description  : Class to handle either client or server-side updating of the
//				  SmartGun weapon.
////////////////////////////////////////////////////////////////////////////////

class AVP_InventoryWeapon_SmartGun : public AVP_InventoryWeapon_RangedWeapon
{
public:
	// Public enumerated type...

	// Public functions...
	AVP_InventoryWeapon_SmartGun( AVP_Inventory_Group& xParentGroup, const Asura_Hash_ID uHash, const Asura_Hash_ID uBlueprintHash );
	virtual ~AVP_InventoryWeapon_SmartGun(){}

	// Overridden functions...

	virtual void	StartUsing(const u_int uUsageType);
	virtual void	UpdateClientState( AVP_ClientEntity_Actor& xClient );
	virtual void	UpdateServerState( AVP_ServerEntity_Actor& xServer );
	virtual void	OnStateChange(const u_int uOldState, const u_int uNewState);
	
	//void RenderTargetLock( void );
	void GetScreenCoordsForReticle(float& fX, float& fY) const;

	virtual void	ProcessPlayerInput( const AVP_ClientEntity_Actor& xVert );
	virtual bool	IsPlayerIsStillFiring( const AVP_ClientEntity_Actor& xActor, int iSubType ) const;

	virtual void					InitialiseAnimation();
	virtual void					DestroyAnimation();

	virtual void InitialiseFromBlueprint();

	void SetTrackingMode(bool bTrackingMode) { m_bTrackingMode = bTrackingMode; }
	bool GetTrackingMode(void) const { return m_bTrackingMode; }
	
// 	// Static initialisation functions...

protected:
	// Protected variables...

	// Protected functions...
	virtual void CalculateFiringDataForSubType( const AVP_ClientEntity_Actor& xActor, Asura_Hash_ID uMuzMP, float fMuzVel, float fMaxRange, Asura_Vector_3& xFirePosition, Asura_Vector_3& xFireDirection, Asura_Matrix_3x3& xMuzzleOri, float& fRange, Asura_Guid* puTargetGuid = NULL );

	virtual void HandleStartFiringEffects( const u_int uUsageType );
	virtual void HandleFireEffects( const u_int uUsageType, const Asura_Vector_3& xFirePosition, const Asura_Matrix_3x3& xFireOrientation, const float fRange, const bool bFirstShot );
	virtual void HandleStopFiringEffects( const u_int uUsageType, const bool bStopWepaonAnims );

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

	// Private functions...
	void SetServerItemToUseDynamicAmmo( AVP_Actor_DynamicStat* pxDynamicAmmo );
	void SetDynamicAmmo( AVP_Actor_DynamicStat* pxDynamicAmmo );

	AVP_InventoryWeapon_SmartGun(void);
	AVP_InventoryWeapon_SmartGun(const AVP_InventoryWeapon_SmartGun& xOther);

	AVP_InventoryWeapon_SmartGun&	operator=(const AVP_InventoryWeapon_SmartGun& xOther);

	void UpdateSpin(State eState, u_int uUsageType);
	void UpdateTargetLock( const AVP_ClientEntity_Actor& xActor );

	bool m_bTrackingMode;
	float m_fRange;
	Asura_Vector_3 m_xMinigunDirLastFrame;
	Asura_Vector_3 m_xFirePosition;
	Asura_Matrix_3x3 m_xMuzzleOri;

	// For calculating barrel anim parametric
	float m_fSpinAcceleration;
	float m_fSpinDeceleration;
	float m_fSpinSpeed;
	float m_fSpinMaxSpeed;
	float m_fSpinAngle;
	float m_fSpinInputScale;

	Asura_Hash_ID m_uSpinLoopSoundHash;
	Asura_Handle  m_iSpinLoopSoundHandle;

	Asura_Animation_IK_Solver m_xIKSolver;
	Asura_Animation_IK_Chain_MarkerPoint m_xArmIKChain;
};   // End of class 'AVP_InventoryWeapon_SmartGun'.


#endif   // ifndef __AVP_INVENTORYWEAPON_SMARTGUN_H__


/// End of file. ///
