Fix placement engine for latest GC and add block IDs
This commit is contained in:
parent
d1c0556b9c
commit
f231ea9f6d
2 changed files with 39 additions and 18 deletions
|
@ -162,8 +162,9 @@ namespace GamecraftModdingAPI.Blocks
|
|||
TractorTyre,
|
||||
MonsterTruckTyre,
|
||||
MotocrossBikeTyre,
|
||||
CartTyre,
|
||||
ANDLogicBlock = 170,
|
||||
CartTyre, //168
|
||||
ObjectIdentifier,
|
||||
ANDLogicBlock,
|
||||
NANDLogicBlock,
|
||||
NORLogicBlock,
|
||||
NOTLogicBlock,
|
||||
|
@ -180,6 +181,13 @@ namespace GamecraftModdingAPI.Blocks
|
|||
SubtractorMathsBlock,
|
||||
SimpleConnector,
|
||||
MeanMathsBlock,
|
||||
Bit,
|
||||
Counter,
|
||||
Timer,
|
||||
ObjectFilter,
|
||||
PlayerFilter,
|
||||
TeamFilter,
|
||||
Number2Text, //193
|
||||
BeachTree1 = 200,
|
||||
BeachTree2,
|
||||
BeachTree3,
|
||||
|
@ -208,6 +216,15 @@ namespace GamecraftModdingAPI.Blocks
|
|||
GrassEdge,
|
||||
GrassEdgeInnerCorner,
|
||||
GrassEdgeCorner,
|
||||
GrassEdgeSlope
|
||||
GrassEdgeSlope,
|
||||
CentreHUD,
|
||||
ObjectiveHUD,
|
||||
GameStatsHUD, //231
|
||||
Mover = 250,
|
||||
Rotator,
|
||||
MovementDampener,
|
||||
RotationDampener,
|
||||
AdvancedMover,
|
||||
AdvancedRotator
|
||||
}
|
||||
}
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue