updated EventBus

This commit is contained in:
Jeonghyeon Ha 2025-07-17 17:15:40 +09:00
parent 929f7ecf55
commit ad17db114f
6 changed files with 30 additions and 3 deletions

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 75d0cfe071ff4a50b1cb68d5a3e6822f
timeCreated: 1752739468

View 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
// {
// }
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 388fe30817e644c29f8b7e71e923c1cc
timeCreated: 1752739530

View File

@ -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); var type = typeof(T);
if (HandlerDictionary.TryGetValue(type, out var list)) if (HandlerDictionary.TryGetValue(type, out var list))
{ {
foreach (var handler in list.Cast<IEventHandler<T>>()) foreach (var handler in list.Cast<IEventHandler<T>>())
{ {
handler.Handle(evt); handler.Invoke(evt);
} }
} }
} }

View File

@ -2,6 +2,6 @@ namespace DDD
{ {
public interface IEventHandler<in T> where T : IEvent public interface IEventHandler<in T> where T : IEvent
{ {
void Handle(T evt); void Invoke(T evt);
} }
} }

View File

@ -19,6 +19,8 @@ protected void Start()
Debug.LogError("_managerDefinitionSo"); Debug.LogError("_managerDefinitionSo");
return; return;
} }
EventBus.ClearAll();
// 매니저 초기화 // 매니저 초기화
_managerInstances = new List<Singleton>(_managerDefinitionSo.ManagerClasses.Count); _managerInstances = new List<Singleton>(_managerDefinitionSo.ManagerClasses.Count);