diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-13 16:26:38 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-13 16:26:38 +0100 |
commit | b63f4700f7bda696afb14cc3111be0f8b0eed458 (patch) | |
tree | 08c4b00b249a4fa672d97a5bc79927adac0a0257 /src/crepe/api/Script.h | |
parent | 2933655dea64f11f200f42fe51e58dacc5f160eb (diff) | |
parent | 9e87a556a5f68c5f9bb04bef9a66880536ccd6e8 (diff) |
merge `loek/tests` into `loek/cleanup` (close #32)
Diffstat (limited to 'src/crepe/api/Script.h')
-rw-r--r-- | src/crepe/api/Script.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h index e6fbb5c..68a46d7 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -6,6 +6,7 @@ namespace crepe { class ScriptSystem; class BehaviorScript; +class ComponentManager; /** * \brief Script interface @@ -14,6 +15,7 @@ class BehaviorScript; * added to game objects using the \c BehaviorScript component. */ class Script { + //! ScriptSystem calls \c update() friend class crepe::ScriptSystem; protected: @@ -61,9 +63,19 @@ protected: template <typename T> std::vector<std::reference_wrapper<T>> get_components() const; +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. + Script() = default; + //! Only \c BehaviorScript instantiates Script + friend class BehaviorScript; + private: - friend class crepe::BehaviorScript; - BehaviorScript * parent = nullptr; + // These references are set by BehaviorScript immediately after calling the + // constructor of Script. + BehaviorScript * parent_ref = nullptr; + ComponentManager * component_manager_ref = nullptr; }; } // namespace crepe |