ecs/View.ixx File
Lightweight view for iterating entities with specific components. More...
Included Headers
#include <tuple>
#include <vector>
#include <functional>
#include <helios.ecs.Entity>
#include <helios.ecs.EntityManager>
#include <helios.ecs.types.TypeDefs>
#include <helios.ecs.types.EntityHandle>
#include <helios.ecs.SparseSet>
Namespaces Index
| namespace | helios |
| namespace | ecs |
|
Generic, reusable ECS primitives. More... | |
Classes Index
| class | View<TEntityManager, 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:
19using namespace helios::ecs::types;
20export namespace helios::ecs {
67 std::vector<std::function<bool(EntityId)>> excludeChecks_;
111 excludeChecks_.emplace_back([set](EntityId entityId) {
134 View& whereEnabled() {
148 using Entity_type = Entity<TEntityManager>;
153 using LeadComponent = std::tuple_element_t<0, std::tuple<Components...>>;
158 using LeadIterator = typename SparseSet<LeadComponent>::Iterator;
176 Iterator(LeadIterator current, LeadIterator end, const View* view)
198 if (!view_->em_->isValid(entityId)) {
206 }, view_->includeSets_);
213 for (const auto& excludeCheck : view_->excludeChecks_) {
220 if (view_->filterEnabledOnly_) {
232 if (!isComponentEnabled(*current_)) {
240 }, view_->includeSets_);
258 ++current_;
267 Iterator& operator++() noexcept {
268 advance();
279 bool operator!=(const Iterator& other) const noexcept {
280 return current_ != other.current_;
293 auto handle = view_->em_->handle(entityId);
297 std::make_tuple(Entity_type(handle, view_->em_)),
300 }, view_->includeSets_)
304 [[nodiscard]] bool operator==(const Iterator& other) const noexcept {
305 return current_ == other.current_;
321 return Iterator{};
324 Iterator it{leadSet->begin(), leadSet->end(), this};
326 if (!it.isValid()) {
327 it.advance();
342 return Iterator{};
345 return Iterator{leadSet->end(), leadSet->end(), this};
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.