// Token: 0x06002147 RID: 8519 RVA: 0x00090090 File Offset: 0x0008E290 private void DoSearch() { if (this.ai.body) { Ray aimRay = this.ai.bodyInputBank.GetAimRay(); this.search.viewer = this.ai.body; this.search.filterByDistinctEntity = true; this.search.filterByLoS = false; this.search.maxDistanceFilter = float.PositiveInfinity; this.search.minDistanceFilter = 0f; this.search.maxAngleFilter = 360f; this.search.searchDirection = aimRay.direction; this.search.searchOrigin = aimRay.origin; this.search.sortMode = BullseyeSearch.SortMode.Distance; this.search.queryTriggerInteraction = QueryTriggerInteraction.UseGlobal; TeamMask none = TeamMask.none; none.AddTeam(this.ai.master.teamIndex); this.search.teamMaskFilter = none; this.search.RefreshCandidates(); this.search.FilterOutGameObject(this.ai.body.gameObject); BaseAI.Target customTarget = this.ai.customTarget; HurtBox hurtBox = this.search.GetResults().Where(new Func <HurtBox, bool>(this.TargetPassesFilters)).FirstOrDefault <HurtBox>(); customTarget.gameObject = ((hurtBox != null) ? hurtBox.healthComponent.gameObject : null); } }
// 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)); }
// 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); }
// 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; }
// 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; }