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.

35 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.ActivateGame()
  14. /// </summary>
  15. [HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateGame")]
  16. class GameActivatedPatch
  17. {
  18. public static void Postfix(ref EnginesRoot ____mainGameEnginesRoot)
  19. {
  20. // register custom game engines
  21. GameEngineManager.RegisterEngines(____mainGameEnginesRoot);
  22. // register custom command engines
  23. GamecraftModdingAPI.Commands.CommandManager.RegisterEngines(____mainGameEnginesRoot);
  24. // A new EnginesRoot is always created when ActivateGame is called
  25. // so all event emitters and handlers must be re-registered.
  26. EventManager.RegisterEngines(____mainGameEnginesRoot);
  27. Logging.Log("Dispatching Game Activated event");
  28. EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit();
  29. }
  30. }
  31. }