コード例 #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>();
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        /// <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;
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
        private void IssueRequest(IPathRequest request, SteerForPathComponent steerer)
        {
            var action = new OneTimeAction((ignored) =>
            {
                steerer.RequestPath(request);
            });

            NavLoadBalancer.defaultBalancer.Add(action, this.retryDelay, true);
        }
コード例 #7
0
        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;
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
        /// <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;
        }
コード例 #11
0
 /// <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);