diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-12 19:46:15 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-12 19:46:15 +0100 |
commit | 297d621987c224db26eadfb9bde9235741387496 (patch) | |
tree | 9b21b5900ce8982f10c52e7312dbf3c471afdb73 /src/crepe/api/Script.hpp | |
parent | 80a80f385874ea109b54454b58e84037aa6092cc (diff) |
more cleanup + script utilities
Diffstat (limited to 'src/crepe/api/Script.hpp')
-rw-r--r-- | src/crepe/api/Script.hpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp index 547fb8b..2553fd1 100644 --- a/src/crepe/api/Script.hpp +++ b/src/crepe/api/Script.hpp @@ -24,9 +24,14 @@ RefVector<T> Script::get_components() const { return this->get_components_by_id<T>(this->game_object_id); } -template <typename... Args> -void Script::logf(Args &&... args) { - Log::logf(std::forward<Args>(args)...); +template <class... Args> +void Script::logf(const Log::Level & level, std::format_string<Args...> fmt, Args &&... args) { + Log::logf(level, fmt, std::forward<Args>(args)...); +} + +template <class... Args> +void Script::logf(std::format_string<Args...> fmt, Args &&... args) { + Log::logf(fmt, std::forward<Args>(args)...); } template <typename EventType> @@ -55,6 +60,18 @@ void Script::subscribe(const EventHandler<EventType> & callback) { this->subscribe_internal(callback, EventManager::CHANNEL_ALL); } +template <typename EventType> +void Script::trigger_event(const EventType & event, event_channel_t channel) { + EventManager & mgr = this->mediator->event_manager; + mgr.trigger_event(event, channel); +} + +template <typename EventType> +void Script::queue_event(const EventType & event, event_channel_t channel) { + EventManager & mgr = this->mediator->event_manager; + mgr.queue_event(event, channel); +} + template <typename T> RefVector<T> Script::get_components_by_id(game_object_id_t id) const { Mediator & mediator = this->mediator; |