/**
* FX Event
* @version: 02-28-2005
* @author Joseph 'Pcjoe' Florencio
*/

#ifndef FXEVENT_H
#define FXEVENT_H

#include "fxobject.h"
#include "fxpathsystem.h"

class CFXEvent
{
public:
	// Constructor / Destructor
	CFXEvent();
	~CFXEvent();

	// Get Next ID
	int getNextID( void );

	// Find object by ID
	CFXObject *getObjectByIndex( int idx );

	// Add object
	void addObject( CFXObject *pObj, float flStart, float flEnd );

	// Think
	void Think( float flTime );

	// Reset Triggers
	void resetTriggers( void );

	// Render all objects
	void Render( void );

	// Get base position/angle ( taking dynamic/static into account
	vec3_t getBasePosition( void );
	vec3_t getBaseAngle( void );

	// Make local position/rotation final ( adjust to base angles, and add base position )
	vec3_t makePosFinal( vec3_t vecPos );
	CQuaternion makeAngFinal( CQuaternion qAngle );

	// Get camera object
	CFXObjectCamera *getCameraObject( void );

	// Remove Object
	void removeObject( int idx );
	void removeObject( CFXObject *pRemove );

	// Read XML
	virtual void readXML( TiXmlElement *pElement );

	// Write XML
	virtual TiXmlElement *writeXML( void );

	/*
	* Accessors
	*/
	// Path System
	CPathSystem	*getPathSystem( void ) { return &m_PathSystem; }

	// Developer Event
	void setDeveloperEvent( bool bDeveloper ) { m_bDeveloperEvent = bDeveloper; }
	bool isDeveloperEvent( void ) { return m_bDeveloperEvent; }

	// Looping
	void setLooping( bool bLooping ) { m_bLooping = bLooping; }
	bool isLooping( void ) { return m_bLooping; }

	// Time
	void setTime( float flTime ) { m_flTime = flTime; }
	float getTime( void ) { return m_flTime; }

	// Start Time
	void setStartTime( float flTime ) { m_flStartTime = flTime; }
	float getStartTime( void ) { return m_flStartTime; }

	// End Time
	void setEndTime( float flTime ) { m_flEndTime = flTime; }
	float getEndTime( void ) { return m_flEndTime; }

	// set Static base ( both angle and position )
	void setStaticBase( bool isStatic ) { setBaseAngleStatic(isStatic); setBasePositionStatic(isStatic); }

	// Is base angle/position static
	void setBaseAngleStatic( bool isStatic ) { m_bBaseAngStatic = isStatic; }
	bool isBaseAngleStatic( void ) { return m_bBaseAngStatic; }
	void setBasePositionStatic( bool isStatic ) { m_bBasePosStatic = isStatic; }
	bool isBasePositionStatic( void ) { return m_bBasePosStatic; }

	// Base position
	void setBasePositionStatic( vec3_t vecPos ) { m_vecBasePosition = vecPos; }
	vec3_t getBasePositionStatic( void ) { return m_vecBasePosition; }

	// Base Angle
	void setBaseAngleStatic( vec3_t vecRot ) { m_vecBaseAngle = vecRot; }
	vec3_t getBaseAngleStatic( void ) { return m_vecBaseAngle; }

	// Dynamic base reference
	void setDynamicBaseReference( int idx ) { m_iBaseEntIdx = idx; }
	int getDynamicBaseReference( void ) { return m_iBaseEntIdx; }

	// Owned by Index, 0 if none
	void setIndex( int idx ) { m_iIndex = idx; }
	int getIndex( void ) { return m_iIndex; }

	// FX Objects
	std::list<CFXObject*> *getFXObjects( void ) { return &m_FXObjects; }
private:
	// Path System
	CPathSystem		m_PathSystem;
	// List of objects in this event
	std::list<CFXObject*>	m_FXObjects;

	// Is Developer Event
	bool		m_bDeveloperEvent;

	// Looping
	bool		m_bLooping;

	// Time
	float		m_flTime;
	float		m_flStartTime;
	float		m_flEndTime;

	// Dynamic base reference
	int			m_iBaseEntIdx;

	// Owned by index, 0 if none
	int			m_iIndex;

	// Base angle
	bool		m_bBaseAngStatic;
	vec3_t		m_vecBaseAngle;

	// Base position
	bool		m_bBasePosStatic;
	vec3_t		m_vecBasePosition;
};

#endif