class hudRecordingController extends inkHUDGameController
{
	private var m_root : weak< inkCompoundWidget >;
	private var anim_intro : inkAnimProxy;
	private var anim_outro : inkAnimProxy;
	private var anim_loop : inkAnimProxy;
	private var option_intro : inkAnimOptions;
	private var option_loop : inkAnimOptions;
	private var option_outro : inkAnimOptions;
	private var m_factListener : Uint32;

	protected event OnInitialize()
	{
		var ownerObject : GameObject;
		ownerObject = ( ( GameObject )( GetOwnerEntity() ) );
		m_factListener = GameInstance.GetQuestsSystem( ownerObject.GetGame() ).RegisterListener( 'sq030_braindance_active', this, 'OnFact' );
		OnFact( GameInstance.GetQuestsSystem( ownerObject.GetGame() ).GetFact( 'sq030_braindance_active' ) );
		m_root = ( ( inkCompoundWidget )( GetRootWidget() ) );
		option_intro.fromMarker = 'start_intro';
		option_intro.toMarker = 'end_intro_start_loop';
		option_loop.fromMarker = 'end_intro_start_loop';
		option_loop.toMarker = 'end_loop_start_outro';
		option_loop.loopType = inkanimLoopType.Cycle;
		option_loop.loopInfinite = true;
		option_loop.loopCounter = 99999999;
		option_outro.fromMarker = 'end_loop_start_outro';
		option_outro.toMarker = 'end_outro';
		m_root.SetVisible( false );
	}

	protected event OnUninitialize()
	{
		var ownerObject : GameObject;
		ownerObject = ( ( GameObject )( GetOwnerEntity() ) );
		GameInstance.GetQuestsSystem( ownerObject.GetGame() ).UnregisterListener( 'sq030_braindance_active', m_factListener );
	}

	public function OnFact( val : Int32 )
	{
		if( val > 0 )
		{
			m_root.SetVisible( true );
			anim_loop = PlayLibraryAnimation( 'start_recording', option_loop );
		}
		else
		{
			OnOutroEnded();
		}
	}

	public function OnOutroEnded()
	{
		anim_loop.Stop();
		anim_outro.Stop();
		anim_intro.Stop();
		m_root.SetVisible( false );
	}

}

