Beispiel #1
0
 private static void FilterMonsterTargetByEllipse(BaseMonoAvatar aAvatar, List <BaseMonoMonster> monsters, Vector3 mainDirection, float eccentricity, ref BaseMonoEntity monsterTarget, ref float monsterScore)
 {
     for (int i = 0; i < monsters.Count; i++)
     {
         BaseMonoMonster target = monsters[i];
         if (!target.denySelect && target.IsActive())
         {
             List <BaseMonoAbilityEntity> allHitboxEnabledBodyParts = target.GetAllHitboxEnabledBodyParts();
             if (allHitboxEnabledBodyParts.Count > 0)
             {
                 foreach (BaseMonoAbilityEntity entity in allHitboxEnabledBodyParts)
                 {
                     float num2 = GetScoreByEllipse(aAvatar, entity, mainDirection, eccentricity);
                     if (num2 < monsterScore)
                     {
                         monsterTarget = entity;
                         monsterScore  = num2;
                     }
                 }
             }
             else
             {
                 float num3 = GetScoreByEllipse(aAvatar, target, mainDirection, eccentricity);
                 if (num3 < monsterScore)
                 {
                     monsterTarget = target;
                     monsterScore  = num3;
                 }
             }
         }
     }
 }
        protected BaseMonoEntity SelectTarget()
        {
            List <BaseMonoMonster> allMonsters = Singleton <MonsterManager> .Instance.GetAllMonsters();

            BaseMonoEntity entity   = null;
            float          maxValue = float.MaxValue;

            for (int i = 0; i < allMonsters.Count; i++)
            {
                BaseMonoMonster monster = allMonsters[i];
                if (monster.IsActive() && !monster.denySelect)
                {
                    List <BaseMonoAbilityEntity> allHitboxEnabledBodyParts = monster.GetAllHitboxEnabledBodyParts();
                    if (allHitboxEnabledBodyParts.Count > 0)
                    {
                        foreach (BaseMonoAbilityEntity entity2 in allHitboxEnabledBodyParts)
                        {
                            float num3 = Miscs.DistancForVec3IgnoreY(entity2.XZPosition, this._avatar.XZPosition);
                            if ((!this.hasDistanceLimit || ((num3 >= this.minDistance) && (num3 <= this.maxDistance))) && (num3 < maxValue))
                            {
                                maxValue = num3;
                                entity   = entity2;
                            }
                        }
                    }
                    else
                    {
                        float num4 = Miscs.DistancForVec3IgnoreY(monster.XZPosition, this._avatar.XZPosition);
                        if ((!this.hasDistanceLimit || ((num4 >= this.minDistance) && (num4 <= this.maxDistance))) && (num4 < maxValue))
                        {
                            maxValue = num4;
                            entity   = monster;
                        }
                    }
                }
            }
            if ((entity != null) && entity.IsActive())
            {
                return(entity);
            }
            return(null);
        }
Beispiel #3
0
        public override TaskStatus OnUpdate()
        {
            List <BaseMonoMonster> allMonsters = Singleton <MonsterManager> .Instance.GetAllMonsters();

            List <BaseMonoAvatar> allAvatars = Singleton <AvatarManager> .Instance.GetAllAvatars();

            List <BaseMonoMonster> list3 = new List <BaseMonoMonster>();

            for (int i = 0; i < allAvatars.Count; i++)
            {
                BaseMonoAvatar avatar = allAvatars[i];
                if ((avatar != null) && avatar.IsActive())
                {
                    BaseMonoMonster item = avatar.AttackTarget as BaseMonoMonster;
                    if (item != null)
                    {
                        list3.Add(item);
                    }
                }
            }
            if (allMonsters.Count <= 0)
            {
                return(TaskStatus.Failure);
            }
            BaseMonoMonster monster2 = null;
            float           maxValue = float.MaxValue;

            for (int j = 0; j < allMonsters.Count; j++)
            {
                BaseMonoMonster monster3 = allMonsters[j];
                if (monster3.IsActive())
                {
                    float num4 = Miscs.DistancForVec3IgnoreY(monster3.XZPosition, this._avatar.XZPosition);
                    if (!this.hasDistanceLimit || ((num4 >= this.minDistance) && (num4 <= this.maxDistance)))
                    {
                        if (list3.Contains(monster3))
                        {
                            num4 *= 2f;
                        }
                        if (num4 < maxValue)
                        {
                            maxValue = num4;
                            monster2 = monster3;
                        }
                    }
                }
            }
            if (monster2 == null)
            {
                return(TaskStatus.Failure);
            }
            BaseMonoEntity  attackTarget = this._avatar.AttackTarget;
            BaseMonoMonster newTarget    = monster2;

            this.isNewTarget.SetValue(attackTarget != newTarget);
            if (this.muteAnimRetarget)
            {
                this._avatar.SetMuteAnimRetarget(true);
                this._avatar.SetAttackTarget(newTarget);
            }
            else
            {
                this._avatar.GetActiveAIController().TrySetAttackTarget(newTarget);
            }
            return(TaskStatus.Success);
        }