View.ixx File
Lightweight view for iterating entities with specific components. More...
Included Headers
#include <tuple>
#include <vector>
#include <functional>
#include <type_traits>
#include <helios.engine.core.data.EntityId>
#include <helios.engine.ecs.EntityHandle>
#include <helios.engine.ecs.GameObject>
#include <helios.engine.ecs.EntityManager>
#include <helios.engine.ecs.SparseSet>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | ecs |
|
Core Entity-Component-System architecture. More... | |
Classes Index
| class | View<Components> |
|
A view class to iterate over entities having specific components. More... | |
| struct | Iterator |
Description
Lightweight view for iterating entities with specific components.
File Listing
The file content with the documentation metadata removed is:
21export namespace helios::engine::ecs {
51 EntityManager* em_;
63 std::vector<std::function<bool(EntityId)>> excludeChecks_;
78 explicit View(EntityManager* em) : em_(em) {
107 excludeChecks_.emplace_back([set](EntityId entityId) {
122 View& whereEnabled() {
138 using LeadComponent = std::tuple_element_t<0, std::tuple<Components...>>;
143 using LeadIterator = typename SparseSet<LeadComponent>::Iterator;
161 Iterator(LeadIterator current, LeadIterator end, const View* view)
183 if (!view_->em_->isValid(entityId)) {
191 }, view_->includeSets_);
198 for (const auto& excludeCheck : view_->excludeChecks_) {
205 if (view_->filterEnabledOnly_) {
217 if (!isComponentEnabled(*current_)) {
225 }, view_->includeSets_);
243 ++current_;
252 Iterator& operator++() noexcept {
253 advance();
264 bool operator!=(const Iterator& other) const noexcept {
265 return current_ != other.current_;
278 auto handle = view_->em_->handle(entityId);
282 std::make_tuple(GameObject(handle, view_->em_)),
285 }, view_->includeSets_)
302 return Iterator{};
305 Iterator it{leadSet->begin(), leadSet->end(), this};
307 if (!it.isValid()) {
308 it.advance();
323 return Iterator{};
326 return Iterator{leadSet->end(), leadSet->end(), this};
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.