示例#1
0
        /// <summary>
        /// Called on Start
        /// </summary>
        protected override void Start()
        {
            base.Start();

            _steerForFormation = this.GetComponent <SteerForFormationComponent>();
            _steerForPath      = this.GetComponent <SteerForPathComponent>();
        }
示例#2
0
        /// <summary>
        /// Called on Start
        /// </summary>
        protected override void Start()
        {
            base.Start();

            _steerForFormation = this.GetComponent<SteerForFormationComponent>();
            _steerForPath = this.GetComponent<SteerForPathComponent>();
        }
        /// <summary>
        /// Processes the result.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="steerer">The steerer.</param>
        /// <returns>
        ///   <c>true</c> if the result was handled by this processor, otherwise <c>false</c>
        /// </returns>
        public override bool HandleResult(PathResult result, SteerForPathComponent steerer)
        {
            switch (result.status)
            {
            case PathingStatus.DestinationBlocked:
            {
                var request = result.originalRequest;

                //Try to find an unobstructed cell as close to the original destination as possible
                var newDestination = request.toGrid.GetNearestWalkableCell(
                    request.to,
                    this.transform.position,
                    false,
                    this.maxCellDistanceForNewDestination,
                    request.requesterProperties);

                if (newDestination != null)
                {
                    request.to = newDestination.position;
                    steerer.RequestPath(request);
                    return(true);
                }

                break;
            }
            }

            return(false);
        }
        /// <summary>
        /// Processes the result.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="steerer">The steerer.</param>
        /// <returns>
        ///   <c>true</c> if the result was handled by this processor, otherwise <c>false</c>
        /// </returns>
        public override bool HandleResult(PathResult result, SteerForPathComponent steerer)
        {
            switch (result.status)
            {
                case PathingStatus.NoRouteExists:
                {
                    var request = result.originalRequest;

                    if (_retries < this.maxRetries)
                    {
                        _retries++;

                        request.type = RequestType.Normal;

                        //Having this as a separate call apparently avoids allocation of anonymous method, which otherwise happens even if the status is not the one triggering this action.
                        IssueRequest(request, steerer);
                        return true;
                    }

                    break;
                }
            }

            _retries = 0;
            return false;
        }
        /// <summary>
        /// Processes the result.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="steerer">The steerer.</param>
        /// <returns>
        ///   <c>true</c> if the result was handled by this processor, otherwise <c>false</c>
        /// </returns>
        public override bool HandleResult(PathResult result, SteerForPathComponent steerer)
        {
            switch (result.status)
            {
                case PathingStatus.DestinationBlocked:
                {
                    var request = result.originalRequest;

                    //Try to find an unobstructed cell as close to the original destination as possible
                    var toGrid = GridManager.instance.GetGrid(request.to);
                    if (toGrid == null)
                    {
                        return false;
                    }

                    var newDestination = toGrid.GetNearestWalkableCell(
                                            request.to,
                                            this.transform.position,
                                            false,
                                            this.maxCellDistanceForNewDestination,
                                            request.requesterProperties);

                    if (newDestination != null)
                    {
                        request.to = newDestination.position;
                        steerer.RequestPath(request);
                        return true;
                    }

                    break;
                }
            }

            return false;
        }
        private void IssueRequest(IPathRequest request, SteerForPathComponent steerer)
        {
            var action = new OneTimeAction((ignored) =>
            {
                steerer.RequestPath(request);
            });

            NavLoadBalancer.defaultBalancer.Add(action, this.retryDelay, true);
        }
        private void IssueRequest(IPathRequest request, SteerForPathComponent steerer)
        {
            var action = new OneTimeAction((ignored) =>
            {
                steerer.RequestPath(request);
            });

            NavLoadBalancer.defaultBalancer.Add(action, this.retryDelay, true);
        }
示例#8
0
        public void CloneFrom(SteerForPathComponent steerForPath)
        {
            this.priority = steerForPath.priority;
            this.weight   = steerForPath.weight;

            this.slowingAlgorithm             = steerForPath.slowingAlgorithm;
            this.autoCalculateSlowingDistance = steerForPath.autoCalculateSlowingDistance;
            this.slowingDistance = steerForPath.slowingDistance;
            this.arrivalDistance = steerForPath.arrivalDistance;
        }
        /// <summary>
        /// Processes the result.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="steerer">The steerer.</param>
        /// <returns>
        ///   <c>true</c> if the result was handled by this processor, otherwise <c>false</c>
        /// </returns>
        public override bool HandleResult(PathResult result, SteerForPathComponent steerer)
        {
            switch (result.status)
            {
            case PathingStatus.NoRouteExists:
            {
                var request = result.originalRequest;

                if (_retries < this.maxRetries)
                {
                    _retries++;

                    //Having this as a separate call apparently avoids allocation of anonymous method, which otherwise happens even if the status is not the one triggering this action.
                    IssueRequest(request, steerer);
                    return(true);
                }

                break;
            }
            }

            _retries = 0;
            return(false);
        }
        /// <summary>
        /// Clones from the other component.
        /// </summary>
        /// <param name="steerForPath">The component to clone from.</param>
        public void CloneFrom(SteerForPathComponent steerForPath)
        {
            this.priority = steerForPath.priority;
            this.weight = steerForPath.weight;

            this.slowingAlgorithm = steerForPath.slowingAlgorithm;
            this.autoCalculateSlowingDistance = steerForPath.autoCalculateSlowingDistance;
            this.slowingDistance = steerForPath.slowingDistance;
            this.arrivalDistance = steerForPath.arrivalDistance;

            this.strictPathFollowing = steerForPath.strictPathFollowing;
        }
 /// <summary>
 /// Processes the result.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <param name="steerer">The steerer.</param>
 /// <returns>
 ///   <c>true</c> if the result was handled by this processor, otherwise <c>false</c>
 /// </returns>
 public abstract bool HandleResult(PathResult result, SteerForPathComponent steerer);
 /// <summary>
 /// Processes the result.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <param name="steerer">The steerer.</param>
 /// <returns>
 ///   <c>true</c> if the result was handled by this processor, otherwise <c>false</c>
 /// </returns>
 public abstract bool HandleResult(PathResult result, SteerForPathComponent steerer);