void Update()
    {
        InteractableAbstract closest = GetClosestInteractable();

        if (focusedInteractable != closest)
        {
            if (focusedInteractable != null)
            {
                focusedInteractable.LoseFocus();
            }
            if (closest != null)
            {
                closest.GainFocus();
            }
            focusedInteractable = closest;
        }

        if (!GameManager.instance.paused && Input.GetButtonDown("Use"))
        {
            if (focusedInteractable != null)
            {
                focusedInteractable.Interact();
            }
        }
    }
 public void Refresh()
 {
     if (focusedInteractable != null)
     {
         focusedInteractable.LoseFocus();
         focusedInteractable = null;
     }
     interactables.Clear();
 }
    private InteractableAbstract GetClosestInteractable()
    {
        if (interactables.Count == 0)
        {
            return(null);
        }
        InteractableAbstract closest = interactables[0];

        foreach (InteractableAbstract i in interactables)
        {
            if (i.CanInteract() && DistanceFromPlayer(i) < DistanceFromPlayer(closest))
            {
                closest = i;
            }
        }
        if (!closest.CanInteract())
        {
            return(null);
        }
        return(closest);
    }
 private float DistanceFromPlayer(InteractableAbstract i)
 {
     return(Vector2.Distance(i.transform.position, player.transform.position));
 }