aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Script.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-12 22:43:32 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-12 22:43:32 +0100
commit3e94ecb3dac5003a3d58210ed1a4d1f1cb2083d1 (patch)
tree67c3e1c122652ae09e58e7de49db668e252c4730 /src/crepe/api/Script.h
parentf2509e89c02894ebd3ad992324eb300103621d26 (diff)
add script unit tests + major refactoring
Diffstat (limited to 'src/crepe/api/Script.h')
-rw-r--r--src/crepe/api/Script.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h
index 49e625f..d543df8 100644
--- a/src/crepe/api/Script.h
+++ b/src/crepe/api/Script.h
@@ -11,6 +11,7 @@ namespace crepe {
class BehaviorScript;
class Script {
+ //! ScriptSystem calls \c update()
friend class crepe::ScriptSystem;
protected:
@@ -22,17 +23,25 @@ protected:
// added event.
protected:
+ //! Retrieve component from component manager (utility)
template <typename T>
T & get_component();
+ //! Retrieve components from component manager (utility)
template <typename T>
std::vector<std::reference_wrapper<T>> get_components();
-private:
- friend class crepe::BehaviorScript;
- BehaviorScript * parent = nullptr;
+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;
+ BehaviorScript * parent_ref = nullptr;
};
} // namespace crepe
#include "Script.hpp"
+