class CrosshairGameController_NoWeapon extends gameuiCrosshairBaseGameController
{
	private editable var m_AimDownSightContainer : inkCompoundRef;
	private editable var m_ZoomMovingContainer : inkCompoundRef;
	private editable var m_ZoomNumber : inkTextRef;
	private editable var m_ZoomNumberR : inkTextRef;
	private editable var m_DistanceImageRuler : inkImageRef;
	private editable var m_ZoomMoveBracketL : inkImageRef;
	private editable var m_ZoomMoveBracketR : inkImageRef;
	private var m_ZoomLevelString : String;
	private var m_PlayerSMBB : weak< IBlackboard >;
	private var m_ZoomLevelBBID : CallbackHandle;
	private var m_sceneTierBlackboardId : CallbackHandle;
	private var m_sceneTier : gamePSMHighLevel;
	default m_sceneTier = gamePSMHighLevel.Default;
	private var zoomUpAnim : inkAnimProxy;
	private var animLockOn : inkAnimProxy;
	private var zoomDownAnim : inkAnimProxy;
	private var animLockOff : inkAnimProxy;
	private var zoomShowAnim : inkAnimProxy;
	private var zoomHideAnim : inkAnimProxy;
	private var argZoomBuffered : Float;

	protected event OnPlayerAttach( playerPuppet : GameObject )
	{
		m_PlayerSMBB = GetPSMBlackboard( playerPuppet );
		m_ZoomLevelBBID = m_PlayerSMBB.RegisterDelayedListenerFloat( GetAllBlackboardDefs().PlayerStateMachine.ZoomLevel, this, 'OnZoomLevel' );
		m_sceneTierBlackboardId = m_PlayerSMBB.RegisterDelayedListenerInt( GetAllBlackboardDefs().PlayerStateMachine.SceneTier, this, 'OnPSMSceneTierChanged' );
		super.OnPlayerAttach( playerPuppet );
	}

	protected event OnPlayerDetach( playerPuppet : GameObject )
	{
		m_PlayerSMBB.UnregisterDelayedListener( GetAllBlackboardDefs().PlayerStateMachine.ZoomLevel, m_ZoomLevelBBID );
		m_PlayerSMBB.UnregisterDelayedListener( GetAllBlackboardDefs().PlayerStateMachine.SceneTier, m_sceneTierBlackboardId );
		super.OnPlayerDetach( playerPuppet );
	}

	public override function GetIntroAnimation( firstEquip : Bool ) : inkAnimProxy
	{
		var anim : inkAnimDef;
		var alphaInterpolator : inkAnimTransparency;
		anim = new inkAnimDef;
		alphaInterpolator = new inkAnimTransparency;
		alphaInterpolator.SetStartTransparency( 0.0 );
		alphaInterpolator.SetEndTransparency( 1.0 );
		alphaInterpolator.SetDuration( 0.25 );
		alphaInterpolator.SetType( inkanimInterpolationType.Linear );
		alphaInterpolator.SetMode( inkanimInterpolationMode.EasyIn );
		anim.AddInterpolator( alphaInterpolator );
		return m_rootWidget.PlayAnimation( anim );
	}

	public override function GetOutroAnimation() : inkAnimProxy
	{
		var anim : inkAnimDef;
		var alphaInterpolator : inkAnimTransparency;
		anim = new inkAnimDef;
		alphaInterpolator = new inkAnimTransparency;
		alphaInterpolator.SetStartTransparency( 1.0 );
		alphaInterpolator.SetEndTransparency( 0.0 );
		alphaInterpolator.SetDuration( 0.25 );
		alphaInterpolator.SetType( inkanimInterpolationType.Linear );
		alphaInterpolator.SetMode( inkanimInterpolationMode.EasyIn );
		anim.AddInterpolator( alphaInterpolator );
		return m_rootWidget.PlayAnimation( anim );
	}

	protected override function OnState_HipFire()
	{
		m_rootWidget.SetVisible( true );
		zoomHideAnim = PlayLibraryAnimation( 'hide' );
		inkCompoundRef.SetVisible( m_AimDownSightContainer, false );
	}

	protected override function OnState_Aim()
	{
		inkCompoundRef.SetVisible( m_AimDownSightContainer, true );
		zoomShowAnim = PlayLibraryAnimation( 'show' );
	}

	protected override function OnState_Sprint()
	{
		m_rootWidget.SetVisible( false );
	}

	protected override function OnState_Scanning()
	{
		m_rootWidget.SetVisible( false );
	}

	protected override function OnState_Safe()
	{
		m_rootWidget.SetVisible( ( m_sceneTier == gamePSMHighLevel.Default || m_sceneTier == gamePSMHighLevel.SceneTier1 ) || m_sceneTier == gamePSMHighLevel.SceneTier2 );
	}

	protected event OnZoomLevel( argZoom : Float )
	{
		var distanceVector : Vector2;
		var distanceMargin : inkMargin;
		var origRulerSize : Float;
		var pixelsFromBottom : Float;
		distanceVector = inkImageRef.GetDesiredSize( m_DistanceImageRuler );
		distanceMargin = inkImageRef.GetMargin( m_DistanceImageRuler );
		origRulerSize = distanceVector.Y + distanceMargin.bottom;
		pixelsFromBottom = ( ( argZoom == 1.0 ) ? ( 0.0 ) : ( ( argZoom * origRulerSize ) / 4.0 ) );
		inkCompoundRef.SetMargin( m_ZoomMovingContainer, inkMargin( 0.0, 0.0, 0.0, MinF( origRulerSize, pixelsFromBottom ) ) );
		if( ( argZoom * 2.0 ) > 2.0 )
		{
			inkTextRef.SetText( m_ZoomNumber, FloatToStringPrec( MaxF( 1.0, argZoom * 2.0 ), 1 ) + "x" );
			inkTextRef.SetText( m_ZoomNumberR, FloatToStringPrec( MaxF( 1.0, argZoom * 2.0 ), 1 ) + "x" );
		}
		else
		{
			inkTextRef.SetText( m_ZoomNumber, FloatToStringPrec( MaxF( 1.0, ( argZoom * 2.0 ) - 1.0 ), 1 ) + "x" );
			inkTextRef.SetText( m_ZoomNumberR, FloatToStringPrec( MaxF( 1.0, ( argZoom * 2.0 ) - 1.0 ), 1 ) + "x" );
		}
		inkImageRef.SetMargin( m_ZoomMoveBracketL, inkMargin( 0.0, 0.0, 560.0 - ( argZoom * 60.0 ), 0.0 ) );
		inkImageRef.SetMargin( m_ZoomMoveBracketR, inkMargin( 560.0 - ( argZoom * 60.0 ), 0.0, 0.0, 0.0 ) );
		if( argZoom < argZoomBuffered )
		{
			if( ( ( !( zoomDownAnim ) || !( zoomDownAnim.IsPlaying() ) ) && ( !( zoomUpAnim ) || !( zoomUpAnim.IsPlaying() ) ) ) && !( zoomShowAnim.IsPlaying() ) )
			{
				zoomDownAnim = PlayLibraryAnimation( 'zoomDown' );
			}
		}
		if( argZoom > argZoomBuffered )
		{
			if( ( ( !( zoomDownAnim ) || !( zoomDownAnim.IsPlaying() ) ) && ( !( zoomUpAnim ) || !( zoomUpAnim.IsPlaying() ) ) ) && !( zoomHideAnim.IsPlaying() ) )
			{
				zoomUpAnim = PlayLibraryAnimation( 'zoomUp' );
			}
		}
		argZoomBuffered = argZoom;
	}

	protected event OnPSMSceneTierChanged( value : Int32 )
	{
		var tier : gamePSMHighLevel;
		tier = ( ( gamePSMHighLevel )( value ) );
		if( tier != m_sceneTier )
		{
			m_sceneTier = tier;
			UpdateCrosshairState();
		}
	}

}

