public void Execute(OnRequestCompleteDelegate onComplete) { if (Status != eRequestStatus.pending_path_find || Status != eRequestStatus.pending_server_response) { Status = eRequestStatus.pending_path_find; m_onCompleteCallback = onComplete; PathfindingSystem.AddPathRequest(m_entity.CurrentRoomKey, m_entity.Position, TargetPosition, this.OnPathComputed); } }
// Requests public bool SubmitPathRequest( Point3d point, Vector2d facing, PathComputer.OnPathComputerComplete pathCompletedCallback) { bool success = false; m_pathSteps = new List <PathStep>(); m_pathStepIndex = 0; m_pathCompleteCallback = pathCompletedCallback; m_destinationPoint.Set(point); m_destinationFacing.Copy(facing); if (Point3d.DistanceSquared(m_destinationPoint, m_entity.Position) > MathConstants.EPSILON_SQUARED) { success = PathfindingSystem.AddPathRequest( m_entity.CurrentRoomKey, m_entity.Position, m_destinationPoint, (PathComputer pathResult) => { if (pathResult.ResultCode == PathComputer.eResult.success) { m_state = ePathFindingState.in_progress; m_pathSteps = pathResult.FinalPath; } else { OnPathCompleted(pathResult); } }); } else { OnPathCompleted(null); success = true; } return(success); }
public void Execute(OnRequestCompleteDelegate onComplete) { if (Status != eRequestStatus.pending_path_find || Status != eRequestStatus.pending_server_response) { m_onCompleteCallback = onComplete; if (Point3d.DistanceSquared(OriginalPosition, OriginPortalEntryPoint) > WITHIN_PORTAL_TOLERANCE_SQUARED) { Status = eRequestStatus.pending_path_find; PathfindingSystem.AddPathRequest( m_entity.CurrentRoomKey, m_entity.Position, OriginPortalEntryPoint, this.OnPathComputed); } else { Status = eRequestStatus.pending_server_response; } } }