private static Path CalculateLowlevelPath(VoxelGraph graph, Vector3I from, List <Vector3I> to) { var start = graph.GetNode(from) ?? graph.GetClosestNode(from, 5); if (start == null) { return(null); } var targets = to.Select(graph.GetNode).Where(t => t != null).ToList(); if (targets.Count == 0) { return(null); } var path = new Path(start, targets, graph.GetPathRegistry()); path.Thread = new Thread(() => { path = AStar.GetPath(start, targets, path); path.Finished = true; path.State = PathState.Ready; }); path.Thread.Start(); return(path); }
private static Path CalculateHighlevelPath(VoxelGraph graph, Vector3I from, List <Vector3I> to) { var start = graph.GetNode(from) ?? graph.GetClosestNode(from, 5); if (start == null) { return(null); } var targets = to.Select(graph.GetNode).Where(t => t != null).ToList(); if (targets.Count == 0) { return(null); } var path = new HighLevelPath(start, targets, graph); path.Thread = new Thread(() => { path = (HighLevelPath)AStar.GetPath(start.SuperNodes.ToDictionary(n => n.Key as Node, n => n.Value.Length), targets.Select(t => t.GetClosestSuperNode()).ToList(), path); path.Finished = true; }); path.Thread.Start(); return(path); }