using System.Collections.Generic; using UnityEngine; namespace UnityAtoms { public abstract class GameEvent : ScriptableObject { private readonly List> _eventListeners = new List>(); public void Raise(T item) { for (int i = _eventListeners.Count - 1; i >= 0; i--) _eventListeners[i].OnEventRaised(item); } public void RegisterListener(IGameEventListener listener) { if (!_eventListeners.Contains(listener)) _eventListeners.Add(listener); } public void UnregisterListener(IGameEventListener listener) { if (_eventListeners.Contains(listener)) _eventListeners.Remove(listener); } } public abstract class GameEvent : ScriptableObject { private readonly List> _eventListeners = new List>(); public void Raise(T1 item1, T2 item2) { for (int i = _eventListeners.Count - 1; i >= 0; i--) _eventListeners[i].OnEventRaised(item1, item2); } public void RegisterListener(IGameEventListener listener) { if (!_eventListeners.Contains(listener)) _eventListeners.Add(listener); } public void UnregisterListener(IGameEventListener listener) { if (_eventListeners.Contains(listener)) _eventListeners.Remove(listener); } } }