public void RemoveFromChunkList(Chunk *chunk, ref EntityComponentStore.ChunkListChanges changes) { Chunks.RemoveAtSwapBack(chunk->ListIndex); var chunkThatMoved = Chunks[chunk->ListIndex]; chunkThatMoved->ListIndex = chunk->ListIndex; fixed(Archetype *archetype = &this) { changes.TrackArchetype(archetype); } }
public void AddToChunkList(Chunk *chunk, SharedComponentValues sharedComponentIndices, uint changeVersion, ref EntityComponentStore.ChunkListChanges changes) { chunk->ListIndex = Chunks.Count; if (Chunks.Count == Chunks.Capacity) { var newCapacity = (Chunks.Capacity == 0) ? 1 : (Chunks.Capacity * 2); // The shared component indices we are inserting belong to the same archetype so they need to be adjusted after reallocation if (Chunks.InsideAllocation((ulong)sharedComponentIndices.firstIndex)) { int chunkIndex = (int)(sharedComponentIndices.firstIndex - Chunks.GetSharedComponentValueArrayForType(0)); Chunks.Grow(newCapacity); sharedComponentIndices = Chunks.GetSharedComponentValues(chunkIndex); } else { Chunks.Grow(newCapacity); } } Chunks.Add(chunk, sharedComponentIndices, changeVersion); fixed(Archetype *archetype = &this) { changes.TrackArchetype(archetype); } }