class stealthAlertGameController extends inkHUDGameController
{
	private editable var m_label : inkTextRef;
	private editable var m_icon : inkImageRef;
	private editable var m_indicator_01 : inkImageRef;
	private editable var m_indicator_02 : inkImageRef;
	private editable var m_indicator_03 : inkImageRef;
	private editable var m_fluff_01 : inkWidgetRef;
	private editable var m_fluff_02 : inkWidgetRef;
	private editable var m_fluff_03 : inkWidgetRef;
	private editable var m_fluff_04 : inkWidgetRef;
	private var m_root : weak< inkWidget >;
	private var m_securityBlackBoardID : CallbackHandle;
	private var m_playerBlackboardID : Uint32;
	private var m_blackboard : weak< IBlackboard >;
	private var m_playerPuppet : weak< GameObject >;
	private var m_animationProxy : inkAnimProxy;

	protected event OnPlayerAttach( playerPuppet : GameObject )
	{
		m_playerPuppet = playerPuppet;
		m_blackboard = GetPSMBlackboard( m_playerPuppet );
		m_securityBlackBoardID = m_blackboard.RegisterListenerVariant( GetAllBlackboardDefs().PlayerStateMachine.SecurityZoneData, this, 'OnSecurityDataChange' );
		m_root = GetRootWidget();
		inkWidgetRef.SetVisible( m_fluff_01, false );
		inkWidgetRef.SetVisible( m_fluff_02, false );
		inkWidgetRef.SetVisible( m_fluff_03, false );
		inkWidgetRef.SetVisible( m_fluff_04, false );
		m_root.SetState( 'Public' );
		m_root.SetVisible( false );
	}

	protected event OnPlayerDetach( playerPuppet : GameObject )
	{
		m_blackboard.UnregisterListenerVariant( GetAllBlackboardDefs().PlayerStateMachine.SecurityZoneData, m_securityBlackBoardID );
	}

	protected event OnSecurityDataChange( arg : Variant )
	{
		var securityZoneData : SecurityAreaData;
		securityZoneData = ( ( SecurityAreaData )arg );
		inkWidgetRef.SetVisible( m_fluff_01, false );
		inkWidgetRef.SetVisible( m_fluff_02, false );
		inkWidgetRef.SetVisible( m_fluff_03, false );
		inkWidgetRef.SetVisible( m_fluff_04, false );
		switch( securityZoneData.securityAreaType )
		{
			case ESecurityAreaType.DANGEROUS:
				if( m_root.GetState() == 'Dangerous' )
				{
					break;
				}
			inkTextRef.SetText( m_label, "UI-Cyberpunk-Widgets-DANGER_ZONE" );
			m_root.SetState( 'Dangerous' );
			inkWidgetRef.SetVisible( m_fluff_01, true );
			inkImageRef.SetTexturePart( m_icon, 'danger_icon_zone' );
			inkImageRef.SetTexturePart( m_indicator_01, 'indicator_on' );
			inkImageRef.SetTexturePart( m_indicator_02, 'indicator_on' );
			inkImageRef.SetTexturePart( m_indicator_03, 'indicator_on' );
			PlayAnimation( 'outro_danger' );
			PlaySound( 'StealthTrespassingPopup', 'OnOpen' );
			break;
			case ESecurityAreaType.RESTRICTED:
				if( m_root.GetState() == 'Restricted' )
				{
					break;
				}
			inkTextRef.SetText( m_label, "UI-Cyberpunk-Widgets-RESTRICTED_ZONE" );
			m_root.SetState( 'Restricted' );
			inkWidgetRef.SetVisible( m_fluff_02, true );
			inkImageRef.SetTexturePart( m_icon, 'estricted_icon_zone' );
			inkImageRef.SetTexturePart( m_indicator_01, 'indicator_on' );
			inkImageRef.SetTexturePart( m_indicator_02, 'indicator_on' );
			inkImageRef.SetTexturePart( m_indicator_03, 'indicator_off' );
			PlayAnimation( 'outro_restricted' );
			PlaySound( 'StealthTrespassingPopup', 'OnOpen' );
			break;
			default:
				if( m_root.GetState() == 'Public' )
				{
					break;
				}
			inkTextRef.SetText( m_label, "UI-Cyberpunk-Widgets-PUBLIC_ZONE" );
			m_root.SetState( 'Public' );
			inkWidgetRef.SetVisible( m_fluff_03, true );
			inkImageRef.SetTexturePart( m_icon, 'public_icon_zone' );
			inkImageRef.SetTexturePart( m_indicator_01, 'indicator_on' );
			inkImageRef.SetTexturePart( m_indicator_02, 'indicator_off' );
			inkImageRef.SetTexturePart( m_indicator_03, 'indicator_off' );
			PlayAnimation( 'outro_public' );
			PlaySound( 'StealthTrespassingPopup', 'OnOpen' );
			break;
		}
	}

	private function PlayAnimation( animName : CName )
	{
		m_root.SetVisible( true );
		m_animationProxy = PlayLibraryAnimation( animName );
		m_animationProxy.RegisterToCallback( inkanimEventType.OnFinish, this, 'OnOutroAnimFinished' );
	}

	protected event OnOutroAnimFinished( anim : inkAnimProxy )
	{
		m_root.SetVisible( false );
	}

}

