|
|
@@ -49,15 +49,10 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
{ //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.)"); |
|
|
|
BuildBlock((ushort) block, (byte) (color + darkness * 10), position, uscale, scale, rotation).Init( |
|
|
|
new BlockPlacementInfoStruct() |
|
|
|
{ |
|
|
|
loadedFromDisk = false, |
|
|
|
placedBy = playerId |
|
|
|
}); |
|
|
|
BuildBlock((ushort) block, (byte) (color + darkness * 10), position, uscale, scale, rotation, playerId); |
|
|
|
} |
|
|
|
|
|
|
|
private EntityStructInitializer BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, float3 rot) |
|
|
|
private void BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, float3 rot, uint playerId) |
|
|
|
{ |
|
|
|
if (_blockEntityFactory == null) |
|
|
|
throw new Exception("The factory is null."); |
|
|
@@ -78,8 +73,6 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
CubeCategoryStruct category = new CubeCategoryStruct |
|
|
|
{category = CubeCategory.General, type = CubeType.Block}; |
|
|
|
DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid}; |
|
|
|
uint num = PrefabsID.DBIDMAP[dbid]; |
|
|
|
GFXPrefabEntityStructGO gfx = new GFXPrefabEntityStructGO {prefabID = num}; |
|
|
|
BlockPlacementScaleEntityStruct placementScale = new BlockPlacementScaleEntityStruct |
|
|
|
{ |
|
|
|
blockPlacementHeight = uscale, blockPlacementWidth = uscale, desiredScaleFactor = uscale, |
|
|
@@ -99,17 +92,18 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
int cubeId = PrefabsID.GenerateDBID((ushort) category.category, block); |
|
|
|
EntityStructInitializer |
|
|
|
structInitializer = |
|
|
|
_blockEntityFactory.Build(egid2, (uint) cubeId); //The ghost block index is only used for triggers |
|
|
|
_blockEntityFactory.Build(egid2, dbid); //The ghost block index is only used for triggers |
|
|
|
if (colour.indexInPalette != byte.MaxValue) |
|
|
|
structInitializer.Init(new ColourParameterEntityStruct |
|
|
|
{ |
|
|
|
indexInPalette = colour.indexInPalette |
|
|
|
indexInPalette = colour.indexInPalette, |
|
|
|
needsUpdate = true |
|
|
|
}); |
|
|
|
structInitializer.Init(new GFXPrefabEntityStructGPUI(gfx.prefabID)); |
|
|
|
structInitializer.Init(new PhysicsPrefabEntityStruct(gfx.prefabID)); |
|
|
|
uint prefabId = PrefabsID.GetPrefabId(dbid, 0); |
|
|
|
structInitializer.Init(new GFXPrefabEntityStructGPUI(prefabId)); |
|
|
|
structInitializer.Init(new PhysicsPrefabEntityStruct(prefabId)); |
|
|
|
structInitializer.Init(dbEntity); |
|
|
|
structInitializer.Init(new PositionEntityStruct {position = position}); |
|
|
|
structInitializer.Init(rotation); |
|
|
@@ -119,7 +113,17 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
{ |
|
|
|
scaleFactor = placementScale.desiredScaleFactor |
|
|
|
}); |
|
|
|
return structInitializer; |
|
|
|
structInitializer.Init( |
|
|
|
new BlockPlacementInfoStruct() |
|
|
|
{ |
|
|
|
loadedFromDisk = false, |
|
|
|
placedBy = playerId |
|
|
|
}); |
|
|
|
PrimaryRotationUtility.InitialisePrimaryDirection(rotation.rotation, ref structInitializer); |
|
|
|
EGID playerEGID = new EGID(playerId, CharacterExclusiveGroups.OnFootGroup); |
|
|
|
ref PickedBlockExtraDataStruct pickedBlock = ref entitiesDB.QueryEntity<PickedBlockExtraDataStruct>(playerEGID); |
|
|
|
pickedBlock.placedBlockEntityID = playerEGID; |
|
|
|
pickedBlock.placedBlockWasAPickedBlock = false; |
|
|
|
} |
|
|
|
|
|
|
|
public string Name { get; } = "GamecraftModdingAPIPlacementGameEngine"; |
|
|
|