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.

49 lines
1.5KB

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