
namespace GatherAndDefend.Events
{
    /// <summary>
    /// lets you create custom events for the event aggregator
    /// </summary>
    public abstract class EventBase
    {
        private event System.Action innerEvent;
        public void Invoke()
        {
            innerEvent?.Invoke();
        }
        public void Attach(System.Action handler)
        {
            innerEvent += handler;
        }
        public void Detach(System.Action handler)
        {
            innerEvent -= handler;
        }
    }
    /// <summary>
    /// lets you create custom event with given parameter for the event aggregator
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class EventBase<T> : EventBase
    {
        private event System.Action<T> innerEvent;
        public void Invoke(T value) => innerEvent?.Invoke(value);
        public void Attach(System.Action<T> handler) => innerEvent += handler;
        public void Detach(System.Action<T> handler) => innerEvent -= handler;
    }
}