
#include "scenesystem/sceneanimatableobject.h"

delegate SboxAnimationEventCallback;
delegate SboxAnimTagEventCallback;
delegate SboxAnimGraphChangedCallback;

[Handle:Sandbox.SceneModel]
native class CSceneAnimatableObject as NativeEngine.CSceneAnimatableObject : CSceneObject
{
	void SetWorldSpaceRenderBoneTransform( int nBoneIndex, Transform pRenderWorldTransform );
	Transform GetWorldSpaceRenderBoneTransform( int nBoneIndex );
	Transform GetWorldSpaceRenderBoneTransform( string boneName );
	Transform GetWorldSpaceRenderBonePreviousTransform( int nBoneIndex );
	Transform GetWorldSpaceRenderBonePreviousTransform( string boneName );
	Transform GetLocalSpaceRenderBoneTransform( int nBoneIndex );
	Transform GetLocalSpaceRenderBoneTransform( string boneName );
	Transform GetWorldSpaceAnimationTransform( int nBoneIndex );

	void Update( float dt );
	void MergeFrom( CSceneAnimatableObject other );
	void SetBindPose();
	void CalculateWorldSpaceBones();
	void FinishUpdate();

	void ResetGraphParameters();

	Transform GetParentSpaceBone( int index );
	void SetParentSpaceBone( int index, Transform tx );

	void InitAnimGraph( SboxAnimGraphChangedCallback pAnimGraphChangedCallback );
	void SetAnimGraph( string graphName );

	void SetAnimGraph( HAnimationGraph hGraph );
	HAnimationGraph GetAnimGraph();

	void SBox_SetFlexOverride( StringToken name, float flWeight );
	void SBox_SetFlexOverride( int flexId, float flWeight );
	float SBox_GetFlexOverride( int flexId );
	float SBox_GetFlexOverride( StringToken name );
	void SBox_ClearFlexOverride();

	void DirectPlayback_PlaySequence( string pSequenceName );
	void DirectPlayback_PlaySequence( string pSequenceName, Vector3 vTargetPos, float flFacingHeading, float flInterpTime );
	void DirectPlayback_CancelSequence();
	float DirectPlayback_GetSequenceCycle();
	string DirectPlayback_GetSequence();
	void DirectPlayback_SetSequenceStartTime( float flStartTime );
	float DirectPlayback_GetSequenceDuration();

	bool SBox_GetAttachment( StringToken name, bool worldspace, cref out Transform tx );

	void SetShouldUseAnimGraph( bool bEnabled );
	bool GetShouldUseAnimGraph();

	string GetSequence();
	void SetSequence( string pSequenceName );

	float GetSequenceDuration();

	float GetSequenceCycle();
	void SetSequenceCycle( float flCycle );

	void SetSequenceLooping( bool bLooping );
	bool IsSequenceFinished();
	void SetSequenceBlending( bool bBlending );

	float GetPlaybackRate();
	void SetPlaybackRate( float flPlaybackRate );

	int GetParameterInt( string name );
	Float GetParameterFloat( string name );
	Vector3 GetParameterVector3( string name );
	Rotation GetParameterRotation( string name );

	//
	// Anim Events
	//
	int PendingAnimationEvents();
	void RunAnimationEvents( SboxAnimationEventCallback callback );
	void DispatchTagEvents( SboxAnimTagEventCallback callback );

	//
	// Bone Overrides
	//
	void ClearPhysicsBones();
	void SetPhysicsBone( ushort bone, Transform transform );

	Transform GetRootMotion();

	float m_flDeltaTime;

	inline bool HasPhysicsBones()
	{
		return self->m_PhysicsBoneTransform.Count() > 0;
	}

	IAnimParameterInstance GetAnimParameter( string name );
	IAnimParameterInstance GetAnimParameter( int index );

	BBox m_worldBounds;
	BBox m_localBounds;
}

native class IAnimParameterInstance as NativeEngine.IAnimParameterInstance
{
	void SetValue( bool val );
	void SetValue( int val );
	void SetValue( float val );
	void SetValue( Vector3 val );
	void SetValue( Rotation val );
	inline void SetEnumValue( int val )
	{
		self->SetValue( CAnimEnum( (AnimEnumValue_t)val ) );
	}

	CUtlString GetName();
	bool IsAutoReset();

	NativeEngine.AnimParamType GetParameterType();
}