private void DrawPath(PathFinder.Path path, Vector3 navigator_pos, Color color) { if (path.nodes != null && path.nodes.Count > 1) { GL.PushMatrix(); material.SetPass(0); GL.Begin(1); GL.Color(color); GL.Vertex(navigator_pos); PathFinder.Path.Node node = path.nodes[1]; int cell = node.cell; PathFinder.Path.Node node2 = path.nodes[1]; GL.Vertex(NavTypeHelper.GetNavPos(cell, node2.navType)); for (int i = 1; i < path.nodes.Count - 1; i++) { PathFinder.Path.Node node3 = path.nodes[i]; int cell2 = node3.cell; PathFinder.Path.Node node4 = path.nodes[i]; Vector3 navPos = NavTypeHelper.GetNavPos(cell2, node4.navType); PathFinder.Path.Node node5 = path.nodes[i + 1]; int cell3 = node5.cell; PathFinder.Path.Node node6 = path.nodes[i + 1]; Vector3 navPos2 = NavTypeHelper.GetNavPos(cell3, node6.navType); GL.Vertex(navPos); GL.Vertex(navPos2); } GL.End(); GL.PopMatrix(); } }
public static void DebugDrawPath(PathFinder.Path path) { if (path.nodes != null) { for (int i = 0; i < path.nodes.Count - 1; i++) { PathFinder.Path.Node node = path.nodes[i]; int cell = node.cell; PathFinder.Path.Node node2 = path.nodes[i + 1]; DebugDrawPath(cell, node2.cell); } } }
public NavGrid.Transition GetNextTransition() { NavGrid.Transition[] transitions = NavGrid.transitions; PathFinder.Path.Node node = path.nodes[1]; return(transitions[node.transitionId]); }
public void AdvancePath(bool trigger_advance = true) { int num = Grid.PosToCell(this); int num2; bool flag; if ((UnityEngine.Object)target == (UnityEngine.Object)null) { Trigger(-766531887, null); Stop(false); } else { if (num != reservedCell || CurrentNavType == NavType.Tube) { flag = false; num2 = Grid.PosToCell(target); if (reservedCell == NavigationReservations.InvalidReservation) { flag = true; } else if (!CanReach(reservedCell)) { flag = true; } else if (!Grid.IsCellOffsetOf(reservedCell, num2, targetOffsets)) { flag = true; } else if (path.IsValid()) { int num3 = num; PathFinder.Path.Node node = path.nodes[0]; if (num3 == node.cell) { NavType currentNavType = CurrentNavType; PathFinder.Path.Node node2 = path.nodes[0]; if (currentNavType == node2.navType) { flag = !ValidatePath(ref path); goto IL_018c; } } int num4 = num; PathFinder.Path.Node node3 = path.nodes[1]; if (num4 == node3.cell) { NavType currentNavType2 = CurrentNavType; PathFinder.Path.Node node4 = path.nodes[1]; if (currentNavType2 == node4.navType) { path.nodes.RemoveAt(0); flag = !ValidatePath(ref path); goto IL_018c; } } flag = true; } else { flag = true; } goto IL_018c; } Stop(true); } goto IL_02b5; IL_018c: if (flag) { int cellPreferences = tactic.GetCellPreferences(num2, targetOffsets, this); SetReservedCell(cellPreferences); if (reservedCell != NavigationReservations.InvalidReservation) { PathFinder.UpdatePath(potential_path: new PathFinder.PotentialPath(num, CurrentNavType, flags), nav_grid: NavGrid, abilities: GetCurrentAbilities(), query: PathFinderQueries.cellQuery.Reset(reservedCell), path: ref path); } else { Stop(false); } } if (path.IsValid()) { NavGrid.Transition[] transitions = NavGrid.transitions; PathFinder.Path.Node node5 = path.nodes[1]; BeginTransition(transitions[node5.transitionId]); distanceTravelledByNavType[CurrentNavType] = Mathf.Max(distanceTravelledByNavType[CurrentNavType] + 1, distanceTravelledByNavType[CurrentNavType]); } else if (path.HasArrived()) { Stop(true); } else { ClearReservedCell(); Stop(false); } goto IL_02b5; IL_02b5: if (trigger_advance) { Trigger(1347184327, null); } }