// Token: 0x06002745 RID: 10053 RVA: 0x001AD344 File Offset: 0x001AB544 public static bool UpdateGraphsNoBlock(GraphUpdateObject guo, List <GraphNode> nodes, bool alwaysRevert = false) { for (int i = 0; i < nodes.Count; i++) { if (!nodes[i].Walkable) { return(false); } } guo.trackChangedNodes = true; PathProcessor.GraphUpdateLock graphUpdateLock = AstarPath.active.PausePathfinding(); bool flag; try { AstarPath.active.UpdateGraphs(guo); AstarPath.active.FlushGraphUpdates(); flag = PathUtilities.IsPathPossible(nodes); if (!flag || alwaysRevert) { guo.RevertFromBackup(); AstarPath.active.FloodFill(); } } finally { graphUpdateLock.Release(); } guo.trackChangedNodes = false; return(flag); }
public static bool UpdateGraphsNoBlock(GraphUpdateObject guo, List <GraphNode> nodes, bool alwaysRevert = false) { for (int i = 0; i < nodes.Count; i++) { if (!nodes[i].Walkable) { return(false); } } guo.trackChangedNodes = true; bool worked = true; AstarPath.RegisterSafeUpdate(delegate { AstarPath.active.UpdateGraphs(guo); AstarPath.active.FlushGraphUpdates(); worked = (worked && PathUtilities.IsPathPossible(nodes)); if (!worked || alwaysRevert) { guo.RevertFromBackup(); AstarPath.active.FloodFill(); } }); AstarPath.active.FlushThreadSafeCallbacks(); guo.trackChangedNodes = false; return(worked); }
/// <summary> /// Updates graphs and checks if all nodes are still reachable from each other. /// Graphs are updated, then a check is made to see if the nodes are still reachable from each other. /// If they are not, the graphs are reverted to before the update and false is returned. /// This is slower than a normal graph update. /// All queued graph updates will be flushed during this function. /// /// Returns: True if the given nodes are still reachable from each other after the guo has been applied. False otherwise. /// </summary> /// <param name="guo">The GraphUpdateObject to update the graphs with</param> /// <param name="nodes">Nodes which should have valid paths between them. All nodes should be walkable or false will be returned.</param> /// <param name="alwaysRevert">If true, reverts the graphs to the old state even if no blocking occurred</param> public static bool UpdateGraphsNoBlock(GraphUpdateObject guo, List <GraphNode> nodes, bool alwaysRevert = false) { bool worked; // Pause pathfinding while modifying the graphs var graphLock = AstarPath.active.PausePathfinding(); try { // Make sure any pending graph updates have been done before we start AstarPath.active.FlushGraphUpdates(); // Make sure all nodes are walkable for (int i = 0; i < nodes.Count; i++) { if (!nodes[i].Walkable) { return(false); } } // Track changed nodes to enable reversion of the guo guo.trackChangedNodes = true; AstarPath.active.UpdateGraphs(guo); // Update the graphs immediately AstarPath.active.FlushGraphUpdates(); // Check if all nodes are in the same area and that they are walkable, i.e that there are paths between all of them worked = PathUtilities.IsPathPossible(nodes); // If it did not work, revert the GUO if (!worked || alwaysRevert) { guo.RevertFromBackup(); // Recalculate connected components AstarPath.active.hierarchicalGraph.RecalculateIfNecessary(); } } finally { graphLock.Release(); } // Disable tracking nodes, not strictly necessary, but will slightly reduce the cance that some user causes errors guo.trackChangedNodes = false; return(worked); }
/** Updates graphs and checks if all nodes are still reachable from each other. * Graphs are updated, then a check is made to see if the nodes are still reachable from each other. * If they are not, the graphs are reverted to before the update and \a false is returned. * This is slower than a normal graph update. * All queued graph updates and thread safe callbacks will be flushed during this function. * * \note This might return true for small areas even if there is no possible path if AstarPath.minAreaSize is greater than zero (0). * So when using this, it is recommended to set AstarPath.minAreaSize to 0. (A* Inspector -> Settings -> Pathfinding) * * \param guo The GraphUpdateObject to update the graphs with * \param nodes Nodes which should have valid paths between them. All nodes should be walkable or \a false will be returned. * \param alwaysRevert If true, reverts the graphs to the old state even if no blocking ocurred */ public static bool UpdateGraphsNoBlock(GraphUpdateObject guo, List <GraphNode> nodes, bool alwaysRevert = false) { //Make sure all nodes are walkable for (int i = 0; i < nodes.Count; i++) { if (!nodes[i].Walkable) { return(false); } } //Track changed nodes to enable reversion of the guo guo.trackChangedNodes = true; bool worked = true; AstarPath.RegisterSafeUpdate(delegate() { AstarPath.active.UpdateGraphs(guo); //Make sure graph updates are registered for update and not delayed for performance AstarPath.active.QueueGraphUpdates(); //Call thread safe callbacks, includes graph updates AstarPath.active.FlushGraphUpdates(); //Check if all nodes are in the same area and that they are walkable, i.e that there are paths between all of them worked = worked && PathUtilities.IsPathPossible(nodes); //If it did not work, revert the GUO if (!worked || alwaysRevert) { guo.RevertFromBackup(); //The revert operation does not revert ALL nodes' area values, so we must flood fill again AstarPath.active.FloodFill(); } }, true); //Force the thread safe callback to be called AstarPath.active.FlushThreadSafeCallbacks(); //Disable tracking nodes, not strictly necessary, but will slightly reduce the cance that some user causes errors guo.trackChangedNodes = false; return(worked); }
/** Updates graphs and checks if all nodes are still reachable from each other. * Graphs are updated, then a check is made to see if the nodes are still reachable from each other. * If they are not, the graphs are reverted to before the update and \a false is returned. * This is slower than a normal graph update. * All queued graph updates will be flushed during this function. * * \note This might return true for small areas even if there is no possible path if AstarPath.minAreaSize is greater than zero (0). * So when using this, it is recommended to set AstarPath.minAreaSize to 0. (A* Inspector -> Settings -> Pathfinding) * * \param guo The GraphUpdateObject to update the graphs with * \param nodes Nodes which should have valid paths between them. All nodes should be walkable or \a false will be returned. * \param alwaysRevert If true, reverts the graphs to the old state even if no blocking occurred * * \returns True if the given nodes are still reachable from each other after the \a guo has been applied. False otherwise. */ public static bool UpdateGraphsNoBlock(GraphUpdateObject guo, List <GraphNode> nodes, bool alwaysRevert = false) { // Make sure all nodes are walkable for (int i = 0; i < nodes.Count; i++) { if (!nodes[i].Walkable) { return(false); } } // Track changed nodes to enable reversion of the guo guo.trackChangedNodes = true; bool worked; // Pause pathfinding while modifying the graphs var graphLock = AstarPath.active.PausePathfinding(); try { AstarPath.active.UpdateGraphs(guo); // Update the graphs immediately AstarPath.active.FlushGraphUpdates(); // Check if all nodes are in the same area and that they are walkable, i.e that there are paths between all of them worked = PathUtilities.IsPathPossible(nodes); // If it did not work, revert the GUO if (!worked || alwaysRevert) { guo.RevertFromBackup(); // The revert operation does not revert ALL nodes' area values, so we must flood fill again AstarPath.active.FloodFill(); } } finally { graphLock.Release(); } // Disable tracking nodes, not strictly necessary, but will slightly reduce the cance that some user causes errors guo.trackChangedNodes = false; return(worked); }
/** Updates graphs and checks if all nodes are still reachable from each other. * Graphs are updated, then a check is made to see if the nodes are still reachable from each other. * If they are not, the graphs are reverted to before the update and \a false is returned. * This is slower than a normal graph update. * All queued graph updates and thread safe callbacks will be flushed during this function. * * \note This might return true for small areas even if there is no possible path if AstarPath.minAreaSize is greater than zero (0). * So when using this, it is recommended to set AstarPath.minAreaSize to 0. (A* Inspector -> Settings -> Pathfinding) * * \param guo The GraphUpdateObject to update the graphs with * \param nodes Nodes which should have valid paths between them. All nodes should be walkable or \a false will be returned. * \param alwaysRevert If true, reverts the graphs to the old state even if no blocking ocurred */ public static bool UpdateGraphsNoBlock (GraphUpdateObject guo, List<GraphNode> nodes, bool alwaysRevert = false) { //Make sure all nodes are walkable for (int i=0;i<nodes.Count;i++) if (!nodes[i].Walkable) return false; //Track changed nodes to enable reversion of the guo guo.trackChangedNodes = true; bool worked = true; AstarPath.RegisterSafeUpdate (delegate () { AstarPath.active.UpdateGraphs (guo); //Make sure graph updates are registered for update and not delayed for performance AstarPath.active.QueueGraphUpdates (); //Call thread safe callbacks, includes graph updates AstarPath.active.FlushGraphUpdates(); //Check if all nodes are in the same area and that they are walkable, i.e that there are paths between all of them worked = worked && PathUtilities.IsPathPossible (nodes); //If it did not work, revert the GUO if (!worked || alwaysRevert) { guo.RevertFromBackup (); //The revert operation does not revert ALL nodes' area values, so we must flood fill again AstarPath.active.FloodFill (); } },true); //Force the thread safe callback to be called AstarPath.active.FlushThreadSafeCallbacks(); //Disable tracking nodes, not strictly necessary, but will slightly reduce the cance that some user causes errors guo.trackChangedNodes = false; return worked; }
private bool WillBlockPathInternal (GraphUpdateObject ob, Node n1, Node n2) { if (n1.area != n2.area) return true; ob.trackChangedNodes = true; foreach (IUpdatableGraph g in astarData.GetUpdateableGraphs ()) { g.UpdateArea (ob); } FloodFill (); bool returnVal = n1.area != n2.area; ob.RevertFromBackup (); FloodFill (); return returnVal; }