private void Interact() { List <GameObject> collidingWith = Detector.GetCurrentOverlapping(); if (collidingWith.Count > 0) { IInteractible firstCollided = collidingWith.FirstOrDefault() .GetComponent <IInteractible>(); if (firstCollided != null) { firstCollided.Use(ReferenceCollider); } } }
public void Interact() { if (IsBusy) { return; } // Use interactibles first, whether we're holding an item or not. // If that fails, try and use the held item if we're holding one. currentInteractible = GetInteractible(); if (currentInteractible != null) { var type = currentInteractible.Use(this); if (type != InteractionTypes.None) { actor.Animator.ApplyInteractionAnimation(type); state = States.UsingInteractible; return; } } // No interactibles were used if (CurrentItem != null) { var type = CurrentItem.CanUse(this); if (type != InteractionTypes.None) { actor.Animator.ApplyInteractionAnimation(type); state = States.UsingItem; return; } } state = States.None; }