|
| template<typename... Args> |
| Component & | emplace (Entity entity, Args &&... args) |
| | Gives an entity a component built in place.
|
| |
| Component & | get (Entity entity) |
| | Component of an entity.
|
| |
| const Component & | get (Entity entity) const |
| | Component of an entity.
|
| |
| std::optional< std::reference_wrapper< Component > > | try_get (Entity entity) |
| | Component of an entity, if it has one.
|
| |
| std::optional< std::reference_wrapper< const Component > > | try_get (Entity entity) const |
| | Component of an entity, if it has one.
|
| |
| std::span< Component > | components () noexcept |
| | Components of the pool, packed, in the same order as entities().
|
| |
| std::span< const Component > | components () const noexcept |
| | Components of the pool, packed, in the same order as entities().
|
| |
| void | reserve (std::size_t count) |
| | Prepares room for a number of components without reallocating.
|
| |
| | SparseSetBase ()=default |
| |
| | SparseSetBase (const SparseSetBase &)=delete |
| |
| SparseSetBase & | operator= (const SparseSetBase &)=delete |
| |
| | SparseSetBase (SparseSetBase &&) noexcept=default |
| |
| SparseSetBase & | operator= (SparseSetBase &&) noexcept=default |
| |
| virtual | ~SparseSetBase ()=default |
| |
| bool | contains (Entity entity) const noexcept |
| | Tells whether an entity is in the pool.
|
| |
| bool | remove (Entity entity) |
| | Removes an entity and its component; the last entry moves into its place.
|
| |
| void | clear () noexcept |
| | Removes every entity and component.
|
| |
| std::size_t | size () const noexcept |
| | Number of entities in the pool.
|
| |
| bool | empty () const noexcept |
| | Tells whether the pool is empty.
|
| |
| std::span< const Entity > | entities () const noexcept |
| | Entities of the pool, packed, in the same order as the components.
|
| |
template<typename Component>
requires std::movable<Component> && std::is_nothrow_move_assignable_v<Component> && (!std::is_same_v<Component, bool>)
class aegis2d::ecs::SparseSet< Component >
Pool of one component type, stored in a sparse set.
Components are packed in the same order as entities(): iterate both spans together to visit every (entity, component) pair. References and spans returned by the pool are invalidated by any insertion or removal.
- Template Parameters
-
| Component | Movable component type whose move assignment does not throw (removal cannot fail halfway); bool is not allowed (use a tag struct). |