Moar Gamecraft commands!
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.4KB

  1. using Svelto.ECS;
  2. //using Svelto.Context;
  3. using Unity.Mathematics;
  4. using GamecraftModdingAPI.Commands;
  5. using GamecraftModdingAPI;
  6. namespace ExtraCommands.Building
  7. {
  8. [CustomCommand("MoveLastBlock", "Move last block from original position")]
  9. class MoveBlocksCommandEngine : ICustomCommandEngine
  10. {
  11. private const float BLOCKSIZE = 0.2f;
  12. public string Description => "Move blocks";
  13. public string Name => "MoveBlocks";
  14. public EntitiesDB entitiesDB { set; private get; }
  15. public bool isRemovable => false;
  16. public void Ready()
  17. {
  18. //CustomCommandUtility.Register<float, float, float>("MoveBlocks", MoveBlocksCommand, "Move all blocks (including ground) from their original position");
  19. CommandRegistrationHelper.Register<float, float, float>("MoveLastBlock", MoveLastBlockCommand, "Move last block, and connecting blocks, from their original position");
  20. }
  21. private void MoveLastBlockCommand(float x, float y, float z)
  22. {
  23. float3 vector = new float3(x * BLOCKSIZE, y * BLOCKSIZE, z * BLOCKSIZE);
  24. Block lastBlock = Block.GetLastPlacedBlock();
  25. Block[] besideBlocks = lastBlock.GetConnectedCubes();
  26. for (int i = 0; i < besideBlocks.Length; i++)
  27. {
  28. besideBlocks[i].Position += vector;
  29. }
  30. //lastBlock.Position += vector;
  31. }
  32. public void Dispose()
  33. {
  34. //CommandRegistrationHelper.Unregister("MoveBlocks");
  35. CommandRegistrationHelper.Unregister("MoveLastBlock");
  36. }
  37. }
  38. }