diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-12 22:45:12 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-12 22:45:12 +0100 |
commit | 23196be83778973d9688cc5d465e4e4a16476568 (patch) | |
tree | 91dee3b2c2e05d3b529cf537d12a7faf7ec21dc1 /src/crepe/api/Script.hpp | |
parent | 297d621987c224db26eadfb9bde9235741387496 (diff) |
add documentation
Diffstat (limited to 'src/crepe/api/Script.hpp')
-rw-r--r-- | src/crepe/api/Script.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp index 2553fd1..b42a6df 100644 --- a/src/crepe/api/Script.hpp +++ b/src/crepe/api/Script.hpp @@ -40,10 +40,17 @@ void Script::subscribe_internal(const EventHandler<EventType> & callback, EventManager & mgr = this->mediator->event_manager; subscription_t listener = mgr.subscribe<EventType>( [this, callback](const EventType & data) -> bool { + // check if (parent) BehaviorScript component is active bool & active = this->active; if (!active) return false; - ReplayManager & replay = this->mediator->replay_manager; - if (replay.get_state() == ReplayManager::PLAYING) return false; + + // check if replay manager is playing (if initialized) + try { + ReplayManager & replay = this->mediator->replay_manager; + if (replay.get_state() == ReplayManager::PLAYING) return false; + } catch (const std::runtime_error &) {} + + // call user-provided callback return callback(data); }, channel); |