aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Script.h19
-rw-r--r--src/crepe/api/Script.hpp27
2 files changed, 42 insertions, 4 deletions
diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h
index d99ab0e..49bdcf5 100644
--- a/src/crepe/api/Script.h
+++ b/src/crepe/api/Script.h
@@ -86,6 +86,25 @@ protected:
RefVector<T> get_components() const;
/**
+ * \copydoc ComponentManager::get_components_by_id
+ * \see ComponentManager::get_components_by_id
+ */
+ template <typename T>
+ RefVector<T> get_components_by_id(game_object_id_t id) const;
+ /**
+ * \copydoc ComponentManager::get_components_by_name
+ * \see ComponentManager::get_components_by_name
+ */
+ template <typename T>
+ RefVector<T> get_components_by_name(const std::string & name) const;
+ /**
+ * \copydoc ComponentManager::get_components_by_tag
+ * \see ComponentManager::get_components_by_tag
+ */
+ template <typename T>
+ RefVector<T> get_components_by_tag(const std::string & tag) const;
+
+ /**
* \brief Log a message using Log::logf
*
* \tparam Args Log::logf parameters
diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp
index 45f1ff1..16e0dc5 100644
--- a/src/crepe/api/Script.hpp
+++ b/src/crepe/api/Script.hpp
@@ -20,10 +20,7 @@ T & Script::get_component() const {
template <typename T>
RefVector<T> Script::get_components() const {
- Mediator & mediator = this->mediator;
- ComponentManager & mgr = mediator.component_manager;
-
- return mgr.get_components_by_id<T>(this->game_object_id);
+ return this->get_components_by_id<T>(this->game_object_id);
}
template <typename... Args>
@@ -56,4 +53,26 @@ void Script::subscribe(const EventHandler<EventType> & callback) {
this->subscribe_internal(callback, EventManager::CHANNEL_ALL);
}
+template <typename T>
+RefVector<T> Script::get_components_by_id(game_object_id_t id) const {
+ Mediator & mediator = this->mediator;
+ ComponentManager & mgr = mediator.component_manager;
+
+ return mgr.get_components_by_id<T>(id);
+}
+template <typename T>
+RefVector<T> Script::get_components_by_name(const std::string & name) const {
+ Mediator & mediator = this->mediator;
+ ComponentManager & mgr = mediator.component_manager;
+
+ return mgr.get_components_by_name<T>(name);
+}
+template <typename T>
+RefVector<T> Script::get_components_by_tag(const std::string & tag) const {
+ Mediator & mediator = this->mediator;
+ ComponentManager & mgr = mediator.component_manager;
+
+ return mgr.get_components_by_tag<T>(tag);
+}
+
} // namespace crepe