private Units GetNormalTarget()
        {
            Units        units = null;
            List <Units> list  = MapManager.Instance.EnumEnemyMapUnits(this.m_Owner.TeamType, TargetTag.HeroAndMonster).ToList <Units>();

            if (list.Count > 0)
            {
                list.Sort(new Comparison <Units>(this.SortFunc));
                foreach (Units current in list)
                {
                    if (HeroMirrorTargetingSystem.IfChooseTarget(this.m_Owner, current, 0f))
                    {
                        if (current.isHero)
                        {
                            return(current);
                        }
                        if (units == null)
                        {
                            units = current;
                        }
                    }
                }
                return(units);
            }
            return(null);
        }
        protected override bool IfNeedChangeTarget()
        {
            this.m_timer.interval = 1f;
            if (this.m_timer.CanUpdate())
            {
                return(true);
            }
            object outputTarget = base.GetOutputTarget(OutputTargetType.OutputAttackTarget);

            if (outputTarget == null)
            {
                return(true);
            }
            Units target = outputTarget as Units;
            bool  flag   = HeroMirrorTargetingSystem.IfChooseTarget(this.m_Owner, target, 0f);

            return(!flag);
        }
        public static bool IfChooseTarget(Units owner, Units target, float range = 0f)
        {
            if (target == null || !target.isLive || !TeamManager.CanAttack(owner, target) || !target.CanBeSelected || target.isItem || (target.isMonster && target.teamType == 2) || !owner.CanBeSelected)
            {
                return(false);
            }
            if (UnitFeature.DistanceToTarget(owner.transform, target.transform) > owner.warning_range)
            {
                return(false);
            }
            Units home = MapManager.Instance.GetHome((TeamType)target.teamType);

            if (home == null)
            {
                return(true);
            }
            if (owner.MeiHuo.IsInState)
            {
                return(true);
            }
            if (range != 0f && !HeroMirrorTargetingSystem.IsInrange(owner.mTransform.position, target.mTransform.position, range))
            {
                return(false);
            }
            UtilCounter counter = UtilManager.Instance.GetCounter(UtilType.Tower);

            if (counter != null)
            {
                TowerCounter towerCounter          = counter as TowerCounter;
                Units        towerOfLowestPriority = towerCounter.GetTowerOfLowestPriority(owner);
                if (towerOfLowestPriority != null)
                {
                    float num  = UnitFeature.DistanceToTargetSqr(owner.transform, towerOfLowestPriority.transform);
                    float num2 = UnitFeature.DistanceToTargetSqr(owner.transform, target.transform);
                    if (num2 > num)
                    {
                        return(false);
                    }
                }
            }
            bool flag = StrategyManager.Instance.IsHomeRecovery((TeamType)target.teamType);

            if (flag)
            {
                Vector3 recoveryPos = StrategyManager.Instance.GetRecoveryPos((TeamType)target.teamType);
                if (HeroMirrorTargetingSystem.IsInrange(target.transform.position, recoveryPos, 3f))
                {
                    return(false);
                }
            }
            Units nearestEnemyTowerOfTarget = TargetSelectHelper.GetNearestEnemyTowerOfTarget(target);

            if (nearestEnemyTowerOfTarget != null)
            {
                float attackRange = nearestEnemyTowerOfTarget.GetAttackRange(owner);
                if (HeroMirrorTargetingSystem.IsInrange(target.transform.position, nearestEnemyTowerOfTarget.transform.position, attackRange))
                {
                    float num3 = UnitFeature.DistanceToTarget(target, nearestEnemyTowerOfTarget);
                    if (owner.GetAttackRange(target) + num3 > attackRange && !HeroMirrorTargetingSystem.IsInrange(owner.transform.position, nearestEnemyTowerOfTarget.transform.position, attackRange))
                    {
                        return(true);
                    }
                    Units attackTarget = nearestEnemyTowerOfTarget.GetAttackTarget();
                    if (attackTarget != null && attackTarget == owner)
                    {
                        return(false);
                    }
                    List <Units> allians = TargetSelectHelper.GetAllians(nearestEnemyTowerOfTarget, attackRange, TargetTag.Monster, false);
                    return(allians != null && allians.Count > 1 && !target.isHero);
                }
            }
            return(true);
        }