public void Execute(int index) { var chunk = Chunks[index].m_Chunk; var archetype = chunk->Archetype; if (!archetype->CompareMask(QueryMask)) // Archetype doesn't match query { return; } var sequenceNumber = chunk->SequenceNumber; if (ShadowChunksBySequenceNumber.TryGetValue(sequenceNumber, out var shadow)) { return; } var entityDataPtr = chunk->Buffer + archetype->Offsets[0]; shadow = new ShadowChunk { Count = chunk->Count, Version = chunk->GetChangeVersion(0), EntityBuffer = (byte *)UnsafeUtility.Malloc(sizeof(Entity) * chunk->Capacity, 4, Allocator.Persistent), }; UnsafeUtility.MemCpy(shadow.EntityBuffer, entityDataPtr, chunk->Count * sizeof(Entity)); AllocatedShadowChunks[index] = shadow; }
public void Execute(int index) { var chunk = Chunks[index].m_Chunk; var archetype = chunk->Archetype; var indexInTypeArray = ChunkDataUtility.GetIndexInTypeArray(archetype, TypeIndex); if (indexInTypeArray == -1) // Archetype doesn't match required component { return; } var sequenceNumber = chunk->SequenceNumber; if (ShadowChunksBySequenceNumber.TryGetValue(sequenceNumber, out var shadow)) { return; } var entityDataPtr = chunk->Buffer + archetype->Offsets[0]; shadow = new ShadowChunk { EntityCount = chunk->Count, Version = chunk->GetChangeVersion(0), EntityDataBuffer = (Entity *)UnsafeUtility.Malloc(sizeof(Entity) * chunk->Capacity, 4, Allocator.Persistent), }; UnsafeUtility.MemCpy(shadow.EntityDataBuffer, entityDataPtr, chunk->Count * sizeof(Entity)); AllocatedShadowChunks[index] = shadow; }