Browse Source

Fix rotation parameter

tags/v0.1.3.0
NorbiPeti 4 years ago
parent
commit
dd72f42cc2
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
2 changed files with 8 additions and 18 deletions
  1. +3
    -3
      GamecraftModdingAPI/Blocks/Placement.cs
  2. +5
    -15
      GamecraftModdingAPI/Blocks/PlacementEngine.cs

+ 3
- 3
GamecraftModdingAPI/Blocks/Placement.cs View File

@@ -21,14 +21,14 @@ namespace GamecraftModdingAPI.Blocks
/// <param name="color">The block's color</param>
/// <param name="darkness">The block color's darkness (0-9) - 0 is default color</param>
/// <param name="position">The block's position in the grid - default block size is 0.2</param>
/// <param name="rotation">The block's rotation</param>
/// <param name="rotation">The block's rotation in degrees</param>
/// <param name="uscale">The block's uniform scale - default scale is 1 (with 0.2 width)</param>
/// <param name="scale">The block's non-uniform scale - 0 means <paramref name="uscale"/> is used</param>
/// <param name="playerId">The player who placed the block</param>
/// <returns>Whether the operation was successful</returns>
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())
{


+ 5
- 15
GamecraftModdingAPI/Blocks/PlacementEngine.cs View File

@@ -44,19 +44,8 @@ namespace GamecraftModdingAPI.Blocks
public IEntitiesDB entitiesDB { get; set; }
internal static BlockEntityFactory _blockEntityFactory; //Injected from PlaceBlockEngine

/// <summary>
/// Places a block at the given position
/// </summary>
/// <param name="block">The block's type</param>
/// <param name="color">The block's color</param>
/// <param name="darkness">The block color's darkness - 0 is default color</param>
/// <param name="position">The block's position - default block size is 0.2</param>
/// <param name="uscale">The block's uniform scale - default scale is 1 (with 0.2 width)</param>
/// <param name="scale">The block's non-uniform scale - less than 1 means <paramref name="uscale"/> is used</param>
/// <param name="playerId">The player who placed the block</param>
/// <exception cref="Exception"></exception>
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;


Loading…
Cancel
Save