Первый коммит с LFS.
This commit is contained in:
1 parent
4fcb1e2f24
commit
179816dc4b
5084 files changed
+3714098
-1
No files matched your search
@@ -0,0 +1,34 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(menuName = "Game Event", fileName = "New Game Event")]
|
||||
public class GameEvent : ScriptableObject
|
||||
{
|
||||
private readonly List<GameEventListener> _listeners = new List<GameEventListener>();
|
||||
|
||||
public void Raise()
|
||||
{
|
||||
// Проходимся по списку в обратном порядке, на случай если слушатель удалится во время вызова
|
||||
for (int i = _listeners.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_listeners[i].OnEventRaised();
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterListener(GameEventListener listener)
|
||||
{
|
||||
if (!_listeners.Contains(listener))
|
||||
{
|
||||
_listeners.Add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnregisterListener(GameEventListener listener)
|
||||
{
|
||||
if (_listeners.Contains(listener))
|
||||
{
|
||||
_listeners.Remove(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user