static NativeArray <EntityInChunkWithGuid> GetSortedEntitiesInChunk ( ArchetypeChunkChangeSet archetypeChunkChangeSet, Allocator allocator, out JobHandle jobHandle, JobHandle dependsOn = default) { var entities = new NativeArray <EntityInChunkWithGuid>(archetypeChunkChangeSet.TotalEntityCount, allocator, NativeArrayOptions.UninitializedMemory); var gatherEntitiesByChunk = new GatherEntityInChunkWithGuid { EntityGuidTypeIndex = TypeManager.GetTypeIndex <EntityGuid>(), Chunks = archetypeChunkChangeSet.Chunks, Flags = archetypeChunkChangeSet.Flags, EntityCounts = archetypeChunkChangeSet.EntityCounts, Entities = entities }.Schedule(archetypeChunkChangeSet.Chunks.Length, 64, dependsOn); var sortEntities = new SortNativeArrayWithComparer <EntityInChunkWithGuid, EntityInChunkWithGuidComparer> { Array = entities }.Schedule(gatherEntitiesByChunk); jobHandle = sortEntities; return(entities); }
static NativeList <BlobAssetPtr> GetReferencedBlobAssets( NativeArray <ArchetypeChunk> chunks, Allocator allocator, out JobHandle jobHandle, JobHandle dependsOn = default) { var blobAssets = new NativeList <BlobAssetPtr>(1, allocator); var blobAssetsMap = new NativeHashMap <ulong, int>(1, allocator); var gatherUniqueBlobAssets = new GatherUniqueBlobAssetReferences { TypeInfo = TypeManager.GetTypeInfoPointer(), BlobAssetRefOffsets = TypeManager.GetBlobAssetRefOffsetsPointer(), Chunks = chunks, BlobAssets = blobAssets, BlobAssetsMap = blobAssetsMap }.Schedule(dependsOn); var sortBlobAssets = new SortNativeArrayWithComparer <BlobAssetPtr, BlobAssetPtrComparer> { Array = blobAssets.AsDeferredJobArray() }.Schedule(gatherUniqueBlobAssets); jobHandle = blobAssetsMap.Dispose(sortBlobAssets); return(blobAssets); }
public JobHandle Schedule() { var handle = new BuildEntityInChunkWithComponent { ComponentTypeIndex = TypeManager.GetTypeIndex <TComponent>(), Chunks = m_ArchetypeChunks.Chunks, ChunkChangeFlags = m_ArchetypeChunks.ChunkChangeFlags, Offsets = m_ArchetypeChunks.EntityCountOffsets, Entities = m_Entities }.Schedule(m_ArchetypeChunks.Chunks.Length, 64); handle = new SortNativeArrayWithComparer <EntityInChunkWithComponent <TComponent>, EntityInChunkWithComponentComparer <TComponent> > { Array = m_Entities }.Schedule(handle); return(handle); }