public List<CPos> FindPath(IPathSearch search) { List<CPos> path = null; while (search.CanExpand) { var p = search.Expand(); if (search.IsTarget(p)) { path = MakePath(search.Graph, p); break; } } search.Graph.Dispose(); if (path != null) return path; // no path exists return EmptyPath; }
public List <CPos> FindPath(IPathSearch search) { var dbg = world.WorldActor.TraitOrDefault <PathfinderDebugOverlay>(); if (dbg != null && dbg.Visible) { search.Debug = true; } List <CPos> path = null; while (search.CanExpand) { var p = search.Expand(); if (search.IsTarget(p)) { path = MakePath(search.Graph, p); break; } } if (dbg != null && dbg.Visible) { dbg.AddLayer(search.Considered, search.MaxCost, search.Owner); } search.Graph.Dispose(); if (path != null) { return(path); } // no path exists return(EmptyPath); }
public List<CPos> FindPath(IPathSearch search) { var dbg = world.WorldActor.TraitOrDefault<PathfinderDebugOverlay>(); if (dbg != null && dbg.Visible) search.Debug = true; List<CPos> path = null; while (!search.OpenQueue.Empty) { var p = search.Expand(); if (search.IsTarget(p)) { path = MakePath(search.Graph, p); break; } } if (dbg != null && dbg.Visible) dbg.AddLayer(search.Considered, search.MaxCost, search.Owner); search.Graph.Dispose(); if (path != null) return path; // no path exists return EmptyPath; }