public override void Open (Path path, PathNode pathNode, PathHandler handler) {
if (connections == null) return;
for (int i = 0; i < connections.Length; i++) {
GraphNode other = connections[i].node;
if (path.CanTraverse(other)) {
PathNode pathOther = handler.GetPathNode(other);
if (pathOther.pathID != handler.PathID) {
pathOther.parent = pathNode;
pathOther.pathID = handler.PathID;
pathOther.cost = connections[i].cost;
pathOther.H = path.CalculateHScore(other);
pathOther.UpdateG(path);
handler.heap.Add(pathOther);
} else {
//If not we can test if the path from this node to the other one is a better one then the one already used
uint tmpCost = connections[i].cost;
if (pathNode.G + tmpCost + path.GetTraversalCost(other) < pathOther.G) {
pathOther.cost = tmpCost;
pathOther.parent = pathNode;
other.UpdateRecursiveG(path, pathOther, handler);
}
}
}
}
}