Ver código fonte

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
tags/v2.0.0
NorbiPeti 3 anos atrás
pai
commit
4807c12387
Acessado por: NorbiPeti <szatmari.norbert.peter@gmail.com> ID da chave GPG: DBA4C4549A927E56
1 arquivos alterados com 15 adições e 3 exclusões
  1. +15
    -3
      TechbloxModdingAPI/Blocks/PlacementEngine.cs

+ 15
- 3
TechbloxModdingAPI/Blocks/PlacementEngine.cs Ver arquivo

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


Carregando…
Cancelar
Salvar