diff --git a/Pixi/Robots/CubeInfo.cs b/Pixi/Robots/CubeInfo.cs index 842b4b5..e7a9242 100644 --- a/Pixi/Robots/CubeInfo.cs +++ b/Pixi/Robots/CubeInfo.cs @@ -23,6 +23,6 @@ namespace Pixi.Robots public float3 scale; - public string placeholder; + public string name; } } diff --git a/Pixi/Robots/CubeUtility.cs b/Pixi/Robots/CubeUtility.cs index 370cdf2..be52614 100644 --- a/Pixi/Robots/CubeUtility.cs +++ b/Pixi/Robots/CubeUtility.cs @@ -331,7 +331,7 @@ namespace Pixi.Robots if (!map.ContainsKey(cubeId)) { result.block = BlockIDs.TextBlock; - result.placeholder = "Unknown cube #" + cubeId.ToString(); + result.name = "Unknown cube #" + cubeId.ToString(); //result.rotation = float3.zero; #if DEBUG Logging.MetaLog($"Unknown cubeId {cubeId}"); @@ -411,7 +411,7 @@ namespace Pixi.Robots else { result.block = BlockIDs.TextBlock; - result.placeholder = cubeName; + result.name = cubeName; } } } diff --git a/Pixi/Robots/RobotCommands.cs b/Pixi/Robots/RobotCommands.cs index b8baa8a..11ac3db 100644 --- a/Pixi/Robots/RobotCommands.cs +++ b/Pixi/Robots/RobotCommands.cs @@ -58,16 +58,21 @@ namespace Pixi.Robots float3 position = new Player(PlayerType.Local).Position; position.y += (float)blockSize; CubeInfo[] cubes = CubeUtility.ParseCubes(robot.Value); + Block[] blocks = new Block[cubes.Length]; for (int c = 0; c < cubes.Length; c++) // sometimes I wish this were C++ { CubeInfo cube = cubes[c]; float3 realPosition = (cube.position * (float)blockSize) + position; - Block newBlock = Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, scale: cube.scale); + blocks[c] = Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, scale: cube.scale); + } + for (int c = 0; c < cubes.Length; c++) + { + CubeInfo cube = cubes[c]; // the goal is for this to never evaluate to true (ie all cubes are translated correctly) - if (!string.IsNullOrEmpty(cube.placeholder) && cube.block == BlockIDs.TextBlock) - { - newBlock.Specialise().Text = cube.placeholder; - } + if (!string.IsNullOrEmpty(cube.name) && cube.block == BlockIDs.TextBlock) + { + blocks[c].Specialise().Text = cube.name; + } } Logging.CommandLog($"Placed {robot.Value.name} by {robot.Value.addedByDisplayName} ({cubes.Length} cubes) beside you"); } @@ -97,15 +102,20 @@ namespace Pixi.Robots float3 position = new Player(PlayerType.Local).Position; position.y += (float)blockSize; CubeInfo[] cubes = CubeUtility.ParseCubes(robot); + Block[] blocks = new Block[cubes.Length]; for (int c = 0; c < cubes.Length; c++) // sometimes I wish this were C++ { CubeInfo cube = cubes[c]; float3 realPosition = (cube.position * (float)blockSize) + position; - Block newBlock = Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, scale: cube.scale); + blocks[c] = Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, scale: cube.scale); + } + for (int c = 0; c < cubes.Length; c++) + { + CubeInfo cube = cubes[c]; // the goal is for this to never evaluate to true (ie all cubes are translated correctly) - if (!string.IsNullOrEmpty(cube.placeholder) && cube.block == BlockIDs.TextBlock) + if (!string.IsNullOrEmpty(cube.name) && cube.block == BlockIDs.TextBlock) { - newBlock.Specialise().Text = cube.placeholder; + blocks[c].Specialise().Text = cube.name; } } Logging.CommandLog($"Placed {robot.name} by {robot.addedByDisplayName} ({cubes.Length} cubes) beside you");