8template <
typename T,
typename... Types>
15 : lists_(std::make_tuple(&list...)),
17 main_it_(main.begin()) {}
24 auto all_exist = [
this](
auto&... lists) ->
bool {
25 return (
true && ... && lists->at(main_it_.pos()).valid());
27 auto it_end = main_list_->end();
28 while (main_it_ != it_end) {
29 if (main_it_.valid()) {
30 if (std::apply(all_exist, lists_)) {
43 auto res = std::apply(
44 [
this](
auto&... lists) {
45 return std::make_tuple(
46 std::ref(main_it_.component()),
47 std::ref(lists->at(main_it_.pos()).component())...);
68 void reset() { main_it_ = main_list_->begin(); }
71 std::tuple<Types*...> lists_;
73 typename T::Iterator main_it_;
Helper to iterate several component lists simultaneously.
Definition: lists_iterator.hpp:9
Entity getEntity()
retrieves the entity being currently iterated
Definition: lists_iterator.hpp:60
auto get()
Retrieve the components of the last entity found using next.
Definition: lists_iterator.hpp:42
bool next()
Iterates all lists until an entity containing all components is found.
Definition: lists_iterator.hpp:23
ComponentIterator(T &main, Types &... list)
Constructor.
Definition: lists_iterator.hpp:14
void reset()
Resets the internal state, so that you can iterate the lists again.
Definition: lists_iterator.hpp:68
Identifies an entity. This class can only be modified by the engine.
Definition: component_manager.hpp:16