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.

51 lines
1.5KB

  1. using System;
  2. using System.Collections.Generic;
  3. using RobocraftX.Multiplayer;
  4. using RobocraftX.Common;
  5. using Svelto.ECS;
  6. using Svelto.ECS.EntityStructs;
  7. using Unity.Entities;
  8. using Svelto.Context;
  9. using Svelto.Tasks;
  10. using RobocraftX;
  11. using RobocraftX.SimulationModeState;
  12. using RobocraftX.UECS;
  13. using Unity.Transforms;
  14. using Unity.Mathematics;
  15. using UnityEngine;
  16. using GamecraftModdingAPI.Commands;
  17. using GamecraftModdingAPI.Blocks;
  18. namespace ExtraCommands.Building
  19. {
  20. //[CustomCommand("RotateBlocks", "Rotate all blocks (including ground) from their original position")]
  21. [CustomCommand("RotateLastBlock", "Rotate last block from original position")]
  22. class RotateBlocksCommandEngine : ICustomCommandEngine
  23. {
  24. public string Description => "Rotate last block from original position";
  25. public string Name => "RotateLastBlock";
  26. public IEntitiesDB entitiesDB { set; private get; }
  27. public void Ready()
  28. {
  29. CommandRegistrationHelper.Register<float, float, float>(Name, RotateLastBlockCommand, Description);
  30. }
  31. // Move block with highest index by vector (x,y,z)
  32. private void RotateLastBlockCommand(float x, float y, float z)
  33. {
  34. float3 eulerAngles = new float3(x, y, z);
  35. GamecraftModdingAPI.Blocks.Rotation.RotateBlock(BlockIdentifiers.LatestBlockID, eulerAngles);
  36. }
  37. public void Dispose()
  38. {
  39. //CustomCommandUtility.Unregister("RotateBlocks");
  40. CommandRegistrationHelper.Unregister("RotateLastBlock");
  41. }
  42. }
  43. }