public InGameEditorCameraViewModel(IInGameEditorCameraSizeInViewService cameraSizeInViewService, Transform mapTransform, CameraConfig config, ITilesPositionService tilesPositionService, ICameraGetRepository getCameraRepository) { _cameraSizeInViewService = cameraSizeInViewService; _mapTransform = mapTransform; _config = config; var mapPosition = mapTransform.position; _minCameraY = _config.MinDistanceToMap + mapPosition.y; CameraPositionLiveData = new LiveData <Vector3>(); CameraLiveData = new LiveData <Camera>(); /* * we are trying to avoid having a whole bunch of setting and getting service/repo for the camera * but if more class need this thing we will need to refactor */ _cameraYPositionSubject = new Subject <float>(); _disposable = new CompositeDisposable { _cameraYPositionSubject.Subscribe(OnZoomingLevelUpdated), getCameraRepository.GetObservableStream().Subscribe(CameraLiveData.PostValue), tilesPositionService .GetObservableStream(mapPosition.y) .CombineLatest(_cameraYPositionSubject, (positions, _) => positions) //update bounds whenever the camera's height is updated .Subscribe(CalculateCameraRelatedMetrics) }; }
public MousePositionOnMapService(ICameraGetRepository cameraGetRepository, ICurrentMapTransformGetRepository mapTransformGetRepository) { _disposable = new CompositeDisposable { mapTransformGetRepository.GetObservableStream() .SubscribeOn(Scheduler.ThreadPool) .ObserveOn(Scheduler.MainThread) .Subscribe(t => _mapTransform = t), cameraGetRepository.GetObservableStream() .SubscribeOn(Scheduler.ThreadPool) .ObserveOn(Scheduler.MainThread) .Subscribe(camera => _currentCamera = camera) }; }