예제 #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);
        }