コード例 #1
0
        // Token: 0x06002135 RID: 8501 RVA: 0x0008F854 File Offset: 0x0008DA54
        public bool GameObjectPassesSkillDriverFilters(BaseAI.Target target, AISkillDriver skillDriver, out float separationSqrMagnitude)
        {
            separationSqrMagnitude = 0f;
            if (!target.gameObject)
            {
                return(false);
            }
            float num = 1f;

            if (target.healthComponent)
            {
                num = target.healthComponent.combinedHealthFraction;
            }
            if (num < skillDriver.minTargetHealthFraction || num > skillDriver.maxTargetHealthFraction)
            {
                return(false);
            }
            float num2 = 0f;

            if (this.body)
            {
                num2 = this.body.radius;
            }
            float num3 = 0f;

            if (target.characterBody)
            {
                num3 = target.characterBody.radius;
            }
            Vector3 b = this.bodyInputBank ? this.bodyInputBank.aimOrigin : this.bodyTransform.position;
            Vector3 a;

            target.GetBullseyePosition(out a);
            float sqrMagnitude = (a - b).sqrMagnitude;

            separationSqrMagnitude = sqrMagnitude - num3 * num3 - num2 * num2;
            return(separationSqrMagnitude >= skillDriver.minDistanceSqr && separationSqrMagnitude <= skillDriver.maxDistanceSqr && (!skillDriver.selectionRequiresTargetLoS || target.hasLoS));
        }
コード例 #2
0
        // Token: 0x06002137 RID: 8503 RVA: 0x0008F978 File Offset: 0x0008DB78
        public BaseAI.SkillDriverEvaluation EvaluateSkillDrivers()
        {
            this.UpdateTargets();
            BaseAI.SkillDriverEvaluation result = default(BaseAI.SkillDriverEvaluation);
            float num = 1f;

            if (this.bodyHealthComponent)
            {
                num = this.bodyHealthComponent.combinedHealthFraction;
            }
            float positiveInfinity = float.PositiveInfinity;

            if (this.bodySkillLocator)
            {
                for (int i = 0; i < this.skillDrivers.Length; i++)
                {
                    AISkillDriver aiskillDriver = this.skillDrivers[i];
                    if (!aiskillDriver.noRepeat || !(this.skillDriverEvaluation.dominantSkillDriver == aiskillDriver))
                    {
                        BaseAI.Target target = null;
                        if (!aiskillDriver.requireEquipmentReady || this.body.equipmentSlot.stock > 0)
                        {
                            if (aiskillDriver.skillSlot != SkillSlot.None)
                            {
                                GenericSkill skill = this.bodySkillLocator.GetSkill(aiskillDriver.skillSlot);
                                if ((aiskillDriver.requireSkillReady && (!skill || !skill.IsReady())) || (aiskillDriver.requiredSkill && (!skill || !(skill.skillDef == aiskillDriver.requiredSkill))))
                                {
                                    goto IL_327;
                                }
                            }
                            if (aiskillDriver.minUserHealthFraction <= num && aiskillDriver.maxUserHealthFraction >= num)
                            {
                                switch (aiskillDriver.moveTargetType)
                                {
                                case AISkillDriver.TargetType.CurrentEnemy:
                                    if (this.GameObjectPassesSkillDriverFilters(this.currentEnemy, aiskillDriver, out positiveInfinity))
                                    {
                                        target = this.currentEnemy;
                                    }
                                    break;

                                case AISkillDriver.TargetType.NearestFriendlyInSkillRange:
                                    if (this.bodyInputBank)
                                    {
                                        this.buddySearch.teamMaskFilter = TeamMask.none;
                                        this.buddySearch.teamMaskFilter.AddTeam(this.master.teamIndex);
                                        this.buddySearch.sortMode          = BullseyeSearch.SortMode.Distance;
                                        this.buddySearch.minDistanceFilter = aiskillDriver.minDistanceSqr;
                                        this.buddySearch.maxDistanceFilter = aiskillDriver.maxDistance;
                                        this.buddySearch.searchOrigin      = this.bodyInputBank.aimOrigin;
                                        this.buddySearch.searchDirection   = this.bodyInputBank.aimDirection;
                                        this.buddySearch.maxAngleFilter    = 180f;
                                        this.buddySearch.filterByLoS       = aiskillDriver.activationRequiresTargetLoS;
                                        this.buddySearch.RefreshCandidates();
                                        if (this.body)
                                        {
                                            this.buddySearch.FilterOutGameObject(this.body.gameObject);
                                        }
                                        this.buddySearch.FilterCandidatesByHealthFraction(aiskillDriver.minTargetHealthFraction, aiskillDriver.maxTargetHealthFraction);
                                        HurtBox hurtBox = this.buddySearch.GetResults().FirstOrDefault <HurtBox>();
                                        if (hurtBox && hurtBox.healthComponent)
                                        {
                                            this.buddy.gameObject  = hurtBox.healthComponent.gameObject;
                                            this.buddy.bestHurtBox = hurtBox;
                                        }
                                        if (this.GameObjectPassesSkillDriverFilters(this.buddy, aiskillDriver, out positiveInfinity))
                                        {
                                            target = this.buddy;
                                        }
                                    }
                                    break;

                                case AISkillDriver.TargetType.CurrentLeader:
                                    if (this.GameObjectPassesSkillDriverFilters(this.leader, aiskillDriver, out positiveInfinity))
                                    {
                                        target = this.leader;
                                    }
                                    break;

                                case AISkillDriver.TargetType.Custom:
                                    if (this.GameObjectPassesSkillDriverFilters(this.customTarget, aiskillDriver, out positiveInfinity))
                                    {
                                        target = this.customTarget;
                                    }
                                    break;
                                }
                                if (target != null)
                                {
                                    result.dominantSkillDriver = aiskillDriver;
                                    result.target = target;
                                    result.separationSqrMagnitude = positiveInfinity;
                                    break;
                                }
                            }
                        }
                    }
                    IL_327 :;
                }
            }
            return(result);
        }