/// <summary>
        /// Requests the path.
        /// </summary>
        /// <param name="request">The request.</param>
        public void RequestPath(IPathRequest request)
        {
            var unit = this.GetUnitFacade();

            request           = InternalPathRequest.Internalize(request);
            request.timeStamp = Time.time;

            lock (_syncLock)
            {
                request.requester           = this;
                request.requesterProperties = unit;

                if (_pendingPathRequest != null)
                {
                    _pendingPathRequest.hasDecayed = true;
                }

                _pendingPathRequest = request;

                _stop    = false;
                _stopped = false;
            }

            GameServices.pathService.QueueRequest(_pendingPathRequest, unit.pathFinderOptions.pathingPriority);
        }
            internal static InternalPathRequest Internalize(IPathRequest request)
            {
                var internalized = request as InternalPathRequest;

                if (internalized == null)
                {
                    internalized = new InternalPathRequest();
                    Utils.CopyProps(request, internalized);
                }

                internalized.pathType = Type.Normal;
                return(internalized);
            }
Пример #3
0
        /// <summary>
        /// Requests a path.
        /// </summary>
        /// <param name="request">The request.</param>
        public void RequestPath(IPathRequest request)
        {
            if (this.count == 0)
            {
                // if the group has no members, then no need to request anything
                return;
            }

            request                     = InternalPathRequest.Internalize(request);
            request.requester           = this;
            request.requesterProperties = _modelUnit;

            _pendingPathRequest = request;

            _stopped             = false;
            _lastPathRequestTime = Time.time;
            GameServices.pathService.QueueRequest(_pendingPathRequest, _modelUnit.pathFinderOptions.pathingPriority);
        }
Пример #4
0
            internal static InternalPathRequest Internalize(IPathRequest request)
            {
                var internalized = request as InternalPathRequest;
                if (internalized == null)
                {
                    internalized = new InternalPathRequest();
                    Utils.CopyProps(request, internalized);
                }

                internalized.pathType = Type.Normal;
                return internalized;
            }
Пример #5
0
        private void RequestPath(Vector3 from, Vector3 to, InternalPathRequest.Type type)
        {
            var unit = this.GetUnitFacade();

            lock (_syncLock)
            {
                _pendingPathRequest = new InternalPathRequest
                {
                    from = from,
                    to = to,
                    pathType = type,
                    requester = this,
                    requesterProperties = unit,
                    pathFinderOptions = unit.pathFinderOptions,
                    timeStamp = Time.time
                };

                if (type == InternalPathRequest.Type.Normal)
                {
                    _pendingPathRequest.via = _wayPoints.GetViaPoints();
                }

                _stop = false;
                _stopped = false;
            }

            GameServices.pathService.QueueRequest(_pendingPathRequest, unit.pathFinderOptions.pathingPriority);
        }
        private void RequestPath(Vector3 to, InternalPathRequest.Type type)
        {
            if (this.count == 0)
            {
                // if the group has no members, then no need to request anything
                return;
            }

            // find a valid from position for the group
            Vector3 fromPos = _modelUnit.position;
            var grid = GridManager.instance.GetGrid(fromPos);
            Cell fromCell = grid.GetCell(fromPos, true);
            if (fromCell == null || !fromCell.isWalkable(_modelUnit.attributes))
            {
                fromCell = grid.GetNearestWalkableCell(fromPos, fromPos, false, _modelUnit.pathFinderOptions.maxEscapeCellDistanceIfOriginBlocked, _modelUnit);
                if (fromCell != null)
                {
                    fromPos = fromCell.position;
                }
            }

            // setup the path request
            _pendingPathRequest = new InternalPathRequest
            {
                from = fromPos,
                to = to,
                pathType = type,
                requester = this,
                requesterProperties = _modelUnit,
                pathFinderOptions = _modelUnit.pathFinderOptions
            };

            _stopped = false;
            _lastPathRequestTime = Time.time;
            GameServices.pathService.QueueRequest(_pendingPathRequest, _modelUnit.pathFinderOptions.pathingPriority);
        }
Пример #7
0
        private void RequestPath(Vector3 from, Vector3 to, InternalPathRequest.Type type)
        {
            var unit = this.GetUnitFacade();

            lock (_syncLock)
            {
                _pendingPathRequest = new InternalPathRequest
                {
                    from = from,
                    to = to,
                    pathType = type,
                    requester = this,
                    requesterProperties = unit,
                    pathFinderOptions = unit.pathFinderOptions
                };

                _stop = false;
                _stopped = false;
            }

            _lastPathRequestTime = Time.time;
            GameServices.pathService.QueueRequest(_pendingPathRequest, unit.pathFinderOptions.pathingPriority);
        }