class CrosshairGameController_Launcher extends gameuiCrosshairBaseGameController
{
	private var m_weaponBBID : CallbackHandle;
	private var m_animationProxy : inkAnimProxy;
	private editable var m_Cori_S : inkCanvasRef;
	private editable var m_Cori_M : inkCanvasRef;
	private var m_rightStickX : Float;
	private var m_rightStickY : Float;
	private var m_currentState : gamePSMLeftHandCyberware;

	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 event OnPSMLeftHandCyberwareStateChanged( value : Int32 )
	{
		UpdateCrosshairState( ( ( gamePSMLeftHandCyberware )( value ) ) );
	}

	protected event OnPlayerAttach( playerPuppet : GameObject )
	{
		var playerSMBB : IBlackboard;
		playerSMBB = GetPSMBlackboard( playerPuppet );
		m_weaponBBID = playerSMBB.RegisterDelayedListenerInt( GetAllBlackboardDefs().PlayerStateMachine.LeftHandCyberware, this, 'OnPSMLeftHandCyberwareStateChanged' );
		OnPSMLeftHandCyberwareStateChanged( playerSMBB.GetInt( GetAllBlackboardDefs().PlayerStateMachine.LeftHandCyberware ) );
		super.OnPreIntro();
	}

	protected event OnPlayerDetach( playerPuppet : GameObject )
	{
		var playerSMBB : IBlackboard;
		if( m_weaponBBID )
		{
			playerSMBB = GetPSMBlackboard( playerPuppet );
			playerSMBB.UnregisterDelayedListener( GetAllBlackboardDefs().PlayerStateMachine.LeftHandCyberware, m_weaponBBID );
		}
	}

	private function UpdateCrosshairState( state : gamePSMLeftHandCyberware )
	{
		if( state == m_currentState )
		{
			return;
		}
		m_currentState = state;
		switch( m_currentState )
		{
			case gamePSMLeftHandCyberware.QuickAction:
				OnState_Equip();
			OnState_QuickLaunch();
			break;
			case gamePSMLeftHandCyberware.Charge:
				OnState_Equip();
			OnState_Aim();
			break;
			case gamePSMLeftHandCyberware.ChargeAction:
				OnState_Equip();
			OnState_ChargeLaunch();
			break;
			case gamePSMLeftHandCyberware.Safe:
				OnState_Safe();
			break;
			case gamePSMLeftHandCyberware.Unequip:
				OnState_Unequip();
			break;
			default:
				break;
		}
	}

	protected function OnState_Equip()
	{
		m_rootWidget.SetVisible( true );
		PlayLibraryAnimation( 'go_to_equip_state' );
	}

	protected function OnState_QuickLaunch()
	{
		PlayLibraryAnimation( 'go_to_quick_launch_state' );
	}

	protected override function OnState_Aim()
	{
		var hasReilcPerk : Bool;
		hasReilcPerk = RPGManager.HasStatFlag( GetPlayerControlledObject(), gamedataStatType.CanUseNewMeleewareAttackSpyTree );
		if( hasReilcPerk )
		{
			PlayLibraryAnimation( 'go_to_charge_state100' );
		}
		else
		{
			PlayLibraryAnimation( 'go_to_charge_state75' );
		}
	}

	protected function OnState_ChargeLaunch()
	{
		PlayLibraryAnimation( 'go_to_charge_launch_state' );
	}

	protected function OnState_Unequip()
	{
		m_rootWidget.SetVisible( false );
	}

}

