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 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 rotation operations.
  11. /// The functionality in this class is not completely implemented and will only work in build mode.
  12. /// </summary>
  13. public static class Rotation
  14. {
  15. private static RotationEngine rotationEngine = new RotationEngine();
  16. /// <summary>
  17. /// Rotate a single block by a specific amount in degrees.
  18. /// This not destroy inter-block connections, so neighbouring blocks will remain attached despite appearances.
  19. /// The cube placement grid and collision are also rotated.
  20. /// </summary>
  21. /// <param name="id">The block's id</param>
  22. /// <param name="vector">The rotation amount around the x,y,z-axis</param>
  23. /// <returns>Whether the operation was successful</returns>
  24. public static bool RotateBlock(uint id, float3 vector)
  25. {
  26. if (rotationEngine.IsInGame && GamecraftModdingAPI.Utility.GameState.IsBuildMode())
  27. {
  28. rotationEngine.RotateBlock(id, vector);
  29. return true;
  30. }
  31. return false;
  32. }
  33. /// <summary>
  34. /// Rotate all connected blocks by a specific amount in degrees.
  35. /// This does not do anything because it has not been implemented.
  36. /// </summary>
  37. /// <param name="id">The starting block's id</param>
  38. /// <param name="vector">The rotation around the x,y,z-axis</param>
  39. /// <returns>Whether the operation was successful</returns>
  40. public static bool RotateConnectedBlocks(uint id, float3 vector)
  41. {
  42. if (rotationEngine.IsInGame && GamecraftModdingAPI.Utility.GameState.IsBuildMode())
  43. {
  44. rotationEngine.RotateConnectedBlocks(id, vector);
  45. return true;
  46. }
  47. return false;
  48. }
  49. public static void Init()
  50. {
  51. GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(rotationEngine);
  52. }
  53. }
  54. }