mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-23 16:48:23 -05:00
e5f6659eda
* Removed unused namespaces across all files in Unity.Atoms assembly. * Removed unused namspaces in runtime and Test assembly code.
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace UnityAtoms
|
|
{
|
|
public abstract class GameEvent<T> : ScriptableObject
|
|
{
|
|
private readonly List<IGameEventListener<T>> eventListeners = new List<IGameEventListener<T>>();
|
|
|
|
public void Raise(T item)
|
|
{
|
|
for (int i = eventListeners.Count - 1; i >= 0; i--)
|
|
eventListeners[i].OnEventRaised(item);
|
|
}
|
|
|
|
public void RegisterListener(IGameEventListener<T> listener)
|
|
{
|
|
if (!eventListeners.Contains(listener))
|
|
eventListeners.Add(listener);
|
|
}
|
|
|
|
public void UnregisterListener(IGameEventListener<T> listener)
|
|
{
|
|
if (eventListeners.Contains(listener))
|
|
eventListeners.Remove(listener);
|
|
}
|
|
}
|
|
|
|
public abstract class GameEvent<T1, T2> : ScriptableObject
|
|
{
|
|
private readonly List<IGameEventListener<T1, T2>> eventListeners = new List<IGameEventListener<T1, T2>>();
|
|
|
|
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<T1, T2> listener)
|
|
{
|
|
if (!eventListeners.Contains(listener))
|
|
eventListeners.Add(listener);
|
|
}
|
|
|
|
public void UnregisterListener(IGameEventListener<T1, T2> listener)
|
|
{
|
|
if (eventListeners.Contains(listener))
|
|
eventListeners.Remove(listener);
|
|
}
|
|
}
|
|
}
|