|
- using Svelto.ECS;
- //using Svelto.Context;
- using Unity.Mathematics;
- using GamecraftModdingAPI.Commands;
- using GamecraftModdingAPI;
-
- namespace ExtraCommands.Building
- {
- [CustomCommand("MoveLastBlock", "Move last block from original position")]
- class MoveBlocksCommandEngine : ICustomCommandEngine
- {
- private const float BLOCKSIZE = 0.2f;
-
- public string Description => "Move blocks";
-
- public string Name => "MoveBlocks";
-
- public EntitiesDB entitiesDB { set; private get; }
-
- public bool isRemovable => false;
-
- public void Ready()
- {
- //CustomCommandUtility.Register<float, float, float>("MoveBlocks", MoveBlocksCommand, "Move all blocks (including ground) from their original position");
- CommandRegistrationHelper.Register<float, float, float>("MoveLastBlock", MoveLastBlockCommand, "Move last block, and connecting blocks, from their original position");
- }
-
- private void MoveLastBlockCommand(float x, float y, float z)
- {
- float3 vector = new float3(x * BLOCKSIZE, y * BLOCKSIZE, z * BLOCKSIZE);
- Block lastBlock = Block.GetLastPlacedBlock();
- Block[] besideBlocks = lastBlock.GetConnectedCubes();
- for (int i = 0; i < besideBlocks.Length; i++)
- {
- besideBlocks[i].Position += vector;
- }
- //lastBlock.Position += vector;
- }
-
- public void Dispose()
- {
- //CommandRegistrationHelper.Unregister("MoveBlocks");
- CommandRegistrationHelper.Unregister("MoveLastBlock");
- }
- }
- }
|