|
|
@@ -352,6 +352,35 @@ public:
|
|
|
((std::get<pool_type<Component> *>(pools) == view ? each<Component>(std::get<pool_type<Component> *>(pools), std::move(func), std::make_index_sequence<sizeof...(Component)-1>{}) : void()), ...);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Iterates entities and components and applies the given function
|
|
|
+ * object to them.
|
|
|
+ *
|
|
|
+ * The function object is invoked for each entity. It is provided with the
|
|
|
+ * entity itself and a set of references to all its components. The
|
|
|
+ * _constness_ of the components is as requested.<br/>
|
|
|
+ * The signature of the function must be equivalent to one of the following
|
|
|
+ * forms:
|
|
|
+ *
|
|
|
+ * @code{.cpp}
|
|
|
+ * void(const entity_type, Component &...);
|
|
|
+ * void(Component &...);
|
|
|
+ * @endcode
|
|
|
+ *
|
|
|
+ * The pool of the suggested component is used to drive iterations. The
|
|
|
+ * returned entities will therefore respect the order of the pool associated
|
|
|
+ * with that type.<br/>
|
|
|
+ * It is no longer guaranteed that the performance is the best possible, but
|
|
|
+ * there will be greater control over the order of iteration.
|
|
|
+ *
|
|
|
+ * @tparam Func Type of the function object to invoke.
|
|
|
+ * @param func A valid function object.
|
|
|
+ */
|
|
|
+ template<typename Comp, typename Func>
|
|
|
+ void each(Func func) const {
|
|
|
+ each<Comp>(std::get<pool_type<Comp> *>(pools), std::move(func), std::make_index_sequence<sizeof...(Component)-1>{});
|
|
|
+ }
|
|
|
+
|
|
|
private:
|
|
|
const std::tuple<pool_type<Component> *...> pools;
|
|
|
};
|