private void RequestPath(Vector3 from, Vector3 to, InternalPathRequest.Type type)
        {
            var unit = this.GetUnitFacade();

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

                _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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        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);
        }