Hey everyone,
I have been trying to create an entity component system for a while and thought that i had a good lay out but now i have ran into a big problem.
My first implementation was based on entities holding all of their components in a vector. systems would then loop though all entities see if they have the entities they care about and then act if they had them.
As im sure you would be able to tell, this will hurt as we will loop though every entity and check if it has a component (or many more) which will hurt performance.
My second version planned to use an unordered map for every component type where the key will be the id of the component. This was looking good for a while but i ran into a problem with performance again. For systems I can loop though a component type but if i want a different component type (say for rendering i need model and texture and transpose component). I would need to do a find check to make sure that a map has a component of that ID. sadly this causes a massive loss in performance and leaves me where i was before.
So I guess really I'm asking for some guidance. Does anyone have a suggestion in a good way to create my entity component system to avoid performance problem. should i continue to use unordered maps or should I use vectors.
Thanks for reading :).