Esempio n. 1
0
        public static PathSearch ToTargetCellByPredicate(
            World world, Locomotor locomotor, Actor self, IEnumerable <CPos> froms, Func <CPos, bool> targetPredicate, BlockedByActor check,
            Func <CPos, int> customCost = null,
            Actor ignoreActor           = null,
            bool laneBias = true)
        {
            var graph  = new MapPathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, ignoreActor, laneBias, false);
            var search = new PathSearch(graph, loc => 0, DefaultHeuristicWeightPercentage, targetPredicate);

            foreach (var sl in froms)
            {
                if (world.Map.Contains(sl))
                {
                    search.AddInitialCell(sl);
                }
            }

            return(search);
        }
Esempio n. 2
0
        public static PathSearch ToTargetCell(
            World world, Locomotor locomotor, Actor self, IEnumerable <CPos> froms, CPos target, BlockedByActor check,
            Func <CPos, int> customCost = null,
            Actor ignoreActor           = null,
            bool laneBias                 = true,
            bool inReverse                = false,
            Func <CPos, int> heuristic    = null,
            int heuristicWeightPercentage = DefaultHeuristicWeightPercentage)
        {
            var graph = new MapPathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, ignoreActor, laneBias, inReverse);

            heuristic = heuristic ?? DefaultCostEstimator(locomotor, target);
            var search = new PathSearch(graph, heuristic, heuristicWeightPercentage, loc => loc == target);

            foreach (var sl in froms)
            {
                if (world.Map.Contains(sl))
                {
                    search.AddInitialCell(sl);
                }
            }

            return(search);
        }