A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Harmony;
  7. using RobocraftX;
  8. using Svelto.ECS;
  9. using GamecraftModdingAPI.Utility;
  10. namespace GamecraftModdingAPI.Events
  11. {
  12. /// <summary>
  13. /// Patch of RobocraftX.FullGameCompositionRoot.ActivateMenu()
  14. /// </summary>
  15. [HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateMenu")]
  16. class MenuActivatedPatch
  17. {
  18. private static bool firstLoad = true;
  19. public static void Postfix(ref EnginesRoot ____frontEndEnginesRoot, FullGameCompositionRoot __instance)
  20. {
  21. // register custom menu engines
  22. MenuEngineManager.RegisterEngines(____frontEndEnginesRoot);
  23. // A new EnginesRoot is always created when ActivateMenu is called
  24. // so all event emitters and handlers must be re-registered.
  25. EventManager.RegisterEngines(____frontEndEnginesRoot);
  26. if (firstLoad)
  27. {
  28. firstLoad = false;
  29. FullGameFields.Init(__instance);
  30. Logging.Log("Dispatching App Init event");
  31. EventManager.GetEventEmitter("GamecraftModdingAPIApplicationInitializedEventEmitter").Emit();
  32. }
  33. Logging.Log("Dispatching Menu Activated event");
  34. EventManager.GetEventEmitter("GamecraftModdingAPIMenuActivatedEventEmitter").Emit();
  35. }
  36. }
  37. }