From 9a5967006c4b8cd202142517b402b4c75dc8b90b Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 20 Nov 2024 22:49:04 +0100 Subject: add Script::subscribe with specialization for CollisionEvent --- src/crepe/api/Script.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/crepe/api/Script.h') diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h index 4d98e4d..2d5e7a6 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -87,18 +87,22 @@ protected: template void logf(Args &&... args); - game_object_id_t get_game_object_id() const { return this->game_object_id; }; - /** * \brief Subscribe to an event * * \see EventManager::subscribe */ template - void subscribe(const EventHandler & callback, event_channel_t channel = EventManager::CHANNEL_ALL); + void subscribe(const EventHandler & callback, event_channel_t channel); + template + void subscribe(const EventHandler & callback); //! \} +private: + template + void subscribe_internal(const EventHandler & callback, event_channel_t channel); + protected: // NOTE: Script must have a constructor without arguments so the game programmer doesn't need // to manually add `using Script::Script` to their concrete script class. @@ -138,6 +142,11 @@ private: std::vector listeners; }; +template <> +void Script::subscribe(const EventHandler & callback); +template <> +void Script::subscribe(const EventHandler & callback, event_channel_t) = delete; + } // namespace crepe #include "Script.hpp" -- cgit v1.2.3