|
|
@@ -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; |
|
|
|