diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-24 19:00:28 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-24 19:00:28 +0100 |
commit | fa283385d43030eca4833c1992da99e472bb5a0a (patch) | |
tree | 105e8427f75fa138ccf1f2b8990d0dab4d9cb0bb /src/crepe/api/Scene.h | |
parent | 0da788561f51215262a4c563853d2845ba1d3876 (diff) | |
parent | 1a56d7dcbf0c7375c2f0b1bb2dcd2b108a489fa8 (diff) |
Merge branch 'max/scenes' of github.com:lonkaars/crepe
Diffstat (limited to 'src/crepe/api/Scene.h')
-rw-r--r-- | src/crepe/api/Scene.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index 869bf6f..22aadab 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -1,5 +1,6 @@ #pragma once +#include "util/OptionalRef.h" #include <string> namespace crepe { @@ -15,11 +16,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 +34,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 |