Please keep in mind, my components have relatively little functionality compared to yours, but still I think you could benefit by trimming yours! Saving ram is one thing, but it looks like your design will not play too nicely with modern CPU Cache's, and so you will potentially loose performance as well.
A few comments (Disclaimer - This is purely my current thoughts, and may be completely wrong, and I may even change my opinions next week!)
- I spent about 2 years designing in my head how my Entity-Component system might work, and I went through a lot of iterations. All I can say from that research is there is no right answer that suits all use cases! However I got a lot of inspiration from
EntityX as well as UE4 and unity. I could not use entityX due to the way Component IDs are generated and a few other specific issues to my system, otherwise I probably would have used it.
- Your Graphics component is big, I would be tempted to separate out some of those into there own components. In my system I have components that take up 0 Bytes. This is because I uses EntityX's concept of having a bitmask on each entity which describes what components it has associated with it. So in yours you could maybe have a Smoke Component which is separate to GraphicsComponent, etc
hyyou wrote:
Entity = 228 ................................... (mainly contain pointer to 50 components)
- By the sounds of this you have a pointer to every possible component in every entity? This is probably going to annoy you at somepoint, but it depends how expandable you want your engine. It is certainly wasteful. Again I would suggest using enityX's concept of have a bitmask on each entity, if you wanted to allow up to 50 components per entity then you would use a 64bit bitmask, and that would be only 8 bytes
.
- You seem to also be heading down an inheritance design for your components, this is a slippery route and I would advise against it!
- I dont full understand the smart pointer part. ECS have 2 problems (in my opinion) that can be difficult to solve. 1) how to deal with interactions between 2 different components, 2) how to iterate over and update all components of a specific type. Both problems are not necessarily that difficult to solve, but getting them to perform well, with a clean code base and work for a wide range of use cases, can be tricky! Again EntityX shows some sensible ways of doing this.