private void GetFinalPath(Node aStartingNode, Node aEndNode, bool isStatic) { // List to hold the path sequentially var finalPath = new List <Node>(); // Node to store the current node being checked var currentNode = aEndNode; // While loop to work through each node going through the parents to the beginning of the path while (currentNode != aStartingNode) { // Add that node to the final path finalPath.Add(currentNode); // Move onto its parent node currentNode = currentNode.ParentNode; } // Reverse the path to get the correct order finalPath.Reverse(); // Set the final path gridReference.FinalPath = finalPath; // static path / dynamic path if (isStatic) { path.CreateStaticPathObjects(); } else { path.UpdateDynamicPathObjects(); OnPathCalculated?.Invoke(); } }
private void SetPath(Path path) { if (path.error) { throw new Exception("Хуевая сетка у А*"); } if (_cancelToken.IsCancellationRequested) { return; } _path = path; _isPathRequested = false; OnPathCalculated?.Invoke(); IsPathCalculated = true; }