|
|
@@ -440,19 +440,14 @@ public:
|
|
|
* Attempting to use an entity that doesn't belong to the view results in
|
|
|
* undefined behavior.
|
|
|
*
|
|
|
- * @tparam Type Types of components to get.
|
|
|
+ * @tparam Type Type of the component to get.
|
|
|
+ * @tparam Other Other types of components to get.
|
|
|
* @param entt A valid identifier.
|
|
|
* @return The components assigned to the entity.
|
|
|
*/
|
|
|
- template<typename... Type>
|
|
|
+ template<typename Type, typename... Other>
|
|
|
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
|
|
- if constexpr(sizeof...(Type) == 0) {
|
|
|
- return std::apply([entt](auto *...curr) { return std::tuple_cat(curr->get_as_tuple(entt)...); }, pools);
|
|
|
- } else if constexpr(sizeof...(Type) == 1) {
|
|
|
- return (storage<index_of<Type>>().get(entt), ...);
|
|
|
- } else {
|
|
|
- return std::tuple_cat(storage<index_of<Type>>().get_as_tuple(entt)...);
|
|
|
- }
|
|
|
+ return get<index_of<Type>, index_of<Other>...>(entt);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -462,17 +457,18 @@ public:
|
|
|
* Attempting to use an entity that doesn't belong to the view results in
|
|
|
* undefined behavior.
|
|
|
*
|
|
|
- * @tparam First Index of a component to get.
|
|
|
- * @tparam Other Indexes of other components to get.
|
|
|
+ * @tparam Index Indexes of the components to get.
|
|
|
* @param entt A valid identifier.
|
|
|
* @return The components assigned to the entity.
|
|
|
*/
|
|
|
- template<std::size_t First, std::size_t... Other>
|
|
|
+ template<std::size_t... Index>
|
|
|
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
|
|
- if constexpr(sizeof...(Other) == 0) {
|
|
|
- return storage<First>().get(entt);
|
|
|
+ if constexpr(sizeof...(Index) == 0) {
|
|
|
+ return std::apply([entt](auto *...curr) { return std::tuple_cat(curr->get_as_tuple(entt)...); }, pools);
|
|
|
+ } else if constexpr(sizeof...(Index) == 1) {
|
|
|
+ return (storage<Index>().get(entt), ...);
|
|
|
} else {
|
|
|
- return std::tuple_cat(storage<First>().get_as_tuple(entt), storage<Other>().get_as_tuple(entt)...);
|
|
|
+ return std::tuple_cat(storage<Index>().get_as_tuple(entt)...);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -761,24 +757,34 @@ public:
|
|
|
* Attempting to use an entity that doesn't belong to the view results in
|
|
|
* undefined behavior.
|
|
|
*
|
|
|
- * @tparam Type Type or index of the component to get.
|
|
|
+ * @tparam Type Type of the component to get.
|
|
|
* @param entt A valid identifier.
|
|
|
* @return The component assigned to the entity.
|
|
|
*/
|
|
|
- template<typename... Type>
|
|
|
+ template<typename Type>
|
|
|
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
|
|
- if constexpr(sizeof...(Type) == 0) {
|
|
|
- return storage().get_as_tuple(entt);
|
|
|
- } else {
|
|
|
- static_assert((std::is_same_v<std::remove_const_t<Type>, typename Get::value_type> && ...), "Invalid component type");
|
|
|
- return storage().get(entt);
|
|
|
- }
|
|
|
+ static_assert(std::is_same_v<std::remove_const_t<Type>, typename Get::value_type>, "Invalid component type");
|
|
|
+ return get<0>(entt);
|
|
|
}
|
|
|
|
|
|
- /*! @copydoc get */
|
|
|
- template<std::size_t Index>
|
|
|
+ /**
|
|
|
+ * @brief Returns the component assigned to the given entity.
|
|
|
+ *
|
|
|
+ * @warning
|
|
|
+ * Attempting to use an entity that doesn't belong to the view results in
|
|
|
+ * undefined behavior.
|
|
|
+ *
|
|
|
+ * @tparam Index Index of the component to get.
|
|
|
+ * @param entt A valid identifier.
|
|
|
+ * @return The component assigned to the entity.
|
|
|
+ */
|
|
|
+ template<std::size_t... Index>
|
|
|
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
|
|
- return storage().get(entt);
|
|
|
+ if constexpr(sizeof...(Index) == 0) {
|
|
|
+ return storage().get_as_tuple(entt);
|
|
|
+ } else {
|
|
|
+ return storage<Index...>().get(entt);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|