Sharing Arrays with systems?

Been playing wit dots for a few weeks now and starting to understand the new way to structure data. However, since IcomponentData’s don’t hold arrays and it seem neither does entities, I’m looking for a way to create a hashtable that holds a grid in it and allow it to be accessed by other systems that will have to access that grids data. But I have yet to find a way to do this.

Any suggestions?

You could look into DynamicBuffer

Was hoping to use something with a string key for quickly finding a spot in the array as needed.

Is this a single shared grid or one per entity?

For a single shared grid, you can use a system-level NativeHashMap.

Ya it’s one grid per entity but I need other systems to access it. Like a grid system to make and edit it but allow like a render system to access to make a mesh on the fly for a floor.

Systems really shouldn’t be accessing other systems. This kind of data access should really be component-level.

I’m making my case for an “Array-Style” component search right now, in fact.

Ya that would be nice.

I have a suspicion I might have already built a solution that does what you want, but I am struggling to fully understand your problem and don’t want to add noise to the thread.

It sounds like what you really want is a 2d array and a hashmap with strings as keys and indices into the array as values. And you want to store both of these things per entity without having to couple systems together. What is not clear is whether you want to treat the array and hashmap as NativeContainers that can be split up and accessed by parallel jobs, or whether you want to treat the array and hashmap as component data, allowing only a single thread which has access to the entity to access these data structures?

Still new to dots in unity but my hope was to put the data of the grids into components. Each component holds the data for its position, if something is built in that cell, and vertices positions. Then use a hastable for the entity to allow all systems to access it with a string key that would be its position in string forum.

I have yet to see a way to do this in unity or a work around with what I have learned so far. Maybe the beta is just no developed enough for what I want to do, but down the road I was thinking of taking advantage of jobs for multi threading.

Oh. You just need a NativeHashMap<FixedString64, Entity> or perhaps NativeHashMap<int2, Entity> (I highly suggest you move away from strings and use the latter).

As for where to store that NativeHashMap, it seems different people have different opinions. But the general consensus is that you always want to store a JobHandle or two with it.

Ah thank you. I didn’t know about the fixedstring64. But looks like I will have to find a new way to make this idea since I don’t see a way to access anything but components from entities.