Does anybody know how the entities within IJobChunk can be grabbed? I have a simple code where I browse through entities, spawn new ones at the position of the old ones and remove the old ones afterwards. The interesting part is in line 8 (entityrefs = ???), as we don’t talk about components, I cannot use ComponentTypeHandle…
public struct SplitSoldierEntities : IJobChunk {
public ComponentTypeHandle<LocalTransform> localtransformtypehandle;
public EntityCommandBuffer.ParallelWriter _ecb;
public void Execute(in ArchetypeChunk chunk, int entityInQueryIndex, bool useEnabledMask, in v128 chunkEnabledMask)
{
NativeArray<LocalTransform> localtransforms = chunk.GetNativeArray<LocalTransform>(ref localtransformtypehandle);
NativeArray<Entity> entityrefs = ???
for (int i = 0; i < localtransforms.Length; i++)
{
LocalTransform localtr = localtransforms[i];
//spawn new ones
//...
//destroy old ones
_ecb.DestroyEntity(entityInQueryIndex, entityrefs[i]);
}
}
}
public void SplitSoldiersInGroup(ref SystemState state, Entity group) {
EntityManager entitymanager = World.DefaultGameObjectInjectionWorld.EntityManager;
EntityQuery groupquery = groupdata.soldiersformovement;
SplitSoldierEntities splitjob = new()
{
localtransformtypehandle = state.GetComponentTypeHandle<LocalTransform>(),
};
state.Dependency = splitjob.ScheduleParallel(groupquery, state.Dependency);
}