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.

47 lines
1.9KB

  1. using System;
  2. using GamecraftModdingAPI.Utility;
  3. using GCMC;
  4. using Unity.Mathematics;
  5. namespace GamecraftModdingAPI.Blocks
  6. {
  7. /// <summary>
  8. /// Common block movement operations
  9. /// </summary>
  10. public static class Placement
  11. {
  12. private static PlacementEngine placementEngine = new PlacementEngine();
  13. /// <summary>
  14. /// Place a block at the given position. If scaled, position means the center of the block. The default block size is 0.2 in terms of position.
  15. /// Place blocks next to each other to connect them.
  16. /// </summary>
  17. /// <param name="block">The block's type</param>
  18. /// <param name="color">The block's color</param>
  19. /// <param name="darkness">The block color's darkness (0-9) - 0 is default color</param>
  20. /// <param name="position">The block's position in the grid - default block size is 0.2</param>
  21. /// <param name="rotation">The block's rotation</param>
  22. /// <param name="uscale">The block's uniform scale - default scale is 1 (with 0.2 width)</param>
  23. /// <param name="scale">The block's non-uniform scale - 0 means <paramref name="uscale"/> is used</param>
  24. /// <param name="playerId">The player who placed the block</param>
  25. /// <exception cref="Exception"></exception>
  26. public static bool PlaceBlock(BlockIDs block, float3 position,
  27. quaternion rotation = new quaternion(), BlockColors color = BlockColors.Default, byte darkness = 0,
  28. int uscale = 1, float3 scale = new float3(), uint playerId = 0)
  29. {
  30. if (placementEngine.IsInGame && GameState.IsBuildMode())
  31. {
  32. placementEngine.PlaceBlock(block, color, darkness, position, uscale, scale, playerId, rotation);
  33. return true;
  34. }
  35. return false;
  36. }
  37. public static void Init()
  38. {
  39. GameEngineManager.AddGameEngine(placementEngine);
  40. }
  41. }
  42. }