-
I'm trying to streamline my system for synchronizing components between a client and server, and my current idea is to do something like:
Does it seem sane to make this the backbone of the process I'm building (potentially calling try_get() hundreds or thousands of times in a frame, if many clients come in range of new entities)? Or is there a more efficient approach that I should take for determining which components are on an entity? I know that internally each component is given an integer index, but I'm guessing the registry doesn't build lists of the component indices that each entity possesses? I could do that externally using on_construct and on_destruct callbacks. It seems like that might be a more efficient approach for this problem, but the cost of maintaining a vector per entity might make it not worthwhile. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yeah, keeping the list of components for each entity has its pros and cons and the right approach really depends on the final use. |
Beta Was this translation helpful? Give feedback.
Yeah, keeping the list of components for each entity has its pros and cons and the right approach really depends on the final use.
For example, in a game on which I've worked in the past we only tracked components on addition. The final list can contain false positives but the solution doesn't hurt performance if you have many creations/deletions.
Also, when it comes to sharing data between client and server, you don't even want to send all components most of the time. As a trivial example, a flyweight-like handle for a renderable object or an input listener tag aren't of interest in this context probably.
I'd probably flip the problem on its head then and send only the components of inte…