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.

59 lines
1.4KB

  1. using System.Reflection;
  2. using HarmonyLib;
  3. using RobocraftX;
  4. using RobocraftX.CR.MainGame;
  5. using RobocraftX.FrontEnd;
  6. using RobocraftX.StateSync;
  7. using Svelto.ECS;
  8. using Svelto.ECS.Schedulers;
  9. using TechbloxModdingAPI.Utility;
  10. namespace TechbloxModdingAPI.Engines
  11. {
  12. [HarmonyPatch]
  13. class GameLoadedEnginePatch
  14. {
  15. public static EntitiesSubmissionScheduler Scheduler { get; private set; }
  16. public static void Postfix(StateSyncRegistrationHelper stateSyncReg)
  17. {
  18. // register all game engines, including deterministic
  19. GameEngineManager.RegisterEngines(stateSyncReg);
  20. Scheduler = stateSyncReg.enginesRoot.scheduler;
  21. }
  22. public static MethodBase TargetMethod()
  23. {
  24. return AccessTools.Method(typeof(MainGameCompositionRoot), "DeterministicCompose").MakeGenericMethod(typeof(object));
  25. }
  26. }
  27. [HarmonyPatch]
  28. class MenuLoadedEnginePatch
  29. {
  30. public static void Postfix(EnginesRoot enginesRoot)
  31. {
  32. // register menu engines
  33. MenuEngineManager.RegisterEngines(enginesRoot);
  34. }
  35. public static MethodBase TargetMethod()
  36. {
  37. return AccessTools.Method(typeof(FrontEndCompositionRoot), "Compose").MakeGenericMethod(typeof(object));
  38. }
  39. }
  40. [HarmonyPatch]
  41. class FullGameCreatedEnginePatch
  42. {
  43. public static void Postfix(FullGameCompositionRoot __instance)
  44. {
  45. FullGameFields.Init(__instance);
  46. }
  47. public static MethodBase TargetMethod()
  48. {
  49. return AccessTools.DeclaredConstructor(typeof(FullGameCompositionRoot));
  50. }
  51. }
  52. }