private void OnTriggerExit2D(Collider2D collision) { if (collision.CompareTag("Interactable")) { IInteractable2D interactable = collision.GetComponent <IInteractable2D>(); interactables.Remove(interactable); interactable.OnEndFocus(this); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Interactable")) { IInteractable2D interactable = collision.GetComponent <IInteractable2D>(); interactables.Add(interactable); interactable.OnBeginFocus(this); } }
void StartInteract(IInteractable2D interactable) { currentInteractTime = 0; if (currentInteractable != null) { CancelInteract(); } currentInteractable = interactable; interactable.OnStartInteract(this); if (interactable.InteractionTime <= 0) { FinishInteract(); return; } interactables.Remove(interactable); }
void CancelInteract() { currentInteractable.OnCancelInteract(this); interactables.Add(currentInteractable); currentInteractable = null; }
void FinishInteract() { currentInteractable.OnFinishInteract(this); currentInteractable = null; }