コード例 #1
0
 public UpdateWorkButtonInteractableWhenWorkerStatusUpdated(WorkerIdentifier workerId, IObservable <WorkshopEvent> workshopEvents, IDisplayWorkButtonInteractable displayWorkButtonInteractable)
 {
     workshopEvents
     .OfType <WorkshopEvent, WorkshopEvent.WorkerStatusUpdated>()
     .Where(workerStatusUpdated => workerStatusUpdated.WorkerId == workerId)
     .Select(workerStatusUpdated => workerStatusUpdated.NewStatus.Busy)
     .Subscribe(busy => displayWorkButtonInteractable.Interactable = !busy);
 }
コード例 #2
0
 public SetWorkButtonNotInteractableWhenWorkerAdded(WorkerIdentifier workerId, IObservable <WorkshopEvent> workshopEvents, IDisplayWorkButtonInteractable displayWorkButtonInteractable)
 {
     workshopEvents
     .OfType <WorkshopEvent, WorkshopEvent.WorkerAdded>()
     .Where(workerAdded => workerAdded.Worker.Id == workerId)
     .Subscribe(_ => displayWorkButtonInteractable.Interactable = false);
 }
        public UpdateWorkButtonInteractableWhenWorkerAssignedOrUnassigned(WorkerIdentifier workerId, IObservable <WorkshopEvent> workshopEvents, IDisplayWorkButtonInteractable displayWorkButtonInteractable)
        {
            var assignments = workshopEvents
                              .OfType <WorkshopEvent, WorkshopEvent.JobAssigned>()
                              .Where(jobAssigned => jobAssigned.WorkerId == workerId)
                              .Select(_ => true);

            var unassignments = workshopEvents
                                .OfType <WorkshopEvent, WorkshopEvent.JobUnassigned>()
                                .Where(jobUnassigned => jobUnassigned.WorkerId == workerId)
                                .Select(_ => false);

            assignments.Merge(unassignments)
            .Subscribe(interactable => displayWorkButtonInteractable.Interactable = interactable);
        }