Andidy / engine-v2

1 stars 0 forks source link

Helper functions for Entity and Component access #42

Closed Andidy closed 3 years ago

Andidy commented 3 years ago

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.