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.

MenuActivatedPatch.cs 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using HarmonyLib;
  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. [Obsolete]
  16. [HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateMenu")]
  17. class MenuActivatedPatch
  18. {
  19. private static bool firstLoad = true;
  20. public static void Postfix(ref EnginesRoot ____frontEndEnginesRoot, FullGameCompositionRoot __instance)
  21. {
  22. // register custom menu engines
  23. MenuEngineManager.RegisterEngines(____frontEndEnginesRoot);
  24. // A new EnginesRoot is always created when ActivateMenu is called
  25. // so all event emitters and handlers must be re-registered.
  26. EventManager.RegisterEngines(____frontEndEnginesRoot);
  27. if (firstLoad)
  28. {
  29. firstLoad = false;
  30. FullGameFields.Init(__instance);
  31. //Application.Application.SetFullGameCompositionRoot(__instance);
  32. Logging.Log("Dispatching App Init event");
  33. EventManager.GetEventEmitter("GamecraftModdingAPIApplicationInitializedEventEmitter").Emit();
  34. }
  35. Logging.Log("Dispatching Menu Activated event");
  36. EventManager.GetEventEmitter("GamecraftModdingAPIMenuActivatedEventEmitter").Emit();
  37. }
  38. }
  39. }