using UnityEngine;
using UnityEngine.Events;


// This class allows us to define multiple child GameEvents that take arguments with explicit types
public class GameEventWithOneArgument<T> : ScriptableObject
{
    // We use a unity event as it already has the infrastructure in place to register and call functions
    // With this event contained inside a scriptable object we will always be able to have it 
    // accept listeners and be invoked.
    private UnityEvent<T> gameEventWithOneArgument;

    public void Raise(T data)
    {
        gameEventWithOneArgument.Invoke(data);
    }

    public void RegisterListener(UnityAction<T> listener)
    {
        gameEventWithOneArgument.AddListener(listener);
    }

    public void UnregisterListener(UnityAction<T> listener)
    {
        gameEventWithOneArgument.RemoveListener(listener);
    }
}
