class MeleeLeapAttackObjectTagger
{
	private var m_game : GameInstance;
	private var m_playerPuppet : weak< GameObject >;
	private var m_playerDevelopmentData : weak< PlayerDevelopmentData >;
	private var m_visionModeSystem : weak< VisionModeSystem >;
	private var m_target : weak< GameObject >;
	private var m_minDistanceToTarget : Float;
	default m_minDistanceToTarget = 2.f;

	public function SetUp( playerPuppet : GameObject )
	{
		m_game = playerPuppet.GetGame();
		m_playerPuppet = playerPuppet;
		m_playerDevelopmentData = PlayerDevelopmentSystem.GetData( playerPuppet );
		m_visionModeSystem = GameInstance.GetVisionModeSystem( m_game );
	}

	public function SetVisionOnTargetObj( targetEntity : Entity, distanceToTarget : Float )
	{
		var leapAttackPerkIsBought : Bool;
		var gameObject : GameObject;
		var isValidTurret : Bool;
		gameObject = ( ( GameObject )( targetEntity ) );
		if( !( gameObject ) )
		{
			return;
		}
		if( m_playerDevelopmentData )
		{
			leapAttackPerkIsBought = m_playerDevelopmentData.IsNewPerkBoughtAnyLevel( gamedataNewPerkType.Reflexes_Inbetween_Right_2 );
		}
		if( gameObject.IsTurret() && ( ( Device )( gameObject ) ) )
		{
			isValidTurret = !( StrContains( ( ( Device )( gameObject ) ).GetDeviceName(), "Ceiling" ) );
		}
		if( ( leapAttackPerkIsBought && gameObject.IsActive() ) && ( gameObject.IsNPC() || isValidTurret ) )
		{
			if( ( m_minDistanceToTarget < distanceToTarget ) && ( GetTargetMaxRange() > distanceToTarget ) )
			{
				if( m_target.GetEntityID() != gameObject.GetEntityID() )
				{
					ResetVisionOnTargetObj();
					m_target = gameObject;
					m_visionModeSystem.GetScanningController().TagObject( m_target );
				}
			}
			else
			{
				ResetVisionOnTargetObj();
			}
		}
	}

	public function ResetVisionOnTargetObj()
	{
		if( m_target )
		{
			m_visionModeSystem.GetScanningController().UntagObject( m_target );
			m_target = NULL;
		}
	}

	protected const function CanPerformRelicLeap( equippedWeapon : WeaponObject ) : Bool
	{
		if( !( equippedWeapon.IsMantisBlades() ) || !( equippedWeapon.IsCharged() ) )
		{
			return false;
		}
		return RPGManager.HasStatFlag( m_playerPuppet, gamedataStatType.CanUseNewMeleewareAttackSpyTree );
	}

	private function GetTargetMaxRange() : Float
	{
		var equippedWeapon : WeaponObject;
		equippedWeapon = GameObject.GetActiveWeapon( m_playerPuppet );
		if( CanPerformRelicLeap( equippedWeapon ) )
		{
			return TDB.GetFloat( T"playerStateMachineMelee.meleeLeap.maxDistToTargetMantisBladesRelic" );
		}
		return TDB.GetFloat( T"playerStateMachineMelee.meleeLeap.maxDistToTarget" );
	}

}

