public void DoSimpleAI() { if (base.isClient) { return; } base.SetFlag(BaseEntity.Flags.Reserved5, TOD_Sky.Instance.IsNight, false, true); if (!this.DoAI) { return; } if (this.targetList.Count <= 0) { this.mainGunTarget = null; this.UpdateMovement_Patrol(); } else { if (!this.targetList[0].IsValid() || !this.targetList[0].IsVisible()) { this.mainGunTarget = null; } else { this.mainGunTarget = this.targetList[0].entity as BaseCombatEntity; } this.UpdateMovement_Hunt(); } this.AdvancePathMovement(); float single = Vector3.Distance(base.transform.position, this.destination); float single1 = Vector3.Distance(base.transform.position, this.finalDestination); if (single > this.stoppingDist) { Vector3 vector3 = BradleyAPC.Direction2D(this.destination, base.transform.position); float single2 = Vector3.Dot(vector3, base.transform.right); float single3 = Vector3.Dot(vector3, base.transform.right); float single4 = Vector3.Dot(vector3, -base.transform.right); if (Vector3.Dot(vector3, -base.transform.forward) <= single2) { this.turning = Mathf.Clamp(single2 * 3f, -1f, 1f); } else if (single3 < single4) { this.turning = -1f; } else { this.turning = 1f; } float single5 = 1f - Mathf.InverseLerp(0f, 0.3f, Mathf.Abs(this.turning)); float single6 = Mathf.InverseLerp(0.1f, 0.4f, Vector3.Dot(base.transform.forward, Vector3.up)); this.throttle = (0.1f + Mathf.InverseLerp(0f, 20f, single1) * 1f) * single5 + single6; } this.DoWeaponAiming(); base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); }
public void AdvancePathMovement() { if (!this.HasPath()) { return; } if (this.AtCurrentPathNode() || this.currentPathIndex == -1) { this.currentPathIndex = this.GetLoopedIndex(this.currentPathIndex + 1); } if (this.PathComplete()) { this.ClearPath(); return; } Vector3 vector3 = this.IdealPathPosition(); float single = Vector3.Distance(vector3, this.currentPath[this.currentPathIndex]); float single1 = Vector3.Distance(base.transform.position, vector3); float single2 = Mathf.InverseLerp(8f, 0f, single1); vector3 = vector3 + (BradleyAPC.Direction2D(this.currentPath[this.currentPathIndex], vector3) * Mathf.Min(single, single2 * 20f)); this.SetDestination(vector3); }