From dd72f42cc2cf6830eb9d33ff034f94ef3e9e443a Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 15 Jan 2020 20:41:50 +0100 Subject: [PATCH] Fix rotation parameter --- GamecraftModdingAPI/Blocks/Placement.cs | 6 +++--- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 20 +++++-------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/Placement.cs b/GamecraftModdingAPI/Blocks/Placement.cs index f650312..d91d214 100644 --- a/GamecraftModdingAPI/Blocks/Placement.cs +++ b/GamecraftModdingAPI/Blocks/Placement.cs @@ -21,14 +21,14 @@ namespace GamecraftModdingAPI.Blocks /// The block's color /// The block color's darkness (0-9) - 0 is default color /// The block's position in the grid - default block size is 0.2 - /// The block's rotation + /// The block's rotation in degrees /// The block's uniform scale - default scale is 1 (with 0.2 width) /// The block's non-uniform scale - 0 means is used /// The player who placed the block /// Whether the operation was successful public static bool PlaceBlock(BlockIDs block, float3 position, - quaternion rotation = new quaternion(), BlockColors color = BlockColors.Default, byte darkness = 0, - int uscale = 1, float3 scale = new float3(), uint playerId = 0) + float3 rotation = default, BlockColors color = BlockColors.Default, byte darkness = 0, + int uscale = 1, float3 scale = default, uint playerId = 0) { if (placementEngine.IsInGame && GameState.IsBuildMode()) { diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index fbad336..0bcf890 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -44,19 +44,8 @@ namespace GamecraftModdingAPI.Blocks public IEntitiesDB entitiesDB { get; set; } internal static BlockEntityFactory _blockEntityFactory; //Injected from PlaceBlockEngine - /// - /// Places a block at the given position - /// - /// The block's type - /// The block's color - /// The block color's darkness - 0 is default color - /// The block's position - default block size is 0.2 - /// The block's uniform scale - default scale is 1 (with 0.2 width) - /// The block's non-uniform scale - less than 1 means is used - /// The player who placed the block - /// public void PlaceBlock(BlockIDs block, BlockColors color, byte darkness, float3 position, int uscale, - float3 scale, uint playerId, quaternion rotation) + float3 scale, uint playerId, float3 rotation) { //It appears that only the non-uniform scale has any visible effect, but if that's not given here it will be set to the uniform one if (darkness > 9) throw new Exception("That is too dark. Make sure to use 0-9 as darkness. (0 is default.)"); @@ -68,7 +57,7 @@ namespace GamecraftModdingAPI.Blocks }); } - private EntityStructInitializer BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, quaternion rot) + private EntityStructInitializer BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, float3 rot) { if (_blockEntityFactory == null) throw new Exception("The factory is null."); @@ -79,9 +68,10 @@ namespace GamecraftModdingAPI.Blocks if (scale.z < 4e-5) scale.z = uscale; //RobocraftX.CR.MachineEditing.PlaceBlockEngine ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale}; - RotationEntityStruct rotation = new RotationEntityStruct {rotation = quaternion.identity}; + Quaternion rotQ = Quaternion.Euler(rot); + RotationEntityStruct rotation = new RotationEntityStruct {rotation = rotQ}; GridRotationStruct gridRotation = new GridRotationStruct - {position = float3.zero, rotation = quaternion.identity}; + {position = position, rotation = rotQ}; CubeCategoryStruct category = new CubeCategoryStruct {category = CubeCategory.General, type = CubeType.Block}; uint dbid = block;