private uint GetSearchPriorityTargetByDistance(PoolObjHandle <ActorRoot> _actorPtr)
        {
            TargetDistanceNearFilter filter = new TargetDistanceNearFilter(ulong.MaxValue);

            if (this.heroList.Count >= 1)
            {
                if (this.heroList.Count == 1)
                {
                    return(this.heroList[0].ObjID);
                }
                return(filter.Searcher(this.heroList.GetEnumerator(), (ActorRoot)_actorPtr).ObjID);
            }
            if (this.bossList.Count >= 1)
            {
                if (this.bossList.Count == 1)
                {
                    return(this.bossList[0].ObjID);
                }
                return(filter.Searcher(this.bossList.GetEnumerator(), (ActorRoot)_actorPtr).ObjID);
            }
            if (this.monsterList.Count >= 1)
            {
                if (this.monsterList.Count == 1)
                {
                    return(this.monsterList[0].ObjID);
                }
                return(filter.Searcher(this.monsterList.GetEnumerator(), (ActorRoot)_actorPtr).ObjID);
            }
            if (this.organList.Count < 1)
            {
                return(0);
            }
            if (this.organList.Count == 1)
            {
                return(this.organList[0].ObjID);
            }
            return(filter.Searcher(this.organList.GetEnumerator(), (ActorRoot)_actorPtr).ObjID);
        }
예제 #2
0
        public ActorRoot GetLowestHpTarget(ActorRoot InActor, int srchR, TargetPriority priotity, uint filter, bool bEnemy = true, bool bWithMonsterNotInBattle = true)
        {
            List <ActorRoot> list  = new List <ActorRoot>();
            List <ActorRoot> list2 = new List <ActorRoot>();
            List <ActorRoot> list3 = new List <ActorRoot>();
            TargetPropertyLessEqualFilter filter2 = new TargetPropertyLessEqualFilter(list, ulong.MaxValue);
            TargetPropertyLessEqualFilter filter3 = new TargetPropertyLessEqualFilter(list2, ulong.MaxValue);
            TargetDistanceNearFilter      filter4 = new TargetDistanceNearFilter(ulong.MaxValue);

            if (bEnemy)
            {
                for (int i = 0; i < 3; i++)
                {
                    if (i != InActor.TheActorMeta.ActorCamp)
                    {
                        List <PoolObjHandle <ActorRoot> > campActors = Singleton <GameObjMgr> .GetInstance().GetCampActors((COM_PLAYERCAMP)i);

                        int num2 = campActors.Count;
                        for (int j = 0; j < num2; j++)
                        {
                            PoolObjHandle <ActorRoot> handle2 = campActors[j];
                            ActorRoot target = handle2.handle;
                            if ((((filter & (((int)1) << target.TheActorMeta.ActorType)) <= 0L) && target.HorizonMarker.IsVisibleFor(InActor.TheActorMeta.ActorCamp)) && InActor.CanAttack(target))
                            {
                                if (TypeSearchCondition.Fit(target, ActorTypeDef.Actor_Type_Hero))
                                {
                                    if (DistanceSearchCondition.Fit(target, InActor, srchR))
                                    {
                                        filter2.Searcher(target, RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP, new PropertyDelegate(TargetProperty.GetPropertyHpRate));
                                    }
                                }
                                else if (TypeSearchCondition.Fit(target, ActorTypeDef.Actor_Type_Organ))
                                {
                                    if (DistanceSearchCondition.Fit(target, InActor, srchR))
                                    {
                                        list3.Add(target);
                                    }
                                }
                                else if ((TypeSearchCondition.Fit(target, ActorTypeDef.Actor_Type_Monster) && TypeSearchCondition.FitWithJungleMonsterNotInBattle(target, bWithMonsterNotInBattle)) && DistanceSearchCondition.Fit(target, InActor, srchR))
                                {
                                    filter3.Searcher(target, RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP, new PropertyDelegate(TargetProperty.GetPropertyHpRate));
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                List <PoolObjHandle <ActorRoot> > list5 = Singleton <GameObjMgr> .GetInstance().GetCampActors(InActor.TheActorMeta.ActorCamp);

                int num4 = list5.Count;
                for (int k = 0; k < num4; k++)
                {
                    PoolObjHandle <ActorRoot> handle3 = list5[k];
                    ActorRoot root2 = handle3.handle;
                    if ((((filter & (((int)1) << root2.TheActorMeta.ActorType)) <= 0L) && !root2.ActorControl.IsDeadState) && root2.HorizonMarker.IsVisibleFor(InActor.TheActorMeta.ActorCamp))
                    {
                        if (TypeSearchCondition.Fit(root2, ActorTypeDef.Actor_Type_Hero))
                        {
                            if (DistanceSearchCondition.Fit(root2, InActor, srchR))
                            {
                                filter2.Searcher(root2, RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP, new PropertyDelegate(TargetProperty.GetPropertyHpRate));
                            }
                        }
                        else if (TypeSearchCondition.Fit(root2, ActorTypeDef.Actor_Type_Organ))
                        {
                            if (DistanceSearchCondition.Fit(root2, InActor, srchR))
                            {
                                list3.Add(root2);
                            }
                        }
                        else if (TypeSearchCondition.Fit(root2, ActorTypeDef.Actor_Type_Monster) && DistanceSearchCondition.Fit(root2, InActor, srchR))
                        {
                            filter3.Searcher(root2, RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP, new PropertyDelegate(TargetProperty.GetPropertyHpRate));
                        }
                    }
                }
            }
            int num6  = (list.Count + list3.Count) + list2.Count;
            int count = list.Count;

            if (count > 0)
            {
                ActorRoot root3 = null;
                if (count == 1)
                {
                    root3 = list[0];
                }
                else
                {
                    root3 = filter4.Searcher(list.GetEnumerator(), InActor);
                }
                PoolObjHandle <ActorRoot> selfPtr = new PoolObjHandle <ActorRoot>();
                if (root3 != null)
                {
                    selfPtr = root3.SelfPtr;
                }
                SkillChooseTargetEventParam prm = new SkillChooseTargetEventParam(selfPtr, InActor.SelfPtr, num6);
                Singleton <GameEventSys> .instance.SendEvent <SkillChooseTargetEventParam>(GameEventDef.Event_ActorBeChosenAsTarget, ref prm);

                return(root3);
            }
            count = list3.Count;
            if (count > 0)
            {
                if (count == 1)
                {
                    return(list3[0]);
                }
                return(filter4.Searcher(list3.GetEnumerator(), InActor));
            }
            count = list2.Count;
            if (count <= 0)
            {
                return(null);
            }
            if (count == 1)
            {
                return(list2[0]);
            }
            return(filter4.Searcher(list2.GetEnumerator(), InActor));
        }