Replies: 2 comments
-
I just thought of a possible solution. Maybe one could create a Dictionary<> mapping shared component data to a list of all chunks that use the same shared component data. Then, updating consists of iterating through each Dictionary<> entry, and then through each entry value's chunks. Each entity in that chunk will store a class reference to the shared component data. Because entities sharing identical shared component data will be grouped together, when they end up accessing the shared component data, it will be fast because it's still fresh in the cache. The reason why I asked the original question is because in Godot, I have Units each having dozens of Soldiers. Updating Unit should do the same to all of the soldier's Unit references, so using a class is unavoidable, but if all the Soldiers are grouped next to each other, this cost could be mitigated |
Beta Was this translation helpful? Give feedback.
-
Such a topic has already been considered in theory. The simplest solution would be to simply use class references so that the entities share them ^^ Your approach sounds quite good though, I'll keep an eye on it and tackle it as soon as I have time. But that will take until early next year because it's very stressful at the moment. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to specify a shared component that all entities within a chunk can access efficiently? For example, a data structure representing a behavior tree can be accessed by all entities that use the same behavior tree. This saves space on a per-entity basis because the same data is reused for all entities within a chunk
Beta Was this translation helpful? Give feedback.
All reactions