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.

Movement.cs 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Unity.Mathematics;
  7. namespace GamecraftModdingAPI.Blocks
  8. {
  9. /// <summary>
  10. /// Common block movement operations
  11. /// </summary>
  12. public static class Movement
  13. {
  14. private static MovementEngine movementEngine = new MovementEngine();
  15. /// <summary>
  16. /// Move a single block by a specific (x,y,z) amount
  17. /// </summary>
  18. /// <param name="id">The block's id</param>
  19. /// <param name="vector">The movement amount (x,y,z)</param>
  20. /// <returns>Whether the operation was successful</returns>
  21. public static bool MoveBlock(uint id, float3 vector)
  22. {
  23. if (movementEngine.IsInGame && movementEngine.IsBuildMode())
  24. {
  25. movementEngine.MoveBlock(id, vector);
  26. return true;
  27. }
  28. return false;
  29. }
  30. /// <summary>
  31. /// Move all connected blocks by a specific (x,y,z) amount
  32. /// </summary>
  33. /// <param name="id">The starting block's id</param>
  34. /// <param name="vector">The movement amount (x,y,z)</param>
  35. /// <returns>Whether the operation was successful</returns>
  36. public static bool MoveConnectedBlocks(uint id, float3 vector)
  37. {
  38. if (movementEngine.IsInGame && movementEngine.IsBuildMode())
  39. {
  40. movementEngine.MoveConnectedBlocks(id, vector);
  41. return true;
  42. }
  43. return false;
  44. }
  45. public static void Init()
  46. {
  47. GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(movementEngine);
  48. }
  49. }
  50. }