/**
*
* AVP_PFX_Entity_Fire.h
*
* Created by RDM - 26 September 2006
*
* Copyright (C) 2006 Rebellion, All Rights Reserved.
*
**/

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __AVP_PFX_ENTITY_FIRE_H__
#define __AVP_PFX_ENTITY_FIRE_H__

/************/
/* Includes */
/************/

// asura
#include "Core/Asura_Hash.h"
#include "SpecialFX/PFX/Asura_PFX_Effect.h"

/***********/
/* Classes */
/***********/   

/*************************************************************
 *
 * Class Name    : AVP_PFX_Entity_Fire
 *
 * Author        : Richard May
 *
 * Description   : Generic entity fire effect. Should work for any entity with a shape or anim. Can use
 *				   any source type (not just fire).
 *
 *				   Usage: Create the effect and then add source templates as necessary. Source templates 	
 *						  are associated with a minimum volume. A source is created for each bone (a single
 *						  source is used for shapes) and the source's generation volume is set to that bone's
 *						  bounding box (shapes use their LOS bounding box). The source template that is used
 *						  depends on the volume (in metres cubed) of the bone.
 *
 *						  Particles are generated using the source's volume and, at the current time, are
 *						  generated on the surface of the volume as this looks better although this could
 *						  also be associated with the size of the source volume.
 *
 *************************************************************/
class AVP_PFX_Entity_Fire : public Asura_PFX_Effect
{

private:
	typedef Asura_PFX_Effect PARENT;

public:
	/* Constructors/destructor. */
	AVP_PFX_Entity_Fire	( void );
	virtual ~AVP_PFX_Entity_Fire();

	/* Public interface functions. */
	virtual void UpdatePosition( const class Asura_Shape_Instance* pxShapeInstance );
	virtual void SetDieOut( bool bDie ) { m_bDieOut = true; }
	virtual void AddSourceTemplate( Asura_Hash_ID uSrcTmp, float fMinVolume );
	virtual const Asura_Matrix_3x3* GetOrientation()	const { return &Asura_Maths::IdentityMatrix3x3; }

	void	Stop();
	u_int	GetNumOfSourceTemplates()	{ return m_uNumberOfSourceTemplates;	}

	float	GetBiggestBoneVolume ( const Asura_Shape_Instance* pxShapeInstance ) const;
	u_int	GetNumOfSourcesForThisVolume( float fVolume ) const;

//	virtual void SetVisible(bool bVisible) { m_bVisible = bVisible;}
//	virtual void SetVisiblityGuid(Asura_Guid guid) { m_VisibilityGuid = guid;}
//	bool m_bVisible;


	// Static create method
	static u_int Create();

protected:
	/* Classes */
	class SourceAndBoneID
	{
	public:
		Asura_PFX_Source* m_pxSource;
		int	m_iBoneID;
	};

	class SrcTmpAndVolume
	{
	public:
		Asura_Hash_ID m_uSourceTemplate;
		float m_fMinVolume;
	};

	/* Helper functions. */
	virtual void  Update(void);
	virtual void  Render(void);

	virtual u_int GetNumberOfSourcesRequired( const class Asura_Shape_Instance* pxShapeInstance ) const;
//	virtual Asura_Hash_ID GetSourceTemplateForVolume( float fSourceVolume ) const;
	virtual void  CreateSources( const class Asura_Shape_Instance* pxShapeInstance );

	void DestroyAllSources();

	/* Data. */	
	SrcTmpAndVolume* m_pxSourceTemplates; // stores the minimum volumes used for each template
	u_int m_uNumberOfSourceTemplates;
	
	SourceAndBoneID* m_pxSources;
	u_int m_uNumberOfSources;

	bool  m_bDieOut;
};
/* end of class AVP_PFX_Entity_Fire */


/***************/
/* End of File */
/***************/

#endif//__AVP_PFX_ENTITY_FIRE_H__
