示例#1
0
        public override AStarPlanResponse HandleRequest(AstarPlanRequest req)
        {
            // If there are no subscribers that want this request, it must be old. So remove it.
            if (Subscribers.Find(s => s.ID == req.Subscriber.ID) == null)
            {
                return(new AStarPlanResponse
                {
                    Path = null,
                    Success = false,
                    Request = req,
                    Result = AStarPlanner.PlanResultCode.Cancelled
                });
            }

            AStarPlanner.PlanResultCode result;
            List <MoveAction>           path = AStarPlanner.FindPath(req.Sender.Movement, req.Start, req.GoalRegion, req.Sender.Manager.World.ChunkManager,
                                                                     req.MaxExpansions, req.HeuristicWeight, Requests.Count, () => { return(Subscribers.Find(s => s.ID == req.Subscriber.ID && s.CurrentRequestID == req.ID) != null); }, out result);

            AStarPlanResponse res = new AStarPlanResponse
            {
                Path    = path,
                Success = (path != null),
                Request = req,
                Result  = result
            };

            return(res);
        }
示例#2
0
        public override AStarPlanResponse HandleRequest(AstarPlanRequest req)
        {
            List <Creature.MoveAction> path = AStarPlanner.FindPath(req.Sender.Movement, req.Start, req.GoalRegion, PlayState.ChunkManager, req.MaxExpansions, req.HeuristicWeight);

            AStarPlanResponse res = new AStarPlanResponse
            {
                Path    = path,
                Success = (path != null)
            };

            return(res);
        }
示例#3
0
        public static bool PathExists(Voxel voxA, Voxel voxB, CreatureAI creature)
        {
            var path = AStarPlanner.FindPath(creature.Movement, voxA, new VoxelGoalRegion(voxB), PlayState.ChunkManager, 1000, 10);

            return(path != null && path.Count > 0);
        }