using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Unity.Mathematics; namespace GamecraftModdingAPI.Blocks { /// /// Common block movement operations. /// The functionality of this class only works in build mode. /// public static class Movement { private static MovementEngine movementEngine = new MovementEngine(); /// /// Move a single block by a specific (x,y,z) amount (offset). /// The moved block will remain connected to the blocks it was touching before it was moved. /// The block's placement grid and collision box are also moved. /// /// The block's id /// The movement amount (x,y,z) /// Whether the operation was successful public static bool MoveBlock(uint id, float3 vector) { if (movementEngine.IsInGame && GamecraftModdingAPI.Utility.GameState.IsBuildMode()) { movementEngine.MoveBlock(id, vector); return true; } return false; } /// /// Move all connected blocks by a specific (x,y,z) amount (offset). /// The moved blocks will remain connected to the block they're touching. /// All of the block's placement grids and collision boxes are also moved. /// This is equivalent to calling MoveBlock() for every connected block. /// /// The starting block's id /// The movement amount (x,y,z) /// Whether the operation was successful public static bool MoveConnectedBlocks(uint id, float3 vector) { if (movementEngine.IsInGame && GamecraftModdingAPI.Utility.GameState.IsBuildMode()) { movementEngine.MoveConnectedBlocks(id, vector); return true; } return false; } public static void Init() { GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(movementEngine); } } }