bool
UpdateGraphsNoBlock
(
GraphUpdateObject | guo | The GraphUpdateObject to update the graphs with |
GraphNode | node1 | Node which should have a valid path to node2. All nodes should be walkable or false will be returned. |
GraphNode | node2 | Node which should have a valid path to node1. All nodes should be walkable or false will be returned. |
bool | alwaysRevert=false | If true, reverts the graphs to the old state even if no blocking occurred |
)
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 and thread safe callbacks will be flushed during this function.
ReturnTrue if the given nodes are still reachable from each other after the guo has been applied. False otherwise.
var graphUpdate = new GraphUpdateObject(tower.GetComponent<Collider>().bounds);
var spawnPointNode = AstarPath.active.GetNearest(spawnPoint.position).node;
var goalNode = AstarPath.active.GetNearest(goalPoint.position).node;
if (GraphUpdateUtilities.UpdateGraphsNoBlock(graphUpdate, spawnPointNode, goalNode, false)) {
// Valid tower position
// Since the last parameter (which is called "alwaysRevert") in the method call was false
// The graph is now updated and the game can just continue
} else {
// Invalid tower position. It blocks the path between the spawn point and the goal
// The effect on the graph has been reverted
Destroy(tower);
}