using System;
using Unity.VisualScripting;
using UnityEngine;
using System.Collections.Generic;

public abstract class Lock : MonoBehaviour
{
    // Room that must be explored before lock can be unlocked.
    [SerializeField] protected Room blockingRoom;
    public event Action Unlocked;

    public virtual bool CheckIfKeyFits(DicePair dicePair)
    {
        if (blockingRoom == null || blockingRoom.GetRoomExplored())
        {
            return true;
        }

        return false;
    }
    
    public virtual void Unlock(DicePair dicePair)
    {
        if (CheckIfKeyFits(dicePair))
        {
            OnUnlock();
        }
    }

    protected virtual void OnUnlock()
    {
        Unlocked?.Invoke();
    }
}
