public List <PathNode> FindPath(string startSystem, string endSystem) { ClearPathData(); PathNode start = nodes[startSystem], end = nodes[endSystem]; AddToOpenSet(start, null, end, 0.0f); while (openSet.Count > 0) { // Take the node off the top of the open set and add it to the closed set PathNode current = openSet[0]; openSet.RemoveAt(0); current.Closed = true; if (current == end) { List <PathNode> path = new List <PathNode>(); while (current != null) { path.Insert(0, current); current = current.Parent; } return(path); } // Add its neighbors to the open list if (current.Neighbors == null) { current.ComputeNeighbors(nodes.Values.ToList(), jump); } foreach (KeyValuePair <PathNode, float> pair in current.Neighbors) { if (pair.Key.Closed) { continue; } AddToOpenSet(pair.Key, current, end, pair.Value); } } return(null); }