From 3e94ecb3dac5003a3d58210ed1a4d1f1cb2083d1 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 12 Nov 2024 22:43:32 +0100 Subject: add script unit tests + major refactoring --- src/crepe/api/BehaviorScript.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/crepe/api/BehaviorScript.h') diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h index 6b1fec7..8d21a72 100644 --- a/src/crepe/api/BehaviorScript.h +++ b/src/crepe/api/BehaviorScript.h @@ -12,19 +12,35 @@ class Script; class BehaviorScript : public Component { protected: - friend class crepe::ComponentManager; using Component::Component; + //! Only ComponentManager is allowed to instantiate BehaviorScript + friend class ComponentManager; public: virtual ~BehaviorScript() = default; public: + /** + * \brief Set the concrete script of this component + * + * \tparam T Concrete script type (derived from \c crepe::Script) + * + * \returns Reference to BehaviorScript component (`*this`) + */ template BehaviorScript & set_script(); protected: - friend class crepe::ScriptSystem; + //! ScriptSystem needs direct access to the script instance + friend class ScriptSystem; + //! Flag to indicate if script->init() has been called already + bool initialized = false; std::unique_ptr