using System;
using UnityEngine;
using UnityEngine.Rendering.Universal;

public class PDA : MonoBehaviour
{
    [SerializeField] Camera OverlayCamera;
    [SerializeField] bool isOverlay = true;

    private void Awake()
    {
        if (isOverlay)
        {
            PutCameraInStack();
            Bind();
        }
    }

    private void PutCameraInStack()
    {
        if (OverlayCamera == null) return;

        //find base camera and put the overlay camera in its stack
        var cameraURPdata = Director.Instance.MainCamera.GetUniversalAdditionalCameraData();
        cameraURPdata.cameraStack.Add(OverlayCamera);
    }

    private void Bind()
    {
        //bind the PDA to events
        MapGenerator.OnMapGenerated += GenerateMinimap;
    }

    private void GenerateMinimap(MapGenerator.MapData obj)
    {
        //throw new NotImplementedException();
    }

    public void UnBind()
    {
        //unbind the PDA from events
        MapGenerator.OnMapGenerated -= GenerateMinimap;
    }

    private void OnDestroy()
    {
        UnBind();
    }
}
