public PathFinder.Cell GetCell(int cell, NavType nav_type, out bool is_cell_in_range) { int num = OffsetCell(cell); is_cell_in_range = (-1 != num); if (!is_cell_in_range) { return(InvalidCell); } PathFinder.Cell cell2 = Cells[num * ValidNavTypes.Length + NavTypeTable[(uint)nav_type]]; return((!IsValidSerialNo(cell2.queryId)) ? InvalidCell : cell2); }
public void UpdateProbe(NavGrid nav_grid, int cell, NavType nav_type, PathFinderAbilities abilities, PathFinder.PotentialPath.Flags flags) { if (scratchPad == null) { scratchPad = new PathFinder.PotentialScratchPad(nav_grid.maxLinksPerCell); } bool flag = updateCount == -1; bool flag2 = Potentials.Count == 0 || flag; PathGrid.BeginUpdate(cell, !flag2); bool is_cell_in_range; if (flag2) { updateCount = 0; PathFinder.Cell cell_data = PathGrid.GetCell(cell, nav_type, out is_cell_in_range); PathFinder.PotentialPath potential_path = new PathFinder.PotentialPath(cell, nav_type, flags); PathFinder.AddPotential(potential_path, Grid.InvalidCell, NavType.NumNavTypes, 0, 0, -1, Potentials, PathGrid, ref cell_data); } int num = (potentialCellsPerUpdate > 0 && !flag) ? potentialCellsPerUpdate : 2147483647; updateCount++; while (Potentials.Count > 0 && num > 0) { KeyValuePair <int, PathFinder.PotentialPath> keyValuePair = Potentials.Next(); num--; PathFinder.Cell cell2 = PathGrid.GetCell(keyValuePair.Value, out is_cell_in_range); if (cell2.cost == keyValuePair.Key) { PathFinder.AddPotentials(scratchPad, keyValuePair.Value, cell2.cost, cell2.underwaterCost, ref abilities, null, nav_grid.maxLinksPerCell, nav_grid.Links, Potentials, PathGrid, cell2.parent, cell2.parentNavType); } } bool flag3 = Potentials.Count == 0; PathGrid.EndUpdate(flag3); if (flag3 && updateCount > 25) { KProfiler.AddEvent("PathProberUpdateCountExceeded"); } }
public void SetCell(PathFinder.PotentialPath potential_path, ref PathFinder.Cell cell_data) { int num = OffsetCell(potential_path.cell); if (num != -1) { cell_data.queryId = serialNo; int num2 = NavTypeTable[(uint)potential_path.navType]; int num3 = num * ValidNavTypes.Length + num2; Cells[num3] = cell_data; if (potential_path.navType != NavType.Tube) { ProberCell proberCell = ProberCells[num]; if (cell_data.queryId != proberCell.queryId || cell_data.cost < proberCell.cost) { proberCell.queryId = cell_data.queryId; proberCell.cost = cell_data.cost; ProberCells[num] = proberCell; freshlyOccupiedCells.Add(potential_path.cell); } } } }