|
|
@@ -20,11 +20,18 @@ namespace GamecraftModdingAPI.Events |
|
|
|
|
|
|
|
private static Dictionary<string, IEventHandlerEngine> _eventHandlers = new Dictionary<string, IEventHandlerEngine>(); |
|
|
|
|
|
|
|
private static EnginesRoot _lastEngineRoot; |
|
|
|
|
|
|
|
// event handler management |
|
|
|
|
|
|
|
public static void AddEventHandler(IEventHandlerEngine engine) |
|
|
|
{ |
|
|
|
_eventHandlers[engine.Name] = engine; |
|
|
|
if (_lastEngineRoot != null) |
|
|
|
{ |
|
|
|
Logging.MetaDebugLog($"Registering IEventHandlerEngine {engine.Name}"); |
|
|
|
_lastEngineRoot.AddEngine(engine); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static bool ExistsEventHandler(string name) |
|
|
@@ -57,6 +64,11 @@ namespace GamecraftModdingAPI.Events |
|
|
|
public static void AddEventEmitter(IEventEmitterEngine engine) |
|
|
|
{ |
|
|
|
_eventEmitters[engine.Name] = engine; |
|
|
|
if (_lastEngineRoot != null) |
|
|
|
{ |
|
|
|
Logging.MetaDebugLog($"Registering IEventEmitterEngine {engine.Name}"); |
|
|
|
_lastEngineRoot.AddEngine(engine); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static bool ExistsEventEmitter(string name) |
|
|
@@ -89,6 +101,7 @@ namespace GamecraftModdingAPI.Events |
|
|
|
|
|
|
|
public static void RegisterEngines(EnginesRoot enginesRoot) |
|
|
|
{ |
|
|
|
_lastEngineRoot = enginesRoot; |
|
|
|
// Register handlers before emitters so no events are missed |
|
|
|
var entityFactory = enginesRoot.GenerateEntityFactory(); |
|
|
|
foreach (var key in _eventHandlers.Keys) |
|
|
|