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.

38 lines
1.2KB

  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)
  20. {
  21. // A new EnginesRoot is always created when ActivateMenu is called
  22. // so all event emitters and handlers must be re-registered.
  23. Manager.RegisterEngines(____frontEndEnginesRoot);
  24. if (firstLoad)
  25. {
  26. firstLoad = false;
  27. Logging.Log("Dispatching App Init event");
  28. Manager.GetEventEmitter("GamecraftModdingAPIApplicationInitializedEventEmitter").Emit();
  29. }
  30. Logging.Log("Dispatching Menu Activated event");
  31. Manager.GetEventEmitter("GamecraftModdingAPIMenuActivatedEventEmitter").Emit();
  32. }
  33. }
  34. }