Fix rotation parameter
This commit is contained in:
parent
7c633045e4
commit
dd72f42cc2
2 changed files with 8 additions and 18 deletions
|
@ -21,14 +21,14 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
/// <param name="color">The block's color</param>
|
/// <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="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="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="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="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>
|
/// <param name="playerId">The player who placed the block</param>
|
||||||
/// <returns>Whether the operation was successful</returns>
|
/// <returns>Whether the operation was successful</returns>
|
||||||
public static bool PlaceBlock(BlockIDs block, float3 position,
|
public static bool PlaceBlock(BlockIDs block, float3 position,
|
||||||
quaternion rotation = new quaternion(), BlockColors color = BlockColors.Default, byte darkness = 0,
|
float3 rotation = default, BlockColors color = BlockColors.Default, byte darkness = 0,
|
||||||
int uscale = 1, float3 scale = new float3(), uint playerId = 0)
|
int uscale = 1, float3 scale = default, uint playerId = 0)
|
||||||
{
|
{
|
||||||
if (placementEngine.IsInGame && GameState.IsBuildMode())
|
if (placementEngine.IsInGame && GameState.IsBuildMode())
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,19 +44,8 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
public IEntitiesDB entitiesDB { get; set; }
|
public IEntitiesDB entitiesDB { get; set; }
|
||||||
internal static BlockEntityFactory _blockEntityFactory; //Injected from PlaceBlockEngine
|
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,
|
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
|
{ //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)
|
if (darkness > 9)
|
||||||
throw new Exception("That is too dark. Make sure to use 0-9 as darkness. (0 is default.)");
|
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)
|
if (_blockEntityFactory == null)
|
||||||
throw new Exception("The factory is null.");
|
throw new Exception("The factory is null.");
|
||||||
|
@ -79,9 +68,10 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
if (scale.z < 4e-5) scale.z = uscale;
|
if (scale.z < 4e-5) scale.z = uscale;
|
||||||
//RobocraftX.CR.MachineEditing.PlaceBlockEngine
|
//RobocraftX.CR.MachineEditing.PlaceBlockEngine
|
||||||
ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale};
|
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
|
GridRotationStruct gridRotation = new GridRotationStruct
|
||||||
{position = float3.zero, rotation = quaternion.identity};
|
{position = position, rotation = rotQ};
|
||||||
CubeCategoryStruct category = new CubeCategoryStruct
|
CubeCategoryStruct category = new CubeCategoryStruct
|
||||||
{category = CubeCategory.General, type = CubeType.Block};
|
{category = CubeCategory.General, type = CubeType.Block};
|
||||||
uint dbid = block;
|
uint dbid = block;
|
||||||
|
|
Loading…
Reference in a new issue