using System;
using KitsuneCafe.System;
using UnityEngine;

namespace KitsuneCafe.UI
{
    [CreateAssetMenu(menuName = KitsuneCafeMenu.Ui + "Orchestrator")]
    public class UIOrchestrator : ScriptableObject
    {
        public event EventHandler<SpawnElementRequest> SpawnRequested = default;
        public event EventHandler<DespawnElementRequest> DespawnRequested = default;


        public ElementId SpawnElement(IUIElement element, Vector3 worldPosition)
        {
            var id = ElementId.Create();
            SpawnRequested.Invoke(this, SpawnElementRequest.Create(id, element, worldPosition));
            return id;
        }

        public void DespawnElement(ElementId id)
        {
            DespawnRequested.Invoke(this, DespawnElementRequest.Create(id));
        }
    }
}