public void OnDrawGizmosSelected() { if (AutoWayPoint.waypoints.get_length() == 0) { this.RebuildWaypointList(); } IEnumerator enumerator = UnityRuntimeServices.GetEnumerator(this.connected); while (enumerator.MoveNext()) { AutoWayPoint autoWayPoint = (AutoWayPoint)RuntimeServices.Coerce(enumerator.Current, typeof(AutoWayPoint)); if (Physics.Linecast(this.get_transform().get_position(), autoWayPoint.get_transform().get_position())) { Gizmos.set_color(Color.get_red()); Gizmos.DrawLine(this.get_transform().get_position(), autoWayPoint.get_transform().get_position()); UnityRuntimeServices.Update(enumerator, autoWayPoint); } else { Gizmos.set_color(Color.get_green()); Gizmos.DrawLine(this.get_transform().get_position(), autoWayPoint.get_transform().get_position()); UnityRuntimeServices.Update(enumerator, autoWayPoint); } } }
public void RecalculateConnectedWaypoints() { this.connected = new Array(); IEnumerator enumerator = UnityRuntimeServices.GetEnumerator(AutoWayPoint.waypoints); while (enumerator.MoveNext()) { AutoWayPoint autoWayPoint = (AutoWayPoint)RuntimeServices.Coerce(enumerator.Current, typeof(AutoWayPoint)); if (!(autoWayPoint == this)) { if (!Physics.CheckCapsule(this.get_transform().get_position(), autoWayPoint.get_transform().get_position(), AutoWayPoint.kLineOfSightCapsuleRadius)) { this.connected.Add(autoWayPoint); UnityRuntimeServices.Update(enumerator, autoWayPoint); } } } }
public static AutoWayPoint FindClosest(Vector3 pos) { AutoWayPoint result = null; float num = 100000f; IEnumerator enumerator = UnityRuntimeServices.GetEnumerator(AutoWayPoint.waypoints); while (enumerator.MoveNext()) { AutoWayPoint autoWayPoint = (AutoWayPoint)RuntimeServices.Coerce(enumerator.Current, typeof(AutoWayPoint)); float num2 = Vector3.Distance(autoWayPoint.get_transform().get_position(), pos); UnityRuntimeServices.Update(enumerator, autoWayPoint); if (num2 < num) { num = num2; result = autoWayPoint; UnityRuntimeServices.Update(enumerator, autoWayPoint); } } return(result); }
public AutoWayPoint PickNextWaypoint(AutoWayPoint currentWaypoint) { Vector3 vector = this.get_transform().TransformDirection(Vector3.get_forward()); AutoWayPoint result = currentWaypoint; float num = 10f * (float)-1; IEnumerator enumerator = UnityRuntimeServices.GetEnumerator(currentWaypoint.connected); while (enumerator.MoveNext()) { AutoWayPoint autoWayPoint = (AutoWayPoint)RuntimeServices.Coerce(enumerator.Current, typeof(AutoWayPoint)); Vector3 vector2 = Vector3.Normalize(autoWayPoint.get_transform().get_position() - this.get_transform().get_position()); UnityRuntimeServices.Update(enumerator, autoWayPoint); float num2 = Vector3.Dot(vector2, vector); if (num2 > num && autoWayPoint != currentWaypoint) { num = num2; result = autoWayPoint; UnityRuntimeServices.Update(enumerator, autoWayPoint); } } return(result); }