class hudSniperNestController extends inkHUDGameController
{
	private var m_psmBlackboard : weak< IBlackboard >;
	private var m_tcsBlackboard : weak< IBlackboard >;
	private var m_PSM_BBID : CallbackHandle;
	private var m_tcs_BBID : CallbackHandle;
	private var m_deviceChain_BBID : CallbackHandle;
	private var m_root : weak< inkCompoundWidget >;
	private var m_controlledObjectRef : weak< GameObject >;
	private var m_alpha_fadein : inkAnimDef;
	private var m_AnimProxy : inkAnimProxy;
	private var m_AnimOptions : inkAnimOptions;
	private var m_ownerObject : weak< GameObject >;
	private var m_maxZoomLevel : Int32;

	protected event OnInitialize()
	{
		var delayInitialize : DelayedHUDInitializeEvent;
		var alphaInterpolator : inkAnimTransparency;
		m_root = ( ( inkCompoundWidget )( GetRootWidget() ) );
		m_ownerObject = ( ( GameObject )( GetOwnerEntity() ) );
		m_tcsBlackboard = GetBlackboardSystem().Get( GetAllBlackboardDefs().DeviceTakeControl );
		if( m_tcsBlackboard )
		{
			m_tcs_BBID = m_tcsBlackboard.RegisterDelayedListenerEntityID( GetAllBlackboardDefs().DeviceTakeControl.ActiveDevice, this, 'OnChangeControlledDevice' );
			m_deviceChain_BBID = m_tcsBlackboard.RegisterListenerVariant( GetAllBlackboardDefs().DeviceTakeControl.DevicesChain, this, 'OnTakeControllOverDevice' );
			OnChangeControlledDevice( m_tcsBlackboard.GetEntityID( GetAllBlackboardDefs().DeviceTakeControl.ActiveDevice ) );
		}
		m_alpha_fadein = new inkAnimDef;
		alphaInterpolator = new inkAnimTransparency;
		alphaInterpolator.SetDuration( 1.0 );
		alphaInterpolator.SetStartTransparency( 1.0 );
		alphaInterpolator.SetEndTransparency( 1.0 );
		alphaInterpolator.SetType( inkanimInterpolationType.Linear );
		alphaInterpolator.SetMode( inkanimInterpolationMode.EasyIn );
		m_alpha_fadein.AddInterpolator( alphaInterpolator );
		m_AnimOptions.playReversed = false;
		m_AnimOptions.executionDelay = 0.0;
		m_AnimOptions.loopType = inkanimLoopType.Cycle;
		m_AnimOptions.loopInfinite = true;
		m_AnimProxy = m_root.PlayAnimationWithOptions( m_alpha_fadein, m_AnimOptions );
		m_AnimProxy.RegisterToCallback( inkanimEventType.OnEndLoop, this, 'OnEndLoop' );
		GetPlayerControlledObject().RegisterInputListener( this );
		delayInitialize = new DelayedHUDInitializeEvent;
		GameInstance.GetDelaySystem( GetPlayerControlledObject().GetGame() ).DelayEvent( GetPlayerControlledObject(), delayInitialize, 0.1 );
		GameInstance.GetAudioSystem( GetPlayerControlledObject().GetGame() ).Play( 'global_menu_hacking_close' );
		GameInstance.GetAudioSystem( GetPlayerControlledObject().GetGame() ).Play( 'ui_hacking_close' );
	}

	protected event OnUninitialize()
	{
		m_tcsBlackboard.UnregisterListenerEntityID( GetAllBlackboardDefs().DeviceTakeControl.ActiveDevice, m_tcs_BBID );
		m_tcsBlackboard.UnregisterListenerVariant( GetAllBlackboardDefs().DeviceTakeControl.DevicesChain, m_deviceChain_BBID );
		m_AnimProxy.UnregisterFromCallback( inkanimEventType.OnEndLoop, this, 'OnEndLoop' );
		m_AnimProxy.Stop();
		TakeOverControlSystem.CreateInputHint( GetPlayerControlledObject().GetGame(), false );
	}

	protected event OnChangeControlledDevice( value : EntityID )
	{
		if( m_ownerObject )
		{
			m_controlledObjectRef = m_ownerObject.GetTakeOverControlSystem().GetControlledObject();
			if( m_controlledObjectRef.GetPSClassName() == 'SniperNestControllerPS' )
			{
				m_root.SetVisible( true );
			}
			else
			{
				m_root.SetVisible( false );
			}
		}
	}

	protected event OnDelayedHUDInitializeEvent( evt : DelayedHUDInitializeEvent )
	{
		TakeOverControlSystem.CreateInputHint( GetPlayerControlledObject().GetGame(), true );
	}

}

