コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: PathFinder.cs プロジェクト: huwpascoe/OpenRA
        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);
        }
コード例 #3
0
ファイル: PathFinder.cs プロジェクト: ushardul/OpenRA
        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;
        }
コード例 #4
0
ファイル: PathFinder.cs プロジェクト: pchote/OpenRA
        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;
        }