From 16f833cedaeb046454e565768c7043ee8e86671e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 28 Sep 2020 02:52:51 +0200 Subject: [PATCH] Fix RC glass cube and revert temp text support --- Pixi/Common/CommandRoot.cs | 13 +--- Pixi/Common/VoxelObjectNotationUtility.cs | 2 +- Pixi/Robots/CubeUtility.cs | 85 +++++------------------ Pixi/Robots/RobotInternetImporter.cs | 7 +- 4 files changed, 25 insertions(+), 82 deletions(-) diff --git a/Pixi/Common/CommandRoot.cs b/Pixi/Common/CommandRoot.cs index 1081c6b..4a81f66 100644 --- a/Pixi/Common/CommandRoot.cs +++ b/Pixi/Common/CommandRoot.cs @@ -160,21 +160,12 @@ namespace Pixi.Common for (int i = 0; i < optVONsArr.Length; i++) { ProcessedVoxelObjectNotation desc = optVONsArr[i]; - Block b; if (desc.block != BlockIDs.Invalid) { - b = Block.PlaceNew(desc.block, desc.position, desc.rotation, desc.color.Color, + Block b = Block.PlaceNew(desc.block, desc.position, desc.rotation, desc.color.Color, desc.color.Darkness, 1, desc.scale); + blocks[i] = b; } - else - { - TextBlock tb = Block.PlaceNew(BlockIDs.TextBlock, desc.position, desc.rotation, - desc.color.Color, desc.color.Darkness, 1, desc.scale); - tb.Text = desc.metadata; - b = tb; - } - - blocks[i] = b; } magicImporter.PostProcess(name, ref blocks); if (magicImporter.Optimisable && blockCountPreOptimisation > blocks.Length) diff --git a/Pixi/Common/VoxelObjectNotationUtility.cs b/Pixi/Common/VoxelObjectNotationUtility.cs index 5cb491c..00b4f0c 100644 --- a/Pixi/Common/VoxelObjectNotationUtility.cs +++ b/Pixi/Common/VoxelObjectNotationUtility.cs @@ -44,7 +44,7 @@ namespace Pixi.Common if (origin == null) origin = origin_base; return new BlockJsonInfo { - name = block.Type == BlockIDs.TextBlock ? block.Label : block.Type.ToString(), + name = block.Type.ToString(), position = new float[3] { block.Position.x - origin[0], block.Position.y - origin[1], block.Position.z - origin[2]}, rotation = new float[3] { block.Rotation.x, block.Rotation.y, block.Rotation.z }, color = ColorSpaceUtility.UnquantizeToArray(block.Color), diff --git a/Pixi/Robots/CubeUtility.cs b/Pixi/Robots/CubeUtility.cs index a658d94..611283b 100644 --- a/Pixi/Robots/CubeUtility.cs +++ b/Pixi/Robots/CubeUtility.cs @@ -215,10 +215,10 @@ namespace Pixi.Robots [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void TranslateBlockId(uint cubeId, ref CubeInfo result) { - if (map == null) + if (map == null) { StreamReader cubemap = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Pixi.cubes-id.json")); - map = JsonConvert.DeserializeObject>(cubemap.ReadToEnd()); + map = JsonConvert.DeserializeObject>(cubemap.ReadToEnd()); } if (!map.ContainsKey(cubeId)) @@ -231,81 +231,34 @@ namespace Pixi.Robots #endif } string cubeName = map[cubeId]; + + string gcName = cubeName.Contains("glass") || cubeName.Contains("windshield") + ? "Glass" + : "Aluminium"; + if (cubeName.Contains("round")) + gcName += "Rounded"; + if (cubeName.Contains("cube")) - { - result.block = BlockIDs.AluminiumCube; - result.rotation = float3.zero; - } + gcName += "Cube"; else if (cubeName.Contains("prism") || cubeName.Contains("edge")) - { - if (cubeName.Contains("round")) - { - if (cubeName.Contains("glass") || cubeName.Contains("windshield")) - { - result.block = BlockIDs.GlassRoundedSlope; - } else - result.block = BlockIDs.AluminiumRoundedSlope; - } - else - { - if (cubeName.Contains("glass") || cubeName.Contains("windshield")) - { - result.block = BlockIDs.GlassSlope; - } else - result.block = BlockIDs.AluminiumSlope; - } - } + gcName += "Slope"; else if (cubeName.Contains("inner")) - { - if (cubeName.Contains("round")) - { - if (cubeName.Contains("glass") || cubeName.Contains("windshield")) - { - result.block = BlockIDs.GlassRoundedSlicedCube; - } else - result.block = BlockIDs.AluminiumRoundedSlicedCube; - } - else - { - if (cubeName.Contains("glass") || cubeName.Contains("windshield")) - { - result.block = BlockIDs.GlassSlicedCube; - } else - result.block = BlockIDs.AluminiumSlicedCube; - } - } + gcName += "SlicedCube"; else if (cubeName.Contains("tetra") || cubeName.Contains("corner")) - { - if (cubeName.Contains("round")) - { - if (cubeName.Contains("glass") || cubeName.Contains("windshield")) - { - result.block = BlockIDs.GlassRoundedCorner; - } else - result.block = BlockIDs.AluminiumRoundedCorner; - } - else - { - if (cubeName.Contains("glass") || cubeName.Contains("windshield")) - { - result.block = BlockIDs.GlassCorner; - } else - result.block = BlockIDs.AluminiumCorner; - } - } + gcName += "Corner"; else if (cubeName.Contains("pyramid")) - { - result.block = BlockIDs.AluminiumPyramidSegment; - } + gcName += "PyramidSegment"; else if (cubeName.Contains("cone")) - { - result.block = BlockIDs.AluminiumConeSegment; - } + gcName += "ConeSegment"; else { result.block = BlockIDs.TextBlock; result.name = cubeName; + return; } + + BlockIDs id = VoxelObjectNotationUtility.NameToEnum(gcName); + result.block = id; } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Pixi/Robots/RobotInternetImporter.cs b/Pixi/Robots/RobotInternetImporter.cs index 1059e6e..b07e254 100644 --- a/Pixi/Robots/RobotInternetImporter.cs +++ b/Pixi/Robots/RobotInternetImporter.cs @@ -134,11 +134,10 @@ namespace Pixi.Robots { Block block = blocks[c]; // the goal is for this to never evaluate to true (ie all cubes are translated correctly) - if (block.Type == BlockIDs.TextBlock && - (string.IsNullOrEmpty(block.Label) || block.Label == "Text Block")) + if (block.Type == BlockIDs.TextBlock) { - block.Specialise().Text = textBlockInfo[name][textBlockInfoIndex]; - textBlockInfoIndex++; + block.Specialise().Text = textBlockInfo[name][textBlockInfoIndex]; + textBlockInfoIndex++; } }