Managing entities
Now that we have the building blocks of entities defined, it's time to talk about storing and managing them. As mentioned previously, all an entity is at this point is a single identifier. Knowing that, we can begin shaping the way this data is going to be stored, beginning, as always, with the definition of data types to be used:
using EntityId = unsigned int; using ComponentContainer = std::vector<C_Base*>; using EntityData = std::pair<Bitmask,ComponentContainer>; using EntityContainer = std::unordered_map<EntityId,EntityData>; using ComponentFactory = std::unordered_map< Component,std::function<C_Base*(void)>>;
The first data type we'll be working with is the entity identifier, once again represented by an unsigned integer. Next, a container is needed to hold all of the components for an entity. A vector works just fine for this purpose. Following that, we define a pair, a bitmask and the component container, which will hold all of the...