//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "clientsideeffects.h"

#include "materialsystem/IMaterial.h"
#include "materialsystem/IMaterialSystem.h"

#ifndef FX_QUAD2_H
#define FX_QUAD2_H
#ifdef _WIN32
#pragma once
#endif

// Flags
#define	FXQUAD_BIAS_SCALE	0x0001	//Bias the scale's interpolation function
#define	FXQUAD_BIAS_ALPHA	0x0002	//Bias the alpha's interpolation function

struct FXQuadData2_t
{
	FXQuadData2_t( void )
	{
		m_uiFlags		= 0;
	}

	void SetFlags( unsigned int flags )			{ m_uiFlags |= flags; }
	void SetOrigin( const Vector &origin )		{ m_vecOrigin = origin; }
	void SetNormal( const Vector &normal )		{ m_vecNormal = normal; }
	void SetScale( float start )		{ m_flScale = start; }
	void SetAlpha( float alpha )				{ m_flAlpha = alpha; }
	void SetColor( float r, float g, float b )	{ m_Color = Vector( r, g, b ); }
	void SetYaw( float yaw, float delta = 0.0f ){ m_flYaw = yaw; m_flDeltaYaw = delta; }
	void SetFollowEntity( C_BaseEntity *pEnt )	{ m_hEntFollow = pEnt; }
	void SetMoving( bool moving ){ m_bMoving = moving; }

	void SetMaterial( const char *shader )	
	{ 
		m_pMaterial = materials->FindMaterial( shader, TEXTURE_GROUP_CLIENT_EFFECTS );

		if ( m_pMaterial != NULL )
		{
			m_pMaterial->IncrementReferenceCount();
		}
	}

	unsigned int	m_uiFlags;
	IMaterial		*m_pMaterial;
	Vector			m_vecOrigin;
	Vector			m_vecNormal;
	float			m_flScale;
	float			m_flAlpha;
	Vector			m_Color;
	float			m_flYaw;
	float			m_flDeltaYaw;
	EHANDLE			m_hEntFollow;
	bool			m_bMoving;
	
};

class CFXQuad2 : public CClientSideEffect
{
public:

	CFXQuad2( const FXQuadData2_t &data );
	
	~CFXQuad2( void );

	virtual void	Draw( double frametime );
	virtual bool	IsActive( void );
	virtual void	Destroy( void );
	virtual	void	Update( double frametime );

	virtual void	DeActivate();
	virtual C_BaseEntity *GetFollowEntity( void ) { return m_FXData.m_hEntFollow.Get(); };
private:
	bool m_bActiveInternal;

protected:

	FXQuadData2_t	m_FXData;
};

#endif // FX_QUAD2_H
