void LoseAttackTarget(Transform targetTransform)
    {
        if (Gun != null)
        {
            Gun.transform.localRotation = Quaternion.identity;
        }
        if (targetTransform.gameObject.layer == GameConstants.ObjectiveLayer) // Bot is attacking the objective of the map.
        {
            if (_currentEnemyIndex < _seenTargets.Count && _seenTargets[_currentEnemyIndex].Key == targetTransform)
            {
                _nextSwitchEnemy = Time.time;
            }
            _seenTargets.RemoveAll(x => x.Key == targetTransform);
        }
        else // Bot is attacking the a player. "targetTransform" may be a collider inside the ragdoll, so you need to get the root player object.
        {
            if (_currentEnemyIndex < _seenTargets.Count && _seenTargets[_currentEnemyIndex].Key == targetTransform.root)
            {
                _nextSwitchEnemy = Time.time;
            }
            _seenTargets.RemoveAll(x => x.Key == targetTransform.root);
        }

        if (_seenTargets.Count == 0)
        {
            _isFiring = false;
            _botMaster.CallEventEnemyAttack(false);
        }
    }
    void LoseAttackTarget(Transform targetTransform)
    {
        if (Gun != null)
        {
            Gun.transform.localRotation = Quaternion.identity;
        }
        if (_currentAllyIndex < _seenTargets.Count && _seenTargets[_currentAllyIndex].Key == targetTransform.root)
        {
            _shouldSwitchEnemy = true;
        }

        _seenTargets.RemoveAll(x => x.Key == targetTransform.root);

        if (_seenTargets.Count == 0)
        {
            _isFiring = false;
            _botMaster.CallEventEnemyAttack(false);
        }
    }