Minecraft world importer for Gamecraft.
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.

47 lines
1.4KB

  1. using System.Reflection;
  2. using DataLoader;
  3. using Harmony;
  4. using RobocraftX.Blocks.GUI;
  5. using RobocraftX.Common;
  6. using RobocraftX.CR.MachineEditing;
  7. using RobocraftX.StateSync;
  8. using Svelto.ECS;
  9. using Unity.Entities;
  10. using UnityEngine;
  11. namespace GCMC
  12. {
  13. [HarmonyPatch]
  14. public class PlaceBlockPatch
  15. {
  16. static void Postfix(EnginesRoot enginesRoot, ref StateSyncRegistrationHelper stateSyncReg, bool isAuthoritative)
  17. {
  18. if (isAuthoritative)
  19. {
  20. stateSyncReg.AddEngine(new CubePlacerEngine());
  21. Debug.Log($"Added Minecraft world import engine");
  22. }
  23. else
  24. Debug.Log("Not authoritative, not adding MC engine");
  25. }
  26. static MethodBase TargetMethod(HarmonyInstance instance)
  27. {
  28. return _ComposeMethodInfo(MachineEditingCompositionRoot.StateSyncCompose);
  29. }
  30. private delegate void ComposeAction(EnginesRoot enginesRoot,
  31. IDataDB dataDB,
  32. RCXMode currentMode,
  33. World physicsWorld,
  34. ref StateSyncRegistrationHelper stateSyncReg,
  35. bool isAuthoritative,
  36. LabelResourceManager labelResourceManager,
  37. LabelResourceManager textBlockLabelResourceManager,
  38. MainGameOptions.Options mainGameOptions);
  39. private static MethodInfo _ComposeMethodInfo(ComposeAction a)
  40. {
  41. return a.Method;
  42. }
  43. }
  44. }