public List <CPos> FindPath(PathSearch search) { using (new PerfSample("Pathfinder")) { using (search) { List <CPos> path = null; while (!search.queue.Empty) { var p = search.Expand(world); if (search.heuristic(p) == 0) { path = MakePath(search.cellInfo, p); break; } } var dbg = world.WorldActor.TraitOrDefault <DebugOverlay>(); if (dbg != null) { dbg.AddLayer(search.considered.Select(p => new Pair <CPos, int>(p, search.cellInfo[p.X, p.Y].MinCost)), search.maxCost, search.owner); } if (path != null) { return(path); } } // no path exists return(emptyPath); } }
public List <CPos> FindPath(PathSearch search) { using (new PerfSample("Pathfinder")) { using (search) while (!search.queue.Empty) { var p = search.Expand(world); if (search.heuristic(p) == 0) { return(MakePath(search.cellInfo, p)); } } // no path exists return(new List <CPos>(0)); } }