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.

Blueprint.cs 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using Unity.Mathematics;
  3. namespace GamecraftModdingAPI
  4. {
  5. /// <summary>
  6. /// Represents a blueprint in the inventory. When placed it becomes a block group.
  7. /// </summary>
  8. public class Blueprint : IDisposable
  9. {
  10. public uint Id { get; }
  11. internal Blueprint(uint id)
  12. {
  13. Id = id;
  14. BlockGroup._engine.InitBlueprint(id);
  15. }
  16. /*public static void SelectBlueprint(Blueprint blueprint)
  17. {
  18. BlueprintUtil.SelectBlueprint(null, new BlueprintInventoryItemEntityStruct
  19. {
  20. blueprintResourceId = blueprint.Id
  21. });
  22. }*/
  23. /// <summary>
  24. /// Creates a new, empty blueprint. It will be deleted on disposal unless the game holds a reference to it.
  25. /// </summary>
  26. /// <returns>A blueprint that doesn't have any blocks</returns>
  27. public static Blueprint Create()
  28. {
  29. return new Blueprint(BlockGroup._engine.CreateBlueprint());
  30. }
  31. /// <summary>
  32. /// Set the blocks that the blueprint contains.
  33. /// </summary>
  34. /// <param name="blocks">The array of blocks to use</param>
  35. /// <param name="position">The anchor position of the blueprint</param>
  36. /// <param name="rotation">The rotation of the blueprint</param>
  37. public void SetStoredBlocks(Block[] blocks, float3 position = default, float3 rotation = default)
  38. {
  39. BlockGroup._engine.ReplaceBlueprint(Player.LocalPlayer.Id, Id, blocks, position,
  40. quaternion.Euler(rotation));
  41. }
  42. /// <summary>
  43. /// Places the blocks the blueprint contains at the specified position and rotation.
  44. /// </summary>
  45. /// <param name="position">The position of the blueprint</param>
  46. /// <param name="rotation">The rotation of the blueprint</param>
  47. /// <returns>An array of the placed blocks</returns>
  48. public Block[] PlaceBlocks(float3 position, float3 rotation)
  49. {
  50. return BlockGroup._engine.PlaceBlueprintBlocks(Id, Player.LocalPlayer.Id, position, rotation);
  51. }
  52. public void Dispose()
  53. {
  54. BlockGroup._engine.DisposeBlueprint(Id);
  55. }
  56. }
  57. }