From fc5dfd2873279d5003f8a02187a71b05a44892fa Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 16 Nov 2024 16:46:18 +0100 Subject: final touchups 2 for #26 --- src/crepe/api/BehaviorScript.h | 37 ++++++++++++++++++--------------- src/crepe/api/BehaviorScript.hpp | 2 +- src/crepe/api/LoopManager.cpp | 2 -- src/crepe/api/LoopManager.h | 26 ++++++++++++++++++------ src/crepe/api/Scene.h | 8 +++++--- src/crepe/api/Script.h | 44 ++++++++++++++++++++++------------------ src/crepe/api/Script.hpp | 3 +-- 7 files changed, 72 insertions(+), 50 deletions(-) (limited to 'src/crepe/api') diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h index f7d484a..9d85d4c 100644 --- a/src/crepe/api/BehaviorScript.h +++ b/src/crepe/api/BehaviorScript.h @@ -15,12 +15,21 @@ class Script; /** * \brief Script component * - * This class acts as a (component) wrapper around an instance of (a class - * derivatived from) \c Script. \c BehaviorScript is the only ECS component - * that stores member function implementations as data. + * This class acts as a (component) wrapper around an instance of (a class derivatived from) \c + * Script. \c BehaviorScript is the only ECS component that stores member function + * implementations as data. */ class BehaviorScript : public Component { protected: + /** + * \param id Parent \c GameObject id + * \param component_manager Reference to component manager (passed through to \c Script + * instance) + * + * \note Calls to this constructor (should) always pass through \c GameObject::add_component, + * which has an exception for this specific component type. This was done so the user does + * not have to pass references used within \c Script to each \c BehaviorScript instance. + */ BehaviorScript(game_object_id_t id, ComponentManager & component_manager); //! Only ComponentManager is allowed to instantiate BehaviorScript friend class ComponentManager; @@ -37,27 +46,23 @@ public: BehaviorScript & set_script(); protected: - //! ScriptSystem needs direct access to the script instance - friend class ScriptSystem; - //! Flag to indicate if script->init() has been called already - bool initialized = false; //! Script instance std::unique_ptr