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.

Rotation.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 Rotation
  13. {
  14. private static RotationEngine rotationEngine = new RotationEngine();
  15. /// <summary>
  16. /// Rotate a single block by a specific amount in degrees
  17. /// </summary>
  18. /// <param name="id">The block's id</param>
  19. /// <param name="vector">The rotation amount around the x,y,z-axis</param>
  20. /// <returns>Whether the operation was successful</returns>
  21. public static bool RotateBlock(uint id, float3 vector)
  22. {
  23. if (rotationEngine.IsInGame && rotationEngine.IsBuildMode())
  24. {
  25. rotationEngine.RotateBlock(id, vector);
  26. return true;
  27. }
  28. return false;
  29. }
  30. /// <summary>
  31. /// Rotate all connected blocks by a specific amount in degrees
  32. /// </summary>
  33. /// <param name="id">The starting block's id</param>
  34. /// <param name="vector">The rotation around the x,y,z-axis</param>
  35. /// <returns>Whether the operation was successful</returns>
  36. public static bool RotateConnectedBlocks(uint id, float3 vector)
  37. {
  38. if (rotationEngine.IsInGame && rotationEngine.IsBuildMode())
  39. {
  40. rotationEngine.RotateConnectedBlocks(id, vector);
  41. return true;
  42. }
  43. return false;
  44. }
  45. public static void Init()
  46. {
  47. GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(rotationEngine);
  48. }
  49. }
  50. }