//---------------------------------------------------------------------------
// File			: AVP_Behaviour_Marine_Weapon.h
// Created		: 
// Created By	: Gareth Thomas
// Copyright (C) 2007 Rebellion. All Rights Reserved.
//---------------------------------------------------------------------------

// BEGIN FILE WRAPPER ///////////////////////////////////////
#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif
#ifndef __AVP_BEHAVIOUR_MARINE_WEAPON_H__
#define __AVP_BEHAVIOUR_MARINE_WEAPON_H__ 1
// END FILE WRAPPER ///////////////////////////////////////////

// INCLUDES ///////////////////////////////////////////////////////////
#include "Behaviour/Axon_Project_Behaviour.h"

// FORWARD DECLARATIONS ///////////////////////////////////
class AVP_Brain_Actor_Marine;

//---------------------------------------------------------------------------
// Class		: AVP_Behaviour_Marine_Weapon
// Description	: 
//---------------------------------------------------------------------------
class AVP_Behaviour_Marine_Weapon : public Axon_Project_Behaviour
{
	typedef Axon_Project_Behaviour PARENT;

public:

	// InCover Update State Enum
	enum WeaponUpdateState
	{
		UNSET,
		IDLE,
		RELOADING,
		FIRING,
		SUPPORT_IDLE,
		SUPPORT_FIRE,
		MAX_STATES
	};

	// Construction / Deconstruction
	AVP_Behaviour_Marine_Weapon									( AVP_Brain_Actor_Marine* pWeaponBrain );
	virtual ~AVP_Behaviour_Marine_Weapon						( void )							{}

	// Public Member Functions...
	WeaponUpdateState				GetUpdateState				( void ) const							{ return m_eUpdateState; }
	AVP_Brain_Actor_Marine*			GetMarineBrain				( void )								{ return m_pxMarineBrain; }

protected:

	virtual bool 					Activate					( void );
	virtual void 					Deactivate					( void );
	virtual void 					Pause						( void );
	virtual void 					Unpause						( void );
	virtual void 					Update						( const float fTimeslice );
	virtual void					PerFrameUpdate				( const float fTimeslice );
#ifndef ASURA_NO_DEBUG_OUTPUT
	virtual void					RenderDebugInfo				( void );
#endif

	void							SetUpdateState				( WeaponUpdateState eState )			{ m_eUpdateState = eState; }
	bool							CheckForFire				( void );
	bool							CheckForSupportFire			( void );
	bool							CheckForReload				( float fAmountToReloadOn );
	void							Shoot						( void );
	void							SupportShoot				( void );
	void							StopShooting				( void );
	void							ReloadWeapon				( void );
	bool							CheckForReloadFinsihed		( void );
	void							FireGrenade					( void );
	bool							CanFireGrenade				( void );
	float							GetWeaponsMaxRange			( void );
	float							GetWeaponRateOfFire			( void );
	float							GetWeaponAmmo				( void );
	float							GetWeaponClipSize			( void );
	bool							IsWeaponPulseRifle			( void );
	bool							GetWeaponMuzzlePositionAndOrientation( Asura_Vector_3* xPosition, Asura_Matrix_3x3* xOrientation );
	bool							DoNotFireIfHumanIsInFront	( void );
	bool							IsOtherActorInFieldOfView	( const AVP_ServerEntity_Actor* pxOtherActor );
	void							PlayAttackingDialogue		( const float fTimeslice );

	void							ResetFiringToIdleTimer		( void )									{ m_fFiringToIdleTimer = 0.0f; }
	void							IncrementFiringToIdleTimer	( const float fTimeslice )					{ m_fFiringToIdleTimer += fTimeslice; }
	float							GetFiringToIdleTimer		( void )									{ return m_fFiringToIdleTimer; }
	float							GetFiringToIdleTimeout		( void )									{ return m_fFiringToIdleTimeOut; }
	void							SetFiringToIdleTimeout		( float fTime )								{ m_fFiringToIdleTimeOut = fTime; }
	void							IncrementGrenadeTimer		( const float fTimeslice )					{ m_fTimeSinceGrenade += fTimeslice; }
	void							ResetTimeSinceLastGrenade	( void )									{ m_fTimeSinceGrenade = 0.0f; }
	float							GetTimeSinceLastGrenade		( void )									{ return m_fTimeSinceGrenade; }

	bool							AllyToCloseToFire( const Asura_Vector_3 &xStart, const Asura_Vector_3& xEnd );

	bool							DoWeHitThreat	( const Asura_Vector_3& xOrigin, const Asura_Vector_3& xDirection, const AVP_ServerEntity_Actor* pxThreat );

	void							ClearGuidBeingattackedIfWeaponIdle( void );
	bool							IsWeaponPositionInsideFriendlyBoundingBox( const Asura_Vector_3& xTestPos );

	void							TestShoot( void );

	void							DoFiring( const float fTimeslice );
	void							DoSupportFire( const float fTimeslice );
	void							SetWeaponStoppedFireTime( const float fTimeslice );

private:

	// Private Member Variables...
	WeaponUpdateState					m_eUpdateState;
	AVP_Brain_Actor_Marine*				m_pxMarineBrain;
	float								m_fTimeSinceLastShot;
	bool								m_bReloading;
	bool								m_bFiring;
	Asura_Guid							m_uEnemyGuid;
	float								m_fFiringToIdleTimer;
	float								m_fFiringToIdleTimeOut;
	float								m_fLastCheckDistance;
	float								m_fTimeSinceGrenade;
	float								m_fFiringTimer;
	float								m_fStoppedFiringTimer;
	float								m_fDialogueTimer;
	bool								m_bReloadStated;
	float								m_fTestDot;
	float								m_fFlameTimeout;

	static float						s_fGrenadeRefireTime;
	static float						s_fGrenadeMinRange;
	static float						s_fGrenadeMaxRange;

	enum { CURRENT_CHUNK_VERSION = 0 };

};

#endif //__AVP_BEHAVIOUR_MARINE_WEAPON_H__

/// End Of File 'AVP_Behaviour_Marine_Weapon.h'
