public override int GetSubmergedPathCostPenalty(PathFinder.PotentialPath path, NavGrid.Link link) { if (!path.HasAnyFlag(PathFinder.PotentialPath.Flags.HasAtmoSuit | PathFinder.PotentialPath.Flags.HasJetPack)) { return(link.cost * 2); } return(0); }
public static bool Prefix(Navigator ___navigator, ref bool __result, ref PathFinder.PotentialPath path, int from_cell, NavType from_nav_type, int cost, int transition_id, int underwater_cost) { if (___navigator.NavGridName != "RobotNavGrid") { return(true); } return(PathFilter(ref __result, ref path, from_cell, from_nav_type, cost, transition_id, underwater_cost)); }
public override bool TraversePath(ref PathFinder.PotentialPath path, int from_cell, NavType from_nav_type, int cost, int transition_id, int underwater_cost) { if (underwater_cost > maxUnderwaterCost) { return(false); } return(true); }
public static void Postfix(ref bool __result, ref PathFinder.PotentialPath path) { int toCell = path.cell; bool doorCheck = false; if (CritterPathingPatches.config.TreatDefaultDoorsAsCritterProof) { doorCheck = (Grid.BuildMasks[toCell] & Grid.BuildFlags.Door) != 0; } else { doorCheck = critterProofDoorCells.ContainsKey(toCell); } if (__result && doorCheck) { __result = false; } }
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); } } } }
public static bool Prefix(ref bool __result, ref PathFinder.PotentialPath path, int from_cell, NavType from_nav_type, int cost, int transition_id, int underwater_cost) { return(PathFilter(ref __result, ref path, from_cell, from_nav_type, cost, transition_id, underwater_cost)); }
// 寻路限制 public static bool PathFilter(ref bool __result, ref PathFinder.PotentialPath path, int from_cell, NavType from_nav_type, int cost, int transition_id, int underwater_cost) { int cell = path.cell; if (MyGrid.IsBlocked(cell)) { __result = false; return(false); } if (path.navType != NavType.Floor || from_nav_type != NavType.Floor) { return(true); } int f_b = Grid.CellBelow(from_cell); bool cellNotStair = !MyGrid.IsStair(cell); bool fromStair = MyGrid.IsStair(from_cell); bool fromNotScaff = !MyGrid.IsScaffolding(from_cell); //if (!MyGrid.IsStair(f_b) && !fromStair && cellNotStair && !MyGrid.IsScaffolding(cell) && fromNotScaff) return true; CellOffset offset = Grid.GetOffset(from_cell, cell); bool goUpAndStr = offset.y >= 0; if (goUpAndStr) { bool goStraight = offset.y == 0; if (fromStair && goStraight) { return(true); } if (!fromNotScaff && goStraight) { return(true); } bool flag = true; int f_a = Grid.CellAbove(from_cell); if (offset.y > 1) { int f_a_a = Grid.CellAbove(f_a); if (MyGrid.IsScaffolding(f_a) || MyGrid.IsScaffolding(f_a_a)) { flag = false; } } else if (offset.y == 1) { if (MyGrid.IsScaffolding(cell)) { if (MyGrid.IsWalkable(f_b)) { int c_b = Grid.CellBelow(cell); if (!MyGrid.IsWalkable(c_b)) { flag = false; } } else if (MyGrid.IsScaffolding(f_a)) { flag = false; } } else if (MyGrid.IsScaffolding(f_a)) { flag = false; } } if (MyGrid.IsRightSet(f_b)) { if (!fromStair) { if (goUpAndStr && flag) { return(true); } else if (offset.x > 0 && flag) { return(true); } } } else { if (!fromStair) { if (goUpAndStr && flag) { return(true); } else if (offset.x < 0 && flag) { return(true); } } } } else if (cellNotStair) { if (offset.x > 0) { int f_r = Grid.CellRight(from_cell); if (offset.y == -1) { if (MyGrid.IsRightSet(f_b) && MyGrid.IsStair(f_b)) { if (!fromStair) { return(true); } } else if (!MyGrid.IsScaffolding(f_r)) { return(true); } } else { int f_b_r = Grid.CellRight(f_b); if (!MyGrid.IsStair(f_b_r) && !MyGrid.IsScaffolding(f_r) && !MyGrid.IsScaffolding(f_b_r)) { return(true); } } } else if (offset.x < 0) { int f_l = Grid.CellLeft(from_cell); if (offset.y == -1) { if (!MyGrid.IsRightSet(f_b) && MyGrid.IsStair(f_b)) { if (!fromStair) { return(true); } } else if (!MyGrid.IsScaffolding(f_l)) { return(true); } } else { int f_b_l = Grid.CellLeft(f_b); if (!MyGrid.IsStair(f_b_l) && !MyGrid.IsScaffolding(f_l) && !MyGrid.IsScaffolding(f_b_l)) { return(true); } } } else { if (fromNotScaff) { return(true); } } } __result = false; return(false); }
public override bool TraversePath(ref PathFinder.PotentialPath path, int from_cell, NavType from_nav_type, int cost, int transition_id, int underwater_cost) { if (!IsAccessPermitted(proxyID, path.cell, from_cell)) { return(false); } CellOffset[] array = transitionVoidOffsets[transition_id]; foreach (CellOffset offset in array) { int cell = Grid.OffsetCell(from_cell, offset); if (!IsAccessPermitted(proxyID, cell, from_cell)) { return(false); } } if (path.navType == NavType.Tube && from_nav_type == NavType.Floor && !Grid.HasUsableTubeEntrance(from_cell, prefabInstanceID)) { return(false); } if (path.navType == NavType.Hover && (out_of_fuel || !path.HasFlag(PathFinder.PotentialPath.Flags.HasJetPack))) { return(false); } Grid.SuitMarker.Flags flags = (Grid.SuitMarker.Flags) 0; PathFinder.PotentialPath.Flags pathFlags = PathFinder.PotentialPath.Flags.None; bool flag = path.HasFlag(PathFinder.PotentialPath.Flags.PerformSuitChecks) && Grid.TryGetSuitMarkerFlags(from_cell, out flags, out pathFlags) && (flags & Grid.SuitMarker.Flags.Operational) != (Grid.SuitMarker.Flags) 0; bool flag2 = SuitMarker.DoesTraversalDirectionRequireSuit(from_cell, path.cell, flags); bool flag3 = path.HasAnyFlag(PathFinder.PotentialPath.Flags.HasAtmoSuit | PathFinder.PotentialPath.Flags.HasJetPack); if (flag) { bool flag4 = path.HasFlag(pathFlags); if (flag2) { if (!flag3 && !Grid.HasSuit(from_cell, prefabInstanceID)) { return(false); } } else if (flag3 && (flags & Grid.SuitMarker.Flags.OnlyTraverseIfUnequipAvailable) != 0 && (!flag4 || !Grid.HasEmptyLocker(from_cell, prefabInstanceID))) { return(false); } } if (idleNavMaskEnabled && (Grid.PreventIdleTraversal[path.cell] || Grid.PreventIdleTraversal[from_cell])) { return(false); } if (flag) { if (flag2) { if (!flag3) { path.SetFlags(pathFlags); } } else { path.ClearFlags(PathFinder.PotentialPath.Flags.HasAtmoSuit | PathFinder.PotentialPath.Flags.HasJetPack); } } return(true); }
public PathFinder.Cell GetCell(PathFinder.PotentialPath potential_path, out bool is_cell_in_range) { return(GetCell(potential_path.cell, potential_path.navType, out is_cell_in_range)); }
public virtual int GetSubmergedPathCostPenalty(PathFinder.PotentialPath path, NavGrid.Link link) { return(0); }
public abstract bool TraversePath(ref PathFinder.PotentialPath path, int from_cell, NavType from_nav_type, int cost, int transition_id, int underwater_cost);