
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_ClientProjectile_GenericProjectile.h
// Author : Chris Wallace
// Date   : 27-June-2007
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __AVP_CLIENTPROJECTILE_GENERICPROJECTILE_H__
#define __AVP_CLIENTPROJECTILE_GENERICPROJECTILE_H__

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

#include "Entity/PhysicalObject/Projectile/AVP_ClientEntity_Projectile.h"

#include "SpecialFX/PFX/Asura_PFX_System.h"

#define AVP_MAX_CORPSES 5

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

class Asura_Animation;
class AVP_AnimationAttachment_Ragdoll;
class AVP_GenericProjectileData;
class AVP_Message_GenericProjectileClientUpdate;
class AVP_Vertebrate_AnimationHandler;
class Asura_AnimationAttachment_ClientContainerInstance;

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

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_ClientProjectile_GenericProjectile
// Author       : Will Plano
// Date         : 12/12/2007
//
// Description  : Class to handle generic projectiles
////////////////////////////////////////////////////////////////////////////////

class AVP_ClientProjectile_GenericProjectile : public AVP_ClientEntity_Projectile
{
public:
	// Public functions...
	static	void	Create( const Asura_Message* pxMessage );

	// Overridden functions...
	virtual	void	Update			(void);
	virtual	bool	HandleMessage	(const Asura_Message* pxMessage);

	void 			AddRagdollCorpse( AVP_Vertebrate_AnimationHandler* pxVertAnimHandler, int iBoneID );
	
	bool			CollectsCorpses();

	const AVP_GenericProjectileData* GetProjectileData() const	{return m_pxProjectileData; }

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


protected:
	// Protected variables...
	Asura_Animation*					m_pxAnimation;		// A pointer to the animation to use.
	const AVP_GenericProjectileData*	m_pxProjectileData;
	Asura_Handle						m_iPFXTrailHandle;
	bool								m_bPFXAttached;
	bool								m_bIsEmbedded;
	float								m_fScale;
	Asura_Handle						m_iSoundHandle;
	Asura_AnimationAttachment_ClientContainerInstance*	m_pxContainerAttachment;	// It is for trail attachment.
	Asura_AnimationAttachment*							m_pxPFXAttachment;

	// Protected functions...
	void MakeExplosion();
	virtual void UpdateProjectileSound(void);

	virtual void OnEmbed() {}

	AVP_ClientProjectile_GenericProjectile          ( const AVP_Message_ProjectileClientUpdate* pxData );
	virtual ~AVP_ClientProjectile_GenericProjectile ();

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

	// Private variables...
	u_int								m_uNumCorpses;
	AVP_AnimationAttachment_Ragdoll*	m_apxRagdollAttachments[ AVP_MAX_CORPSES ];

	static	Asura_Hashed_List<AVP_ClientProjectile_GenericProjectile>	s_xList;

	// Private functions...
	AVP_ClientProjectile_GenericProjectile  (const AVP_ClientProjectile_GenericProjectile& xOther);

	AVP_ClientProjectile_GenericProjectile&	operator=	(const AVP_ClientProjectile_GenericProjectile& xOther);

	void ProcessClientUpdate (const AVP_Message_GenericProjectileClientUpdate* pxData,	const float fServerTime, const bool bProcessPosAndOri = true);

	void AttachContainerTrail();
	void DestroyTrails();

};   // End of class 'AVP_ClientProjectile_GenericProjectile'.


#endif   // ifndef __AVP_CLIENTPROJECTILE_GENERICPROJECTILE_H__


/// End of file. ///
