Managing systems
Finally, we've arrived at the last stop on the entity component system route: handling systems themselves. Let's quickly review our custom data types for this class:
using SystemContainer = std::unordered_map<System,S_Base*>; using EntityEventContainer = std::unordered_map< EntityId,EventQueue>;
The first data type, SystemContainer
, is really hard to misinterpret. An unordered map is used to link system identifiers to actual systems. The second type definition here is responsible for storage of entity events. It also uses an unordered map and links entity identifiers to EventQueue
instances, that all hold events for a specific entity until they're processed.
It's time to design the system manager class:
class EntityManager; class SystemManager{ public: SystemManager(); ~SystemManager(); void SetEntityManager(EntityManager* l_entityMgr); EntityManager* GetEntityManager(); MessageHandler* GetMessageHandler(); template<class T> T* GetSystem(const...