[C++/SFML] ECS - How to deal with the entities?

Started by
9 comments, last by PureSnowX 10 years, 4 months ago

So I'm currently necroing this thread because I'm back again, desperately trying to wrap my head around ECS! I did read all the way until the last post, so I'm aware of what have been said, although some is a bit fuzzy.

The root of my problems with ECS is basically the entities themselves! How to store them, how to "kill" them and how to make sure that old entity id's are validated as "alive" if they have been reused. I'm stuck here and I'v been reading source like crazy and googling like there is no tomorrow. Most of the code i find are either very cluttered or quite "heavy", making it hard to get a good overview of the system, they aren't simple so to speak.

I have gained some more insight on templates since last time, and "typeid(T).name()" have served me well in various tasks. However the root of my problem with the ECS problem still exists. The entities.

My current naive implementation is basically that each entity is an "unsigned long long" and that the "World" has a


std::map< unsigned long long, std::map< std::string, Component* > > componentBag;

that keeps components associated with objects. I can imagine it's rather ineffective and as one might guess I'm not recycling any old entity id's

I turn to you guys, In hope of getting a throughout and careful explanation on how to deal with entities and how to invalidate and recycle. Preferably some mentions of the association of components.

I know it's a lot to ask, but hopefully someone might be able to answer my request :)

This topic is closed to new replies.

Advertisement