|
@@ -1,31 +1,30 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
-using ObjectEventAction = System.Action<CommonAI.Zone.ObjectEvent>;
|
|
|
|
|
|
namespace ET
|
|
|
{
|
|
|
- public class EventDispatcher
|
|
|
+ public class EventDispatcher<A>
|
|
|
{
|
|
|
- private Dictionary<Type, List<ObjectEventAction>> _list = new();
|
|
|
+ private Dictionary<Type, List<Action<A>>> _list = new();
|
|
|
public EventDispatcher() { }
|
|
|
|
|
|
- public ObjectEventAction AddListener<T>(ObjectEventAction action)
|
|
|
+ public Action<A> AddListener<T>(Action<A> action)
|
|
|
{
|
|
|
- List<ObjectEventAction> acts;
|
|
|
+ List<Action<A>> acts;
|
|
|
if (_list.TryGetValue(typeof(T), out acts))
|
|
|
{
|
|
|
acts.Add(action);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _list.Add(typeof(T), new List<ObjectEventAction> { action });
|
|
|
+ _list.Add(typeof(T), new List<Action<A>> { action });
|
|
|
}
|
|
|
return action;
|
|
|
}
|
|
|
|
|
|
- public void Notfify(CommonAI.Zone.ObjectEvent ev)
|
|
|
+ public void Notfify(A ev)
|
|
|
{
|
|
|
- List<ObjectEventAction> acts;
|
|
|
+ List<Action<A>> acts;
|
|
|
if (_list.TryGetValue(ev.GetType(), out acts))
|
|
|
{
|
|
|
foreach (var act in acts)
|