|
| | View (SparseSet< Components > &... pools) noexcept |
| | Creates a view on the given pools.
|
| |
template<typename Function >
requires std::invocable<Function&, Entity, Components&...> || std::invocable<Function&, Components&...> |
| void | each (Function function) |
| | Calls a function for every entity that owns all the components.
|
| |
| bool | contains (Entity entity) const noexcept |
| | Tells whether an entity owns all the components of the view.
|
| |
template<typename Component >
requires (std::is_same_v<Component, Components> || ...) |
| Component & | get (Entity entity) const |
| | One component of an entity of the view.
|
| |
| std::size_t | size_hint () const noexcept |
| | Upper bound of the number of entities visited.
|
| |
template<typename... Components>
requires (sizeof...(Components) > 0) && detail::distinct_types<Components...>
class aegis2d::ecs::View< Components >
Visits every entity that owns all of Components, with those components.
A view is a cheap handle on the pools of its component types: it copies nothing and sees the pools as they are when it iterates. Usually obtained from Registry::view():
});
void each(Function function)
Calls a function for every entity that owns all the components.
Definition view.hpp:65
How fast an entity moves.
Definition components.hpp:25
Vec2 value
Speed in logical pixels per second.
Definition components.hpp:27
Iteration walks the smallest pool and checks the others in O(1), so its cost follows the rarest component, not the number of entities. The order of the visit is not specified.
The callback may remove components from the entity it is visiting, or destroy it: the other entities are still visited exactly once. Adding or removing components of the viewed types on other entities during the visit is not supported, and invalidates the references the callback holds.
- Template Parameters
-
| Components | Component types, at least one, all different. |