private List <AbstractPathNode> GetPath(HierarchicalMap map, Id <AbstractNode> startNodeId, Id <AbstractNode> targetNodeId, int level, bool mainSearch) { map.SetCurrentLevelForSearches(level); var nodeInfo = map.AbstractGraph.GetNodeInfo(startNodeId); // TODO: This could be perfectly replaced by cached paths in the clusters! Path <AbstractNode> path; if (!mainSearch) { map.SetCurrentClusterByPositionAndLevel(nodeInfo.Position, level + 1); var edgeInfo = map.AbstractGraph.GetEdges(startNodeId)[targetNodeId].Info; path = new Path <AbstractNode>(edgeInfo.InnerLowerLevelPath, edgeInfo.Cost); } else { map.SetAllMapAsCurrentCluster(); var search = new AStar <AbstractNode>(map, startNodeId, targetNodeId); path = search.FindPath(); } if (path.PathCost == -1) { return(new List <AbstractPathNode>()); } var result = new List <AbstractPathNode>(path.PathNodes.Count); foreach (Id <AbstractNode> abstractNodeId in path.PathNodes) { result.Add(new AbstractPathNode(abstractNodeId, level)); } return(result); }