public void CreateChunks(Archetype *archetype, ArchetypeChunk *chunks, int entityCount) { fixed(EntityComponentStore *entityComponentStore = &this) { int *sharedComponentValues = stackalloc int[archetype->NumSharedComponents]; int chunkIndex = 0; while (entityCount != 0) { var chunk = GetCleanChunk(archetype, sharedComponentValues); int allocatedIndex; var allocatedCount = AllocateIntoChunk(chunk, entityCount, out allocatedIndex); AllocateEntities(archetype, chunk, allocatedIndex, allocatedCount, null); ChunkDataUtility.InitializeComponents(chunk, allocatedIndex, allocatedCount); chunk->SetAllChangeVersions(GlobalSystemVersion); chunks[chunkIndex] = new ArchetypeChunk(chunk, entityComponentStore); entityCount -= allocatedCount; chunkIndex++; } IncrementComponentTypeOrderVersion(archetype); } }
public static void CreateEntities(Archetype *archetype, Entity *entities, int count, EntityComponentStore *entityComponentStore, ManagedComponentStore managedComponentStore) { var sharedComponentValues = stackalloc int[archetype->NumSharedComponents]; UnsafeUtility.MemClear(sharedComponentValues, archetype->NumSharedComponents * sizeof(int)); while (count != 0) { var chunk = GetChunkWithEmptySlots(archetype, sharedComponentValues, entityComponentStore, managedComponentStore); int allocatedIndex; var allocatedCount = AllocateIntoChunk(chunk, count, out allocatedIndex, entityComponentStore, managedComponentStore); entityComponentStore->AllocateEntities(archetype, chunk, allocatedIndex, allocatedCount, entities); ChunkDataUtility.InitializeComponents(chunk, allocatedIndex, allocatedCount); chunk->SetAllChangeVersions(entityComponentStore->GlobalSystemVersion); entities += allocatedCount; count -= allocatedCount; } entityComponentStore->IncrementComponentTypeOrderVersion(archetype); }
public static void CreateChunks(Archetype *archetype, ArchetypeChunk *chunks, int entityCount, EntityComponentStore *entityComponentStore, ManagedComponentStore managedComponentStore) { int *sharedComponentValues = stackalloc int[archetype->NumSharedComponents]; UnsafeUtility.MemClear(sharedComponentValues, archetype->NumSharedComponents * sizeof(int)); Chunk *lastChunk = null; int chunkIndex = 0; while (entityCount != 0) { var chunk = GetCleanChunk(archetype, sharedComponentValues, entityComponentStore, managedComponentStore); int allocatedIndex; var allocatedCount = AllocateIntoChunk(chunk, entityCount, out allocatedIndex, entityComponentStore, managedComponentStore); entityComponentStore->AllocateEntities(archetype, chunk, allocatedIndex, allocatedCount, null); ChunkDataUtility.InitializeComponents(chunk, allocatedIndex, allocatedCount); chunk->SetAllChangeVersions(entityComponentStore->GlobalSystemVersion); chunks[chunkIndex] = new ArchetypeChunk(chunk, entityComponentStore); lastChunk = chunk; entityCount -= allocatedCount; chunkIndex++; } entityComponentStore->IncrementComponentTypeOrderVersion(archetype); }
public void CreateChunks(Archetype *archetype, ArchetypeChunk *chunks, int chunksCount, int entityCount) { fixed(EntityComponentStore *entityComponentStore = &this) { int *sharedComponentValues = stackalloc int[archetype->NumSharedComponents]; int chunkIndex = 0; while (entityCount != 0) { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (chunkIndex >= chunksCount) { throw new System.ArgumentException($"CreateChunks chunks array is not large enough to hold the array of chunks {chunksCount}."); } #endif var chunk = GetCleanChunk(archetype, sharedComponentValues); int allocatedIndex; var allocatedCount = AllocateIntoChunk(chunk, entityCount, out allocatedIndex); AllocateEntities(archetype, chunk, allocatedIndex, allocatedCount, null); ChunkDataUtility.InitializeComponents(chunk, allocatedIndex, allocatedCount); chunk->SetAllChangeVersions(GlobalSystemVersion); chunks[chunkIndex] = new ArchetypeChunk(chunk, entityComponentStore); entityCount -= allocatedCount; chunkIndex++; } IncrementComponentTypeOrderVersion(archetype); } }
public void CreateEntities(ArchetypeManager archetypeManager, Archetype *archetype, Entity *entities, int count) { int *sharedComponentDataIndices = stackalloc int[archetype->NumSharedComponents]; UnsafeUtility.MemClear(sharedComponentDataIndices, archetype->NumSharedComponents * sizeof(int)); while (count != 0) { var chunk = archetypeManager.GetChunkWithEmptySlots(archetype, sharedComponentDataIndices); int allocatedIndex; var allocatedCount = archetypeManager.AllocateIntoChunk(chunk, count, out allocatedIndex); AllocateEntities(archetype, chunk, allocatedIndex, allocatedCount, entities); ChunkDataUtility.InitializeComponents(chunk, allocatedIndex, allocatedCount); entities += allocatedCount; count -= allocatedCount; } IncrementComponentTypeOrderVersion(archetype); }
// ---------------------------------------------------------------------------------------------------------- // PUBLIC // ---------------------------------------------------------------------------------------------------------- public void CreateEntities(Archetype *archetype, Entity *entities, int count) { var archetypeChunkFilter = new ArchetypeChunkFilter(); archetypeChunkFilter.Archetype = archetype; while (count != 0) { var chunk = GetChunkWithEmptySlots(ref archetypeChunkFilter); int allocatedIndex; var allocatedCount = AllocateIntoChunk(chunk, count, out allocatedIndex); AllocateEntities(archetype, chunk, allocatedIndex, allocatedCount, entities); ChunkDataUtility.InitializeComponents(chunk, allocatedIndex, allocatedCount); chunk->SetAllChangeVersions(GlobalSystemVersion); entities += allocatedCount; count -= allocatedCount; } IncrementComponentTypeOrderVersion(archetype); }