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,
|
TractorTyre,
|
||||||
MonsterTruckTyre,
|
MonsterTruckTyre,
|
||||||
MotocrossBikeTyre,
|
MotocrossBikeTyre,
|
||||||
CartTyre,
|
CartTyre, //168
|
||||||
ANDLogicBlock = 170,
|
ObjectIdentifier,
|
||||||
|
ANDLogicBlock,
|
||||||
NANDLogicBlock,
|
NANDLogicBlock,
|
||||||
NORLogicBlock,
|
NORLogicBlock,
|
||||||
NOTLogicBlock,
|
NOTLogicBlock,
|
||||||
|
@ -180,6 +181,13 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
SubtractorMathsBlock,
|
SubtractorMathsBlock,
|
||||||
SimpleConnector,
|
SimpleConnector,
|
||||||
MeanMathsBlock,
|
MeanMathsBlock,
|
||||||
|
Bit,
|
||||||
|
Counter,
|
||||||
|
Timer,
|
||||||
|
ObjectFilter,
|
||||||
|
PlayerFilter,
|
||||||
|
TeamFilter,
|
||||||
|
Number2Text, //193
|
||||||
BeachTree1 = 200,
|
BeachTree1 = 200,
|
||||||
BeachTree2,
|
BeachTree2,
|
||||||
BeachTree3,
|
BeachTree3,
|
||||||
|
@ -208,6 +216,15 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
GrassEdge,
|
GrassEdge,
|
||||||
GrassEdgeInnerCorner,
|
GrassEdgeInnerCorner,
|
||||||
GrassEdgeCorner,
|
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
|
{ //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.)");
|
||||||
BuildBlock((ushort) block, (byte) (color + darkness * 10), position, uscale, scale, rotation).Init(
|
BuildBlock((ushort) block, (byte) (color + darkness * 10), position, uscale, scale, rotation, playerId);
|
||||||
new BlockPlacementInfoStruct()
|
|
||||||
{
|
|
||||||
loadedFromDisk = false,
|
|
||||||
placedBy = 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)
|
if (_blockEntityFactory == null)
|
||||||
throw new Exception("The factory is null.");
|
throw new Exception("The factory is null.");
|
||||||
|
@ -78,8 +73,6 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
CubeCategoryStruct category = new CubeCategoryStruct
|
CubeCategoryStruct category = new CubeCategoryStruct
|
||||||
{category = CubeCategory.General, type = CubeType.Block};
|
{category = CubeCategory.General, type = CubeType.Block};
|
||||||
DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid};
|
DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid};
|
||||||
uint num = PrefabsID.DBIDMAP[dbid];
|
|
||||||
GFXPrefabEntityStructGO gfx = new GFXPrefabEntityStructGO {prefabID = num};
|
|
||||||
BlockPlacementScaleEntityStruct placementScale = new BlockPlacementScaleEntityStruct
|
BlockPlacementScaleEntityStruct placementScale = new BlockPlacementScaleEntityStruct
|
||||||
{
|
{
|
||||||
blockPlacementHeight = uscale, blockPlacementWidth = uscale, desiredScaleFactor = uscale,
|
blockPlacementHeight = uscale, blockPlacementWidth = uscale, desiredScaleFactor = uscale,
|
||||||
|
@ -99,17 +92,18 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cubeId = PrefabsID.GenerateDBID((ushort) category.category, block);
|
|
||||||
EntityStructInitializer
|
EntityStructInitializer
|
||||||
structInitializer =
|
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)
|
if (colour.indexInPalette != byte.MaxValue)
|
||||||
structInitializer.Init(new ColourParameterEntityStruct
|
structInitializer.Init(new ColourParameterEntityStruct
|
||||||
{
|
{
|
||||||
indexInPalette = colour.indexInPalette
|
indexInPalette = colour.indexInPalette,
|
||||||
|
needsUpdate = true
|
||||||
});
|
});
|
||||||
structInitializer.Init(new GFXPrefabEntityStructGPUI(gfx.prefabID));
|
uint prefabId = PrefabsID.GetPrefabId(dbid, 0);
|
||||||
structInitializer.Init(new PhysicsPrefabEntityStruct(gfx.prefabID));
|
structInitializer.Init(new GFXPrefabEntityStructGPUI(prefabId));
|
||||||
|
structInitializer.Init(new PhysicsPrefabEntityStruct(prefabId));
|
||||||
structInitializer.Init(dbEntity);
|
structInitializer.Init(dbEntity);
|
||||||
structInitializer.Init(new PositionEntityStruct {position = position});
|
structInitializer.Init(new PositionEntityStruct {position = position});
|
||||||
structInitializer.Init(rotation);
|
structInitializer.Init(rotation);
|
||||||
|
@ -119,7 +113,17 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
scaleFactor = placementScale.desiredScaleFactor
|
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";
|
public string Name { get; } = "GamecraftModdingAPIPlacementGameEngine";
|
||||||
|
|
Loading…
Reference in a new issue