Guest User

Untitled

a guest
Oct 6th, 2023
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. private void CalculateCarPlaces()
  2.     {
  3.       Array.Sort<int>(this.carPositions, (Comparison<int>) ((a, b) =>
  4.       {
  5.         int index;
  6.         if (this.Cars[a] is AICar)
  7.           index = ((AICar) this.Cars[a]).CurrentWaypoint;
  8.         else
  9.           index = this.CurrentCheckpoint;
  10.         int num1;
  11.         if (this.Cars[b] is AICar)
  12.           num1 = ((AICar) this.Cars[b]).CurrentWaypoint;
  13.         else
  14.           num1 = this.CurrentCheckpoint;
  15.         float num2 = Vector3.Distance(this.Cars[a].Rigidbody.Position, this.Waypoints[index].Position);
  16.         float num3 = Vector3.Distance(this.Cars[b].Rigidbody.Position, this.Waypoints[index].Position);
  17.         if (index > num1)
  18.           return 1;
  19.         if (index < num1)
  20.           return -1;
  21.         if ((double) num2 > (double) num3)
  22.           return 1;
  23.         if ((double) num2 < (double) num3)
  24.           return -1;
  25.         return 0;
  26.       }));
  27.     }
Add Comment
Please, Sign In to add comment