using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

[CreateAssetMenu(fileName = "NewGameEvent", menuName = "CustomSO/GameEvent")]
public class GameEvent : ScriptableObject
{
        private List<UnityEvent> responses = new List<UnityEvent>();

        public void RegisterListener(UnityEvent response)
        {
            responses.Add(response);
        }

        public void UnregisterListener(UnityEvent response)
        {
            responses.Remove(response);
        }

        public void Raise()
        {
            Debug.Log($"{this.name} fired");
            for (int i = responses.Count - 1; i >= 0; --i)
            {
                responses[i]?.Invoke();
            }
        }
    
}
