I’m writing a system that’s preparing data for instantiating Prefabs at runtime. It’s a procedurally generated city. This system receives city block data, e.g. location & extents, block type (commercial, industrial, etc.) which determines allowable prefab types. So it iterates over each city block with an IJobParallelFor. Ideally what I would return for each index (city block) being processed is a NativeList of Prefab IDs and corresponding location/rotation as each block is filled with many buildings.
I think it was previously possible to use a NativeMultiHashMap that had a NativeList as the value, but I think that was a bug and was removed?
The other option I can think of is that I only place 1 building on each iteration and update the block dimensions accordingly, i.e. it’s reduced in size as it gets filled with buildings over many iterations of the same job, until it block has been “completed”. The drawback here is that it’s inefficient as I might be performing some calculations/filtering on every iteration which would give identical results each time (not sure I can do that in a previous job as this would resulted in another nested list as an input). And I presume I have to call Complete() on the job after each iteration to determine if more iterations are needed.
Appreciate any advice people might have on how to best implement this.
What you could try, is to use IJobParallelFor and multihashmap with parallel writing.
Once job is done, grab unique keys, from the hasmap. Your keys are your unique prefabs IDs, in that particular city block.
Sorry I did not read the first part last time.
But It sounds like a single MuitiHashMap is already good enough. why do you need a nested list?
MuitiHashMap Key=[block index] and multiple Values for prefabs
MuitiHashMap itself can have multiple values for the same key by defualt.