|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- using HarmonyLib;
- using RobocraftX;
- using Svelto.ECS;
-
- using GamecraftModdingAPI.Utility;
-
- namespace GamecraftModdingAPI.Events
- {
- /// <summary>
- /// Patch of RobocraftX.FullGameCompositionRoot.ActivateMenu()
- /// </summary>
- [HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateMenu")]
- class MenuActivatedPatch
- {
-
- private static bool firstLoad = true;
- public static void Postfix(ref EnginesRoot ____frontEndEnginesRoot, FullGameCompositionRoot __instance)
- {
- // register custom menu engines
- MenuEngineManager.RegisterEngines(____frontEndEnginesRoot);
- // A new EnginesRoot is always created when ActivateMenu is called
- // so all event emitters and handlers must be re-registered.
- EventManager.RegisterEngines(____frontEndEnginesRoot);
- if (firstLoad)
- {
- firstLoad = false;
- FullGameFields.Init(__instance);
- Logging.Log("Dispatching App Init event");
- EventManager.GetEventEmitter("GamecraftModdingAPIApplicationInitializedEventEmitter").Emit();
- }
- Logging.Log("Dispatching Menu Activated event");
- EventManager.GetEventEmitter("GamecraftModdingAPIMenuActivatedEventEmitter").Emit();
- }
- }
- }
|