diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-12-01 23:05:27 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-12-01 23:05:27 +0100 |
commit | b6fdd1d644368226054094a282f5db24b31b5ba2 (patch) | |
tree | f995c792d6b8330a7880dada88d470bd357279e7 /src/crepe/api/Scene.h | |
parent | cbd4b97d348c46f4f43fe59683a5e3d1bdbc500f (diff) | |
parent | 647eb8e318f1ed1e3ec18505ea4df57025e6ffd5 (diff) |
merge with master
Diffstat (limited to 'src/crepe/api/Scene.h')
-rw-r--r-- | src/crepe/api/Scene.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index 869bf6f..f6fdb2a 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -2,6 +2,8 @@ #include <string> +#include "../util/OptionalRef.h" + namespace crepe { class SceneManager; @@ -15,11 +17,8 @@ class ComponentManager; */ class Scene { protected: - //TODO: Use Loek's custom reference class to set ComponentManger via SceneManager instead of via constructor - /** - * \param mgr Reference to the ComponentManager - */ - Scene(ComponentManager & mgr); + // NOTE: This must be the only constructor on Scene, see "Late references" below + Scene() = default; //! SceneManager instances Scene friend class SceneManager; @@ -36,8 +35,20 @@ public: virtual std::string get_name() const = 0; protected: + /** + * \name Late references + * + * These references are set by SceneManager immediately after calling the constructor of Scene. + * + * \note Scene must have a constructor without arguments so the game programmer doesn't need to + * manually add `using Scene::Scene` to their concrete scene class, if they want to add a + * constructor with arguments (e.g. for passing references to their own concrete Scene classes). + * + * \{ + */ //! Reference to the ComponentManager - ComponentManager & component_manager; + OptionalRef<ComponentManager> component_manager; + //! \} }; } // namespace crepe |