What is the difference between directly updating the walkability of a tile via graph updates like described here docs with the following code (only updating a single tile for simplicity):
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx =>
{
var gg = AstarPath.active.data.gridGraph;
var node = gg.GetNode(0, 0);
node.Walkable = false;
gg.GetNodes(node => gg.CalculateConnections((GridNodeBase) node));
}));
and using a grid graph rule like so (I have no idea how to select a specific node here so it’s probably broken code):
public override void Register (GridGraphRules rules) {
rules.AddMainThreadPass(Pass.BeforeConnections, context => {
var nodeWalkable = context.data.nodeWalkable;
var nodePositions = context.data.nodePositions;
for (int i = 0; i < nodePositions.Length; i++) {
nodeWalkable[i] &= false;
}
});
}
In my use case, a player can place or remove obstacles on the grid graph frequently. I just want to let the grid know when that happens and update it for that one specific tile, so the visualization also updates. Which one of these methods is preferable for such use case, and what is the difference?