aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Script.hpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-12 07:59:47 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-12 07:59:47 +0100
commit0f68177a0384d41a7feff36cc0e1869b6d2ac9aa (patch)
tree4904b60820858efd0ee6ece0af1f2c1fc5846ec5 /src/crepe/api/Script.hpp
parent73f8d5c558ebc0820ede241e64a876ff1c5ccefb (diff)
parent194ee3f192c3343c3ccc28dfa97fed180503ffd4 (diff)
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/inputSystem
Diffstat (limited to 'src/crepe/api/Script.hpp')
-rw-r--r--src/crepe/api/Script.hpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp
index 45f1ff1..225a51c 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>
@@ -34,8 +31,7 @@ void Script::logf(Args &&... args) {
template <typename EventType>
void Script::subscribe_internal(const EventHandler<EventType> & callback,
event_channel_t channel) {
- Mediator & mediator = this->mediator;
- EventManager & mgr = mediator.event_manager;
+ EventManager & mgr = this->mediator->event_manager;
subscription_t listener = mgr.subscribe<EventType>(
[this, callback](const EventType & data) -> bool {
bool & active = this->active;
@@ -56,4 +52,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