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.

41 lines
1.2KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Harmony;
  8. using RobocraftX;
  9. using Svelto.ECS;
  10. using GamecraftModdingAPI.Utility;
  11. using RobocraftX.CR.MainGame;
  12. namespace GamecraftModdingAPI.Events
  13. {
  14. /// <summary>
  15. /// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame()
  16. /// </summary>
  17. [HarmonyPatch]
  18. class GameActivatedPatch
  19. {
  20. public static void Postfix(ref EnginesRoot enginesRoot)
  21. {
  22. // register custom game engines
  23. GameEngineManager.RegisterEngines(enginesRoot);
  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(enginesRoot);
  27. Logging.Log("Dispatching Game Activated event");
  28. EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit();
  29. }
  30. public static MethodBase TargetMethod()
  31. {
  32. return typeof(MainGameCompositionRoot).GetMethods().First(m => m.Name == "Compose")
  33. .MakeGenericMethod(typeof(object));
  34. }
  35. }
  36. }