// Token: 0x0600211C RID: 8476 RVA: 0x0008EC00 File Offset: 0x0008CE00
        public void FixedUpdate()
        {
            if (this.drawAIPath)
            {
                this.DebugDrawPath(Color.red, Time.fixedDeltaTime);
            }
            this.enemyAttention -= Time.fixedDeltaTime;
            if (this.currentEnemy.characterBody && this.body && this.currentEnemy.characterBody.GetVisibilityLevel(this.body) < VisibilityLevel.Revealed)
            {
                this.currentEnemy.Reset();
            }
            if (this.pendingPath != null && this.pendingPath.status == PathTask.TaskStatus.Complete)
            {
                this.pathFollower.SetPath(this.pendingPath.path);
                this.pendingPath.path.Dispose();
                this.pendingPath = null;
            }
            if (this.body)
            {
                this.targetRefreshTimer     -= Time.fixedDeltaTime;
                this.skillDriverUpdateTimer -= Time.fixedDeltaTime;
                if (this.skillDriverUpdateTimer <= 0f)
                {
                    if (this.skillDriverEvaluation.dominantSkillDriver)
                    {
                        this.selectedSkilldriverName = this.skillDriverEvaluation.dominantSkillDriver.customName;
                        if (this.skillDriverEvaluation.dominantSkillDriver.resetCurrentEnemyOnNextDriverSelection)
                        {
                            this.currentEnemy.Reset();
                            this.targetRefreshTimer = 0f;
                        }
                    }
                    if (!this.currentEnemy.gameObject && this.targetRefreshTimer <= 0f)
                    {
                        this.targetRefreshTimer = 0.5f;
                        HurtBox hurtBox = this.FindEnemyHurtBox(float.PositiveInfinity, this.fullVision, true);
                        if (hurtBox && hurtBox.healthComponent)
                        {
                            this.currentEnemy.gameObject  = hurtBox.healthComponent.gameObject;
                            this.currentEnemy.bestHurtBox = hurtBox;
                        }
                        if (this.currentEnemy.gameObject)
                        {
                            this.enemyAttention = this.enemyAttentionDuration;
                        }
                    }
                    this.BeginSkillDriver(this.EvaluateSkillDrivers());
                }
            }
            this.PickCurrentNodeGraph();
            if (this.bodyInputBank)
            {
                bool newState  = false;
                bool newState2 = false;
                if (this.skillDriverEvaluation.dominantSkillDriver)
                {
                    AISkillDriver.AimType aimType = this.skillDriverEvaluation.dominantSkillDriver.aimType;
                    if (aimType != AISkillDriver.AimType.None)
                    {
                        BaseAI.Target target = null;
                        switch (aimType)
                        {
                        case AISkillDriver.AimType.AtMoveTarget:
                            target = this.skillDriverEvaluation.target;
                            break;

                        case AISkillDriver.AimType.AtCurrentEnemy:
                            target = this.currentEnemy;
                            break;

                        case AISkillDriver.AimType.AtCurrentLeader:
                            target = this.leader;
                            break;
                        }
                        if (target != null)
                        {
                            Vector3 a;
                            if (target.GetBullseyePosition(out a))
                            {
                                this.desiredAimDirection = (a - this.bodyInputBank.aimOrigin).normalized;
                            }
                            newState = (this.skillDriverEvaluation.dominantSkillDriver.shouldFireEquipment && !this.bodyInputBank.activateEquipment.down);
                        }
                        else if (this.bodyInputBank.moveVector != Vector3.zero)
                        {
                            this.desiredAimDirection = this.bodyInputBank.moveVector;
                        }
                    }
                    newState2 = this.skillDriverEvaluation.dominantSkillDriver.shouldSprint;
                }
                this.bodyInputBank.activateEquipment.PushState(newState);
                this.bodyInputBank.sprint.PushState(newState2);
                Vector3 aimDirection   = this.bodyInputBank.aimDirection;
                Vector3 eulerAngles    = Util.QuaternionSafeLookRotation(this.desiredAimDirection).eulerAngles;
                Vector3 eulerAngles2   = Util.QuaternionSafeLookRotation(aimDirection).eulerAngles;
                float   fixedDeltaTime = Time.fixedDeltaTime;
                float   x = Mathf.SmoothDampAngle(eulerAngles2.x, eulerAngles.x, ref this.aimVelocity.x, this.aimVectorDampTime, this.aimVectorMaxSpeed, fixedDeltaTime);
                float   y = Mathf.SmoothDampAngle(eulerAngles2.y, eulerAngles.y, ref this.aimVelocity.y, this.aimVectorDampTime, this.aimVectorMaxSpeed, fixedDeltaTime);
                float   z = Mathf.SmoothDampAngle(eulerAngles2.z, eulerAngles.z, ref this.aimVelocity.z, this.aimVectorDampTime, this.aimVectorMaxSpeed, fixedDeltaTime);
                this.bodyInputBank.aimDirection = Quaternion.Euler(x, y, z) * Vector3.forward;
            }
            this.debugEnemyHurtBox = this.currentEnemy.bestHurtBox;
        }
Exemple #2
0
        // Token: 0x0600203E RID: 8254 RVA: 0x000975B0 File Offset: 0x000957B0
        public void FixedUpdate()
        {
            if (this.drawAIPath)
            {
                this.DebugDrawPath(Color.red, Time.fixedDeltaTime);
            }
            this.enemyAttention -= Time.fixedDeltaTime;
            if (this.currentEnemy.characterBody && this.body && this.currentEnemy.characterBody.GetVisibilityLevel(this.body) < VisibilityLevel.Revealed)
            {
                this.currentEnemy.Reset();
            }
            if (this.pendingPath != null && this.pendingPath.status == PathTask.TaskStatus.Complete)
            {
                this.pathFollower.SetPath(this.pendingPath.path);
                this.pendingPath.path.Dispose();
                this.pendingPath = null;
            }
            if (this.body)
            {
                this.targetRefreshTimer     -= Time.fixedDeltaTime;
                this.skillDriverUpdateTimer -= Time.fixedDeltaTime;
                if (this.skillDriverUpdateTimer <= 0f)
                {
                    if (this.skillDriverEvaluation.dominantSkillDriver)
                    {
                        this.selectedSkilldriverName = this.skillDriverEvaluation.dominantSkillDriver.customName;
                        if (this.skillDriverEvaluation.dominantSkillDriver.resetCurrentEnemyOnNextDriverSelection)
                        {
                            this.currentEnemy.Reset();
                            this.targetRefreshTimer = 0f;
                        }
                    }
                    if (!this.currentEnemy.gameObject && this.targetRefreshTimer <= 0f)
                    {
                        this.targetRefreshTimer         = 0.5f;
                        this.enemySearch.viewer         = this.body;
                        this.enemySearch.teamMaskFilter = TeamMask.allButNeutral;
                        this.enemySearch.teamMaskFilter.RemoveTeam(this.master.teamIndex);
                        this.enemySearch.sortMode          = BullseyeSearch.SortMode.Distance;
                        this.enemySearch.minDistanceFilter = 0f;
                        this.enemySearch.maxDistanceFilter = float.PositiveInfinity;
                        this.enemySearch.searchOrigin      = this.bodyInputBank.aimOrigin;
                        this.enemySearch.searchDirection   = this.bodyInputBank.aimDirection;
                        this.enemySearch.maxAngleFilter    = (this.fullVision ? 180f : 90f);
                        this.enemySearch.filterByLoS       = true;
                        this.enemySearch.RefreshCandidates();
                        HurtBox hurtBox = this.enemySearch.GetResults().FirstOrDefault <HurtBox>();
                        if (hurtBox && hurtBox.healthComponent)
                        {
                            this.currentEnemy.gameObject  = hurtBox.healthComponent.gameObject;
                            this.currentEnemy.bestHurtBox = hurtBox;
                        }
                        if (this.currentEnemy.gameObject)
                        {
                            this.enemyAttention = this.enemyAttentionDuration;
                        }
                    }
                    this.skillDriverEvaluation = this.EvaluateSkillDrivers();
                    if (this.skillDriverEvaluation.dominantSkillDriver && this.skillDriverEvaluation.dominantSkillDriver.driverUpdateTimerOverride >= 0f)
                    {
                        this.skillDriverUpdateTimer = this.skillDriverEvaluation.dominantSkillDriver.driverUpdateTimerOverride;
                    }
                    else
                    {
                        this.skillDriverUpdateTimer = UnityEngine.Random.Range(0.16666667f, 0.2f);
                    }
                }
            }
            if (this.bodyInputBank)
            {
                if (this.skillDriverEvaluation.dominantSkillDriver)
                {
                    AISkillDriver.AimType aimType = this.skillDriverEvaluation.dominantSkillDriver.aimType;
                    if (aimType != AISkillDriver.AimType.None)
                    {
                        BaseAI.Target target = null;
                        switch (aimType)
                        {
                        case AISkillDriver.AimType.AtMoveTarget:
                            target = this.skillDriverEvaluation.target;
                            break;

                        case AISkillDriver.AimType.AtCurrentEnemy:
                            target = this.currentEnemy;
                            break;

                        case AISkillDriver.AimType.AtCurrentLeader:
                            target = this.leader;
                            break;
                        }
                        if (target != null)
                        {
                            Vector3 a;
                            if (target.GetBullseyePosition(out a))
                            {
                                this.desiredAimDirection = (a - this.bodyInputBank.aimOrigin).normalized;
                            }
                        }
                        else
                        {
                            if (this.bodyInputBank.moveVector != Vector3.zero)
                            {
                                this.desiredAimDirection = this.bodyInputBank.moveVector;
                            }
                            this.bodyInputBank.sprint.PushState(this.skillDriverEvaluation.dominantSkillDriver.shouldSprint);
                        }
                    }
                }
                Vector3 aimDirection   = this.bodyInputBank.aimDirection;
                Vector3 eulerAngles    = Util.QuaternionSafeLookRotation(this.desiredAimDirection).eulerAngles;
                Vector3 eulerAngles2   = Util.QuaternionSafeLookRotation(aimDirection).eulerAngles;
                float   fixedDeltaTime = Time.fixedDeltaTime;
                float   x = Mathf.SmoothDampAngle(eulerAngles2.x, eulerAngles.x, ref this.aimVelocity.x, this.aimVectorDampTime, this.aimVectorMaxSpeed, fixedDeltaTime);
                float   y = Mathf.SmoothDampAngle(eulerAngles2.y, eulerAngles.y, ref this.aimVelocity.y, this.aimVectorDampTime, this.aimVectorMaxSpeed, fixedDeltaTime);
                float   z = Mathf.SmoothDampAngle(eulerAngles2.z, eulerAngles.z, ref this.aimVelocity.z, this.aimVectorDampTime, this.aimVectorMaxSpeed, fixedDeltaTime);
                this.bodyInputBank.aimDirection = Quaternion.Euler(x, y, z) * Vector3.forward;
            }
            this.debugEnemyHurtBox = this.currentEnemy.bestHurtBox;
        }