updated EventBus
This commit is contained in:
parent
929f7ecf55
commit
ad17db114f
3
Assets/_DDD/_Scripts/GameEvent.meta
Normal file
3
Assets/_DDD/_Scripts/GameEvent.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75d0cfe071ff4a50b1cb68d5a3e6822f
|
||||
timeCreated: 1752739468
|
19
Assets/_DDD/_Scripts/GameEvent/GameEvents.cs
Normal file
19
Assets/_DDD/_Scripts/GameEvent/GameEvents.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace DDD
|
||||
{
|
||||
public static class GameEvents
|
||||
{
|
||||
// public static GameGlobalEvent GameGlobalEvent = new GameGlobalEvent();
|
||||
}
|
||||
public static class RestaurantEvents
|
||||
{
|
||||
|
||||
}
|
||||
public static class VoyageEvents
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// public class GameGlobalEvent : IEvent
|
||||
// {
|
||||
// }
|
||||
}
|
3
Assets/_DDD/_Scripts/GameEvent/GameEvents.cs.meta
Normal file
3
Assets/_DDD/_Scripts/GameEvent/GameEvents.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 388fe30817e644c29f8b7e71e923c1cc
|
||||
timeCreated: 1752739530
|
@ -32,14 +32,14 @@ public static void Unregister<T>(IEventHandler<T> handler) where T : IEvent
|
||||
}
|
||||
}
|
||||
|
||||
public static void Publish<T>(T evt) where T : IEvent
|
||||
public static void Broadcast<T>(T evt) where T : IEvent
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (HandlerDictionary.TryGetValue(type, out var list))
|
||||
{
|
||||
foreach (var handler in list.Cast<IEventHandler<T>>())
|
||||
{
|
||||
handler.Handle(evt);
|
||||
handler.Invoke(evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ namespace DDD
|
||||
{
|
||||
public interface IEventHandler<in T> where T : IEvent
|
||||
{
|
||||
void Handle(T evt);
|
||||
void Invoke(T evt);
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@ protected void Start()
|
||||
return;
|
||||
}
|
||||
|
||||
EventBus.ClearAll();
|
||||
|
||||
// 매니저 초기화
|
||||
_managerInstances = new List<Singleton>(_managerDefinitionSo.ManagerClasses.Count);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user