public void DestroyEntityBatchInChunk(EntityBatchInChunk entityBatchInChunk) { ChunkUtility.PatchEntityData(entityBatchInChunk.chunk, entityBatchInChunk.index, entityBatchInChunk.count); // TODO: This thing needs to be more efficent. var movedEntities = ChunkUtility.GetEntities(entityBatchInChunk.chunk); if (entityBatchInChunk.index < movedEntities.Length) // Copied from end? { movedEntities = movedEntities.Slice(entityBatchInChunk.index, Math.Min(movedEntities.Length, entityBatchInChunk.count)); for (int i = 0; i < movedEntities.Length; ++i) { var entityIndex = movedEntities[i].index; this.entitiesInChunk[entityIndex].chunk = entityBatchInChunk.chunk; this.entitiesInChunk[entityIndex].index = entityBatchInChunk.index + i; } } // TODO: Free chunks if chunk->count == 0 after patching entities ++this.version; }
public ReadOnlySpan <Entity> GetEntities() => ChunkUtility.GetEntities(chunk);