I've read some articles about Entity Component System and I like this idea of "entities" having lots of "components" to define them, so I tried to implement it. Here is an simple overview of what i've got so far:
I've a template class that will hold a list for each component type that exit
That allows me to have a collection of components by its type
Which is good because in memory components will be contiguous
Then I've a component manager that hold all these collections and allows me to retrieve a collection at any time
Also, each entity keeps tack of all components it has with a bitset
So in the final result, each index of all component containers belongs to an entity
I know that this causes a problem than, not all entities have all components, so it causes a waste of space... But for now, I can (saldy) live with it
But the real issue for me here is that some components will have same data, and if each entity have a component for that data, this data will be duplicated unnecessary
Even worst, it would require OpenGL to have different objects in memory that are exactly equal and having to enable those objects and disable them many times is not desirable at all.
I've been scratching my head to figure out a solution for this issue but I can't find any. Could someone give me an advice please?
If you've read this far, Thank You!