/// <summary>
 /// Initializes a new instance of the <see cref="PathResult"/> class.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <param name="path">The path.</param>
 /// <param name="pathCost">The cost of the path, i.e. its length and combined cost of the cells involved</param>
 /// <param name="originalRequest">The original request.</param>
 public PathResult(PathingStatus status, Path path, int pathCost, IPathRequest originalRequest)
 {
     this.status = status;
     this.path = path ?? _pathEmpty;
     this.pathCost = pathCost;
     this.originalRequest = originalRequest;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PathResult"/> class.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <param name="path">The path.</param>
 /// <param name="pathCost">The cost of the path, i.e. its length and combined cost of the cells involved</param>
 /// <param name="originalRequest">The original request.</param>
 public PathResult(PathingStatus status, Path path, int pathCost, IPathRequest originalRequest)
 {
     this.status          = status;
     this.path            = path ?? _pathEmpty;
     this.pathCost        = pathCost;
     this.originalRequest = originalRequest;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PathResult"/> class.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <param name="path">The path.</param>
 /// <param name="pathCost">The cost of the path, i.e. its length and combined cost of the cells involved</param>
 /// <param name="originalRequest">The original request.</param>
 public PathResult(PathingStatus status, Path path, int pathCost, IPathRequest originalRequest)
     : this()
 {
     this.status           = status;
     this.path             = path ?? _pathEmpty;
     this.pathCost         = pathCost;
     this.originalRequest  = originalRequest;
     this.pendingWaypoints = originalRequest.pendingWaypoints;
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PathResult"/> class.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <param name="path">The path.</param>
 /// <param name="pathCost">The cost of the path, i.e. its length and combined cost of the cells involved</param>
 /// <param name="originalRequest">The original request.</param>
 public PathResult(PathingStatus status, Path path, int pathCost, IPathRequest originalRequest)
     : this()
 {
     this.status = status;
     this.path = path ?? _pathEmpty;
     this.pathCost = pathCost;
     this.originalRequest = originalRequest;
     this.pendingWaypoints = originalRequest.pendingWaypoints;
 }
        internal void RegisterPartialResult(PathingStatus status, Vector3[] pendingWaypoints)
        {
            this.status = PathingStatus.CompletePartial;

            this.innerResult = new InnerResultData
            {
                status           = status,
                pendingWaypoints = pendingWaypoints
            };
        }
Exemple #6
0
        private void CompleteRequest(PathingStatus status)
        {
            PathResult result;

            if (_currentRequest.type == RequestType.IntelOnly)
            {
                result = new PathResult(status, null, _goal.g, _currentRequest);
            }
            else if (status == PathingStatus.Complete)
            {
                Path path;

                var maxPathLength = Mathf.CeilToInt(_goal.g / (_goal.parent.cellSize * _costProvider.baseMoveCost));

                //Fix the actual destination so it does not overlap obstructions
                FixupGoal(_currentRequest);

                if (_currentRequest.pathFinderOptions.usePathSmoothing)
                {
                    path = _smoother.Smooth(_goal, maxPathLength, _currentRequest, _cellCostStrategy);
                }
                else
                {
                    path = new Path(maxPathLength);

                    //Push the actual end position as the goal
                    path.Push(new Position(_currentRequest.to));

                    IPathNode current = _goal.predecessor;
                    while (current != null)
                    {
                        path.Push(current);
                        current = current.predecessor;
                    }

                    //Instead of testing for it in the while loop, just pop off the start node and replace it with the actual start position
                    if (path.count > 1)
                    {
                        path.Pop();
                    }

                    path.Push(new Position(_currentRequest.from));
                }

                result = new PathResult(status, path, _goal.g, _currentRequest);
            }
            else
            {
                result = new PathResult(status, null, 0, _currentRequest);
            }

            _currentRequest.Complete(result);
            _currentRequest = null;
        }
Exemple #7
0
        private bool CompletePathSegment(PathingStatus status)
        {
            if (status != PathingStatus.Complete)
            {
                return(false);
            }

            _currentResult.pathCost += _goal.g;

            //Fix the actual destination so it does not overlap obstructions
            FixupGoal(_segmentRequest);

            if (_segmentRequest.type == RequestType.IntelOnly)
            {
                return(true);
            }

            var maxPathLength = Mathf.CeilToInt(_goal.g / (_goal.parent.cellSize * _costProvider.baseMoveCost));

            Path pathSegment;

            if (_segmentRequest.pathFinderOptions.usePathSmoothing)
            {
                pathSegment = _smoother.Smooth(_goal, maxPathLength, _segmentRequest, _cellCostStrategy);
            }
            else
            {
                pathSegment = new Path(maxPathLength);

                //Push the actual end position as the goal
                pathSegment.Push(new Position(_segmentRequest.to));

                IPathNode current = _goal.predecessor;
                while (current != null)
                {
                    pathSegment.Push(current);
                    current = current.predecessor;
                }

                //Instead of testing for it in the while loop, just pop off the start node and replace it with the actual start position
                if (pathSegment.count > 1)
                {
                    pathSegment.Pop();
                }

                pathSegment.Push(new Position(_segmentRequest.from));
            }

            _segments.Add(pathSegment);

            return(true);
        }
        private bool CompletePathSegment(PathingStatus status)
        {
            if (status != PathingStatus.Complete)
            {
                return false;
            }

            _currentResult.pathCost += _goal.g;

            //Fix the actual destination so it does not overlap obstructions
            FixupGoal(_segmentRequest);

            if (_segmentRequest.type == RequestType.IntelOnly)
            {
                return true;
            }

            var maxPathLength = Mathf.CeilToInt(_goal.g / (_goal.parent.cellSize * _costProvider.baseMoveCost));

            Path pathSegment;
            if (_segmentRequest.pathFinderOptions.usePathSmoothing)
            {
                pathSegment = _smoother.Smooth(_goal, maxPathLength, _segmentRequest, _cellCostStrategy);
            }
            else
            {
                pathSegment = new Path(maxPathLength);

                //Push the actual end position as the goal
                pathSegment.Push(new Position(_segmentRequest.to));

                IPathNode current = _goal.predecessor;
                while (current != null)
                {
                    pathSegment.Push(current);
                    current = current.predecessor;
                }

                //Instead of testing for it in the while loop, just pop off the start node and replace it with the actual start position
                if (pathSegment.count > 1)
                {
                    pathSegment.Pop();
                }

                pathSegment.Push(new Position(_segmentRequest.from));
            }

            _segments.Add(pathSegment);

            return true;
        }
        internal void RegisterPartialResult(PathingStatus status, Vector3[] pendingWaypoints)
        {
            this.status = PathingStatus.CompletePartial;

            this.innerResult = new InnerResultData
            {
                status = status,
                pendingWaypoints = pendingWaypoints
            };
        }
Exemple #10
0
 /// <summary>
 /// Factory method to create a failure result
 /// </summary>
 /// <param name="status">The status.</param>
 /// <param name="originalRequest">The original request.</param>
 /// <returns>The result</returns>
 public static DirectPathResult Fail(PathingStatus status, IPathRequest originalRequest)
 {
     return new DirectPathResult(status, originalRequest);
 }
Exemple #11
0
 private DirectPathResult(PathingStatus status, IPathRequest originalRequest)
     : base(status, null, 0, originalRequest)
 {
 }
Exemple #12
0
        private void CompleteRequest(PathingStatus status)
        {
            if (status == PathingStatus.Complete)
            {
                StackWithLookAhead<IPositioned> path;
                var maxPathLength = Mathf.CeilToInt(_goal.g / (_goal.parent.cellSize * _costProvider.baseMoveCost));

                //Fix the actual destination so it does not overlap obstructions
                FixupGoal(_currentRequest);

                if (_currentRequest.usePathSmoothing)
                {
                    path = _smoother.Smooth(_goal, maxPathLength, _currentRequest);
                }
                else
                {
                    path = new StackWithLookAhead<IPositioned>(maxPathLength);

                    //Push the actual end position as the goal
                    path.Push(new Position(_currentRequest.to));

                    IPathNode current = _goal.predecessor;
                    while (current != null)
                    {
                        path.Push(current);
                        current = current.predecessor;
                    }

                    //Instead of testing for it in the while loop, just pop off the start node and replace it with the actual start position
                    if (path.count > 1)
                    {
                        path.Pop();
                    }

                    path.Push(new Position(_currentRequest.from));
                }

                _currentRequest.Complete(status, path);
            }
            else
            {
                _currentRequest.Complete(status, null);
            }

            _currentRequest = null;
        }
Exemple #13
0
 /// <summary>
 /// Factory method to create a failure result
 /// </summary>
 /// <param name="status">The status.</param>
 /// <param name="originalRequest">The original request.</param>
 /// <returns>The result</returns>
 public static DirectPathResult Fail(PathingStatus status, IPathRequest originalRequest)
 {
     return(new DirectPathResult(status, originalRequest));
 }
Exemple #14
0
 private DirectPathResult(PathingStatus status, IPathRequest originalRequest)
     : base(status, null, 0, originalRequest)
 {
 }