/**
* MDL Control
* @version: 03-05-2005
* @author Joseph 'Pcjoe' Florencio
*/

#ifndef MDLCONTROL_H
#define MDLCONTROL_H

/*
* Model Control
*/
class CMDLControl
{
public:
	// Constructors
	CMDLControl();
	CMDLControl(int idx);

	// Get Studio Header
	studiohdr_t *getStudioHeader( void );

	// Get Sequence Descriptor
	mstudioseqdesc_t *getSequenceDesc( int iSeq );
	
	// Sequence Lookup
	int SequenceLookup( std::string strAnim );

	// FPS Lookup
	float fpsLookup( int iSeq );

	// Max Frames Lookup
	int numFramesLookup( int iSeq );

	// Current Sequence Num
	int getSequenceNum( void );

	// Interpol Sequence Num
	int getInterpolSequenceNum( void );

	/*
	* Accessors
	*/
	// Entity Index (negitive for temp ents)
	void setIndex( int idx ) { m_iIndex = idx; }
	int getIndex( void ) { return m_iIndex; }

	// Body part
	void setBodyPart( int iBody ) { m_iBodyPart = iBody; }
	int getBodyPart( void ) { return m_iBodyPart; }

	// Current Sequence
	void setSequence( std::string strSequence ) { m_strCurrentSequence = strSequence; }
	std::string getSequence( void ) { return m_strCurrentSequence; }

	// Interpolate to Sequence ( used with m_flInterpol )
	void setInterpolSequence( std::string strSequence ) { m_strInterpolSequence = strSequence; }
	std::string getInterpolSequence( void ) { return m_strInterpolSequence; }

	// Interpolate percent
	void setInterpolPercent( float flS ) { m_flInterpol = flS; }
	float getInterpolPercent( void ) { return m_flInterpol; }

	// Interpolate Frame
	void setInterpolFrame ( float flFrame ) { m_flInterpolFrame = flFrame; }
	float getInterpolFrame( void ) { return m_flInterpolFrame; }

	// Frame
	void setFrame( float flFrame ) { m_flFrame = flFrame; }
	float getFrame( void ) { return m_flFrame; }

	// Model Position
	void setPosition( vec3_t vecPos ) { m_vecPosition = vecPos; }
	vec3_t getPosition( void ) { return m_vecPosition; }

	// Model Angle
	void setAngle( vec3_t vecAng ) { m_vecAngles = vecAng; }
	vec3_t getAngle( void ) { return m_vecAngles; }

	// Model Name
	void setModel( std::string strName );
	void setModel( model_s *pModel ) { m_pModel = pModel; }
	model_s *getModel( void ) { return m_pModel; }

private:
	int		m_iIndex;
	int		m_iBodyPart;
	float	m_flInterpol;
	float	m_flFrame;
	float	m_flInterpolFrame;
	vec3_t	m_vecPosition;
	vec3_t	m_vecAngles;
	std::string	m_strCurrentSequence;
	std::string	m_strInterpolSequence;
	model_s	*m_pModel;
};

/*
* Model Control Manager
*/
class CModelControlManager
{
public:
	// Constructor
	CModelControlManager();

	// Find model control
	std::list<CMDLControl>::iterator findModelControlIter( int idx );
	CMDLControl *findModelControl( int idx );

	// Add model control
	CMDLControl *addModelControl( int idx );

	// Remove model control
	void removeModelControl( int idx );

	/*
	* Accessors
	*/
	// Get Model Control List
	std::list<CMDLControl> *getModelControlList( void ) { return (&m_ModelControls); }

private:
	std::list<CMDLControl>	m_ModelControls;
};

#endif