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); } }
public void AddToChunkList(Chunk *chunk, SharedComponentValues sharedComponentIndices, uint changeVersion) { chunk->ListIndex = Chunks.Count; if (Chunks.Count == Chunks.Capacity) { int newCapacity = Chunks.Capacity == 0 ? 1 : Chunks.Capacity * 2; if (Chunks.data <= sharedComponentIndices.firstIndex && sharedComponentIndices.firstIndex < Chunks.data + Chunks.Count) { int sourceChunk = (int)(sharedComponentIndices.firstIndex - Chunks.data); // The shared component indices we are inserting belong to the same archetype so they need to be adjusted after reallocation Chunks.Grow(newCapacity); sharedComponentIndices = Chunks.GetSharedComponentValues(sourceChunk); } else { Chunks.Grow(newCapacity); } } Chunks.Add(chunk, sharedComponentIndices, changeVersion); }