Here is a simplified example of a parallel IJobChunk job. How can I update the component in each entity within the chunk without having create a new struct (in this case a Translation)?
With more complex components, that would mean having to copy over all the other values in an entity when I only want to update one property of that component.
[BurstCompile]
struct MyJob: IJobChunk
{
public float3 deltaPosition;
public ArchetypeChunkComponentType<Translation> translationType;
public void Execute(ArchetypeChunk archetypeChunk, int chunkIndex, int firstEntityIndex)
{
NativeArray<Translation> chunkTranslations = archetypeChunk.GetNativeArray(translationType);
for (int i = 0; i < chunkTranslations.Length; i++)
{
chunkTranslations[i] = new Translation { Value = chunkTranslations[i].Value + deltaPosition };
}
}
}