class ProgressBarAnimationChunkController extends inkLogicController
{
	private editable var m_rootCanvas : inkWidgetRef;
	private editable var m_barCanvas : inkWidgetRef;
	private var m_hitAnim : inkAnimProxy;
	private var m_fullbarSize : Float;
	private var m_isNegative : Bool;

	public function SetAnimation( widght : Float, height : Float, fullbarSize : Float, isNegative : Bool )
	{
		var animName : CName;
		m_fullbarSize = fullbarSize;
		m_isNegative = isNegative;
		inkWidgetRef.SetSize( m_rootCanvas, Vector2( widght, height ) );
		inkWidgetRef.SetSize( m_barCanvas, Vector2( widght, height ) );
		GetRootWidget().SetMargin( fullbarSize, 0.0, 0.0, 0.0 );
		inkWidgetRef.SetVisible( m_rootCanvas, true );
		animName = ( ( isNegative ) ? ( 'hit_chunk_with_bracket' ) : ( 'heal_chunk_with_bracket' ) );
		if( m_hitAnim.IsPlaying() )
		{
			m_hitAnim.Stop();
			OnAnimationEnd( m_hitAnim );
		}
		m_hitAnim = PlayLibraryAnimation( animName );
		m_hitAnim.RegisterToCallback( inkanimEventType.OnFinish, this, 'OnAnimationEnd' );
	}

	protected event OnAnimationEnd( e : inkAnimProxy )
	{
		var evt : OnProgressBarAnimFinish;
		evt = new OnProgressBarAnimFinish;
		evt.FullbarSize = m_fullbarSize;
		evt.IsNegative = m_isNegative;
		QueueEvent( evt );
		inkWidgetRef.SetVisible( m_rootCanvas, false );
	}

	public function IsProgressAnimationPlaying() : Bool
	{
		return m_hitAnim.IsPlaying();
	}

}

class OnProgressBarAnimFinish extends Event
{
	var FullbarSize : Float;
	var IsNegative : Bool;
}

