Fix placing blocks

Most of the removed initialitzers are actually important
Also, the prefab ID was not calculated correctly
Also, the category is 1, not sure why but it is
This commit is contained in:
Norbi Peti 2021-05-13 00:13:31 +02:00
parent 3432a1ae33
commit 4807c12387
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56

View file

@ -9,6 +9,7 @@ using RobocraftX.Blocks.Scaling;
using RobocraftX.Character;
using RobocraftX.Common;
using RobocraftX.CR.MachineEditing;
using RobocraftX.Rendering;
using Svelto.ECS;
using Svelto.ECS.EntityStructs;
using Unity.Mathematics;
@ -55,12 +56,23 @@ namespace TechbloxModdingAPI.Blocks
DBEntityStruct dbEntity = new DBEntityStruct {DBID = block};
EntityInitializer structInitializer = _blockEntityFactory.Build(CommonExclusiveGroups.nextBlockEntityID, block); //The ghost block index is only used for triggers
uint prefabId = PrefabsID.GetOrCreatePrefabID(block, (byte) BlockMaterial.SteelBodywork, 0, false);
uint prefabAssetID = structInitializer.Has<PrefabAssetIDComponent>()
? structInitializer.Get<PrefabAssetIDComponent>().prefabAssetID
: throw new BlockException("Prefab asset ID not found!"); //Set by the game
uint prefabId = PrefabsID.GetOrCreatePrefabID((ushort) prefabAssetID, (byte) BlockMaterial.SteelBodywork, 1, false);
structInitializer.Init(new GFXPrefabEntityStructGPUI(prefabId));
structInitializer.Init(new PhysicsPrefabEntityStruct(prefabId));
structInitializer.Init(dbEntity);
structInitializer.Init(new PositionEntityStruct {position = position});
structInitializer.Init(new BlockPlacementInfoStruct()
structInitializer.Init(new RotationEntityStruct {rotation = quaternion.identity});
structInitializer.Init(new ScalingEntityStruct {scale = new float3(1, 1, 1)});
structInitializer.Init(new GridRotationStruct
{
position = position,
rotation = quaternion.identity
});
structInitializer.Init(new UniformBlockScaleEntityStruct {scaleFactor = 1});
structInitializer.Get<CubeMaterialStruct>().materialId = (byte) BlockMaterial.SteelBodywork;
structInitializer.Init(new BlockPlacementInfoStruct() //TODO: Grid scale
{
loadedFromDisk = false,
placedBy = playerId,