I want to implement endless generated grid where:
- Cells grouped by a chunks which can be rather an entity or some other grouping data structure
- Each cell is an entity which linked by grid chunk
all mentions of chunk refers to grid chunk and not to
ArchetypeChunk
Cell count in grid chunk is known at compile time, so I can transform global grid coordinates (x,y) to coordinates of chunk then obtain that chunk and access cell entity by it's local to chunk coordinates.
This lets me access to cell in chunk with O(1).
But how effectively store grid chunks is an open question for me. I guess chunks also can be inside other chunks and so on, and if I know current top level of chunk nesting I can recursively access chunks until reach needed cell. How would you implement such data hierarchy? Though with growing nesting lvl grows number of ComponentLookup accesses.
However chunks can store fixed cells count and I'm looking for solution to do this. I see planty of ways:
- Using just
DynamicBuffer<CellLink>whereCellLink : IBufferElementData { public Entity Entity; }but I don't need dynamic size collection for this - Using
FixedListX<Entity>but again I don't need list functionality - Using c# fixed-arrays but they only allow us to use primitive blittable types in unsafe context while I need to store entity link and today unity ECS have no lightweight entity version with just single int or a way to convert single int to existing entity (or just use 2 fixed arrays of ints to store entities like separately)
- Store nested collections somewhere on system side but not "on entities". This can be done with managed collection in a simple way or with native collections in complex way of implementing needed collection structure using all this unfamiliar to me unsafe native arrays, etc.
Well. Maybe one of dots senseis can give me clever advice. I hope so 🙂