Currently the entity and components are stored in std::vectors and an Entity uses an index to access that std::vector. This causes issues because the developer needs to always consider the case where an Entity does not have a component to prevent out of bounds accesses which throw exceptions / cause crashes.
To deal with this an EntityManager should be created that provides access to the Entity and Component storage. The accessor functions will handle the checks to ensure that an Entity actually has a component before the calling code tries to access the component and use it.
Currently the entity and components are stored in
std::vector
s and anEntity
uses an index to access thatstd::vector
. This causes issues because the developer needs to always consider the case where anEntity
does not have a component to prevent out of bounds accesses which throw exceptions / cause crashes.To deal with this an
EntityManager
should be created that provides access to theEntity
andComponent
storage. The accessor functions will handle the checks to ensure that anEntity
actually has a component before the calling code tries to access the component and use it.