using UnityEngine;

public class PlayerInteract : MonoBehaviour
{
    [SerializeField] InteractDetector CurrentInteractable;
    [SerializeField] KeyCode pressToInteract;

    public void SetInteractable(InteractDetector whichInteractable)
    {
        CurrentInteractable = whichInteractable;
    }
    public void RemoveInteractable(InteractDetector whichInteractable)
    {
        CurrentInteractable = null;
    }

    private void Update()
    {
        if(Input.GetKeyDown(pressToInteract))
        {
            if(CurrentInteractable != null)
            {
                CurrentInteractable.Interact();
            }
        }
    }
}