Hi! I am making a 2d-grid-based game. I use a NativeArray<bool>
as a map to record whether grids are occupied by buildings(one building occupies several grids, but buildings won’t overlap with each other). For example, for a 3*3 map, array[2] == true
means grid (2,0) is occupied.
When the player build/delete buildings, I want to update the map by
- Dispose the current
NativeArray<bool>
and allocate a new one - Use a
IJobEntity
, with theNativeArray<bool>
passed in, to go through all buildings and set the slots they occupies astrue
.
The thing is, in this job,
- I don’t need to read the map
- I’m sure that the buildings won’t overlap with each other thus they won’t write to the same slot of the
NativeArray<bool>
- Even if they write to the same slot, it doesn’t matter.
Is there a work-around for this?
Plus, is step 1 the best practice to set the whole NativeArray<bool>
as false
?