|
Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
|
Template class storing components contiguously in memory for optimal cache usage. More...
#include <ComponentStorage.hpp>
Public Member Functions | |
| void | add (Entity e, T comp) |
| Adds a component to an entity. | |
| bool | has (Entity e) const |
| Checks if an entity possesses this component. | |
| void | remove (Entity e) |
| Removes the component from an entity. | |
| void | removeEntity (Entity e) override |
| Polymorphic interface to remove entity component. | |
| T & | get (Entity e) |
| Retrieves the component associated with an entity. | |
| const std::vector< Entity > & | getEntities () const override |
| Retrieves all entities with this component. | |
| size_t | size () const override |
| Returns the size of the storage. | |
| auto | begin () |
| Gets start iterator of stored component data. | |
| auto | end () |
| Gets end iterator of stored component data. | |
| auto | entityBegin () |
| Gets start iterator of stored entity list. | |
| auto | entityEnd () |
| Gets end iterator of stored entity list. | |
| Public Member Functions inherited from IStorage | |
| virtual | ~IStorage ()=default |
| Virtual destructor. | |
Private Attributes | |
| std::vector< T > | data |
| Contiguous array of component instances. | |
| std::vector< Entity > | entities |
| Entity mapping matching data array order. | |
| std::unordered_map< Entity, size_t > | entityToIndex |
| Mapping for quick entity component lookup. | |
Template class storing components contiguously in memory for optimal cache usage.
| T | Type of component being stored. |
|
inline |
Adds a component to an entity.
| e | The target entity. |
| comp | The component instance. |
|
inline |
Gets start iterator of stored component data.
|
inline |
Gets end iterator of stored component data.
|
inline |
Gets start iterator of stored entity list.
|
inline |
Gets end iterator of stored entity list.
|
inline |
Retrieves the component associated with an entity.
| e | The target entity. |
|
inlineoverridevirtual |
|
inline |
Checks if an entity possesses this component.
| e | The entity to check. |
|
inline |
Removes the component from an entity.
| e | The entity to remove. |
|
inlineoverridevirtual |
Polymorphic interface to remove entity component.
| e | The entity to remove. |
Implements IStorage.
|
inlineoverridevirtual |
|
private |
Contiguous array of component instances.
|
private |
Entity mapping matching data array order.
|
private |
Mapping for quick entity component lookup.