private void SetManualPath(ManualPath path) { if (path.path.count == 0) { StopInternal(); return; } _stop = false; _stopped = false; _currentDestination = null; _currentPath = path.path; _currentGrid = GridManager.instance.GetGrid(_currentPath.Peek().position); _endOfResolvedPath = _currentPath.Last().position; _endOfPath = _endOfResolvedPath; _lastPathRequestTime = Time.time; }
private void ConsumeResult() { //Consume way points if appropriate. This must be done prior to the processing of the result, since if the request was a way point request, the first item in line is the one the result concerns. if (_pendingResult.originalRequest.type == RequestType.Waypoint) { _wayPoints.Dequeue(); } else if (_pendingResult.originalRequest.type == RequestType.PathboundWaypoint) { _pathboundWayPoints.Dequeue(); } //Reset current destination no matter what _currentDestination = null; //Since result processing may actually repath and consequently a new result may arrive we need to operate on locals and null the pending result var result = _pendingResult; _pendingResult = null; //Process the result if (!ProcessAndValidateResult(result)) { return; } //Consume the result _currentPath = result.path; _currentGrid = result.originalRequest.fromGrid; _endOfResolvedPath = _currentPath.Last().position; _endOfPath = _endOfResolvedPath; //Update pending way points UpdatePathboundWaypoints(result.pendingWaypoints); //The first point on the path is always the origin of the request, so we want to skip that. _currentPath.Pop(); }