/// <summary> /// Provides new interactable object state to Model. /// Invokes outside mistake event if state is not available. /// </summary> private void HandleSwitchState(object obj, int index) { if (!(obj is Interactable interactableObject)) { return; } if (!machineModel.SwitchMechanismState(index)) { OnUserMistake?.Invoke(); } interactableObject.OnTryInteract -= HandleInteraction; }
/// <summary> /// Gets Model permission for interaction. /// Invokes Interactable.Interact() or outside mistake event. /// </summary> private void HandleInteraction(object obj, int index) { if (!(obj is Interactable interactableObject)) { return; } if (machineModel.CanInteract(index)) { interactableObject.Interact(); return; } OnUserMistake?.Invoke(); interactableObject.OnTryInteract -= HandleInteraction; }