#Sorted ForEach Loop

1 messages · Page 1 of 1 (latest)

modern crystal
#

In my terrain generation system, I have the following loop:

int chunksLeft = 5;
Entities
    .WithoutBurst()
    .WithAll<ChunkPosition>()
    .WithAll<ChunkLod>()
    .WithAll<GenerateChunkTag>()
    .ForEach((
        in Entity entity,
        in ChunkLod lod,
        in ChunkPosition position
    ) => {
        if (chunksLeft-- < 0)
        {
            return;
        }
        entityCommandBuffer.RemoveComponent<GenerateChunkTag>(entity);
        
        // Generation...
    }).Run()

Basically, every update it generates the next 5 chunks.
I have another system that grades every chunk with a level of detail value (lod). The higher the lod, the closer the chunk is to the player.
I want to prioritize generating chunks with high lod values. Is there a builtin priority feature in DOTS?