class BaseCrosshairState extends DefaultTransition
{

	protected function GetCrosshairStateEnumValue() : gamePSMCrosshairStates
	{
		var stateName : CName;
		stateName = GetStateName();
		switch( stateName )
		{
			case 'safe':
				return gamePSMCrosshairStates.Safe;
			case 'scanning':
				return gamePSMCrosshairStates.Scanning;
			case 'grenadeCharging':
				return gamePSMCrosshairStates.GrenadeCharging;
			case 'aim':
				return gamePSMCrosshairStates.Aim;
			case 'reload':
				return gamePSMCrosshairStates.Reload;
			case 'reloadDriverCombatMountedWeapons':
				return gamePSMCrosshairStates.ReloadDriverCombatMountedWeapons;
			case 'sprint':
				return gamePSMCrosshairStates.HipFire;
			case 'hipfire':
				return gamePSMCrosshairStates.HipFire;
			case 'leftHandCyberware':
				return gamePSMCrosshairStates.LeftHandCyberware;
			case 'quickHack':
				return gamePSMCrosshairStates.QuickHack;
		}
		return gamePSMCrosshairStates.Default;
	}

}

class BaseCrosshairStateEvents extends BaseCrosshairState
{

	protected export virtual function OnEnter( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		SetBlackboardIntVariable( scriptInterface, GetAllBlackboardDefs().PlayerStateMachine.Crosshair, ( ( Int32 )( GetCrosshairStateEnumValue() ) ) );
	}

}

class SafeCrosshairStateDecisions extends BaseCrosshairState
{

	protected export const virtual function EnterCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		if( IsInSafeZone( scriptInterface ) )
		{
			return true;
		}
		if( IsInSafeSceneTier( scriptInterface ) )
		{
			return true;
		}
		if( ( ( PlayerPuppet )( scriptInterface.executionOwner ) ).IsAimingAtFriendly() && stateContext.IsStateActive( 'UpperBody', 'singleWield' ) )
		{
			return true;
		}
		if( GetHudManager( scriptInterface ).IsQuickHackPanelOpened() )
		{
			return true;
		}
		return false;
	}

	protected export const virtual function ExitCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		if( !( EnterCondition( stateContext, scriptInterface ) ) )
		{
			return true;
		}
		return false;
	}

}

class SafeCrosshairStateEvents extends BaseCrosshairStateEvents
{
}

class DriverCombatMountedWeaponsReloadCrosshairStateDecisions extends BaseCrosshairState
{

	protected export const virtual function EnterCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		var inDriverCombatWithMountedWeapon : Bool;
		var isReloading : Bool;
		inDriverCombatWithMountedWeapon = stateContext.IsStateActive( 'Vehicle', 'driverCombatMountedWeapons' );
		isReloading = scriptInterface.localBlackboard.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Weapon ) == ( ( Int32 )( gamePSMRangedWeaponStates.Reload ) );
		return inDriverCombatWithMountedWeapon && isReloading;
	}

	protected export const virtual function ExitCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		return !( EnterCondition( stateContext, scriptInterface ) );
	}

}

class DriverCombatMountedWeaponsReloadCrosshairStateEvents extends BaseCrosshairStateEvents
{
}

class QuickHackCrosshairStateDecisions extends BaseCrosshairState
{

	protected export const virtual function EnterCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		return GetHudManager( scriptInterface ).IsQuickHackPanelOpened();
	}

	protected export const virtual function ExitCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		return !( EnterCondition( stateContext, scriptInterface ) );
	}

}

class QuickHackCrosshairStateEvents extends BaseCrosshairStateEvents
{
}

