aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/ComponentManager.hpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-07 14:18:54 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-07 14:18:54 +0100
commit90c6bf03e59fdec64f850310bcbff45ae86f69e3 (patch)
treef80305e8b712e17c41a1860ec82a139842c67ba0 /src/crepe/manager/ComponentManager.hpp
parentf4824f5e7e6cee12bec602f3240770945a73d043 (diff)
more script utilities
Diffstat (limited to 'src/crepe/manager/ComponentManager.hpp')
-rw-r--r--src/crepe/manager/ComponentManager.hpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/crepe/manager/ComponentManager.hpp b/src/crepe/manager/ComponentManager.hpp
index 25c2747..52df368 100644
--- a/src/crepe/manager/ComponentManager.hpp
+++ b/src/crepe/manager/ComponentManager.hpp
@@ -167,4 +167,27 @@ std::set<game_object_id_t> ComponentManager::get_objects_by_predicate(const std:
return objects;
}
+template <typename T>
+RefVector<T> ComponentManager::get_components_by_ids(const std::set<game_object_id_t> & ids) const {
+ using namespace std;
+
+ RefVector<T> out = {};
+ for (game_object_id_t id : ids) {
+ RefVector<T> components = get_components_by_id<T>(id);
+ out.insert(out.end(), components.begin(), components.end());
+ }
+
+ return out;
+}
+
+template <typename T>
+RefVector<T> ComponentManager::get_components_by_name(const std::string & name) const {
+ return this->get_components_by_ids<T>(this->get_objects_by_name(name));
+}
+
+template <typename T>
+RefVector<T> ComponentManager::get_components_by_tag(const std::string & tag) const {
+ return this->get_components_by_ids<T>(this->get_objects_by_tag(tag));
+}
+
} // namespace crepe