diff options
Diffstat (limited to 'source/30-game/Level.hpp')
-rw-r--r-- | source/30-game/Level.hpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/source/30-game/Level.hpp b/source/30-game/Level.hpp index c1170a3..9114a64 100644 --- a/source/30-game/Level.hpp +++ b/source/30-game/Level.hpp @@ -1,8 +1,10 @@ #pragma once +#include "EditorCore.hpp" #include "GameObject.hpp" -#include "RcPtr.hpp" -#include "Uid.hpp" + +#include <RcPtr.hpp> +#include <Uid.hpp> #include <robin_hood.h> #include <filesystem> @@ -20,6 +22,7 @@ private: struct InstanciationEntry; LevelManager* mMan; + Uid mUid; std::vector<InstanciationEntry> mEntries; public: @@ -27,6 +30,12 @@ public: ~Level(); void Instanciate(GameObject* relRoot) const; + + LevelManager* GetLinkedLevelManager() const { return mMan; } + const Uid& GetUid() const { return mUid; } + + // Editor stuff + void ShowInstanciationEntries(IEditor& editor); }; class LevelManager { @@ -34,12 +43,16 @@ public: static inline LevelManager* instance = nullptr; public: // NOTE: public for the editor; actual game components should not modify the map using this + // TODO maybe cut this struct to only the first RcPtr<Level> field in release mode? struct LoadableObject { RcPtr<Level> level; // TODO make weak pointer std::filesystem::path filePath; // NOTE: these fields are only loaded in dev mode std::string name; std::string description; + + // Editor book keeping fields + bool edited = false; }; // We want pointer stability here for the editor (inspector object) robin_hood::unordered_node_map<Uid, LoadableObject> mObjByUid; @@ -54,8 +67,16 @@ public: /// Send the given level to be loaded on another thread void PrepareLevel(const Uid& uid); - // These should only be used by the editor + /// Create and add a new level object with the given uid. + /// Should only be used by the editor. LoadableObject& AddLevel(const Uid& uid); + /// Should only be used by the editor. + void SaveLevel(const Uid& uid) const; + /// Should only be used by the editor. + void SaveLevel(const Uid& uid, const std::filesystem::path& path) const; + +private: + void SaveLevelImpl(const LoadableObject& obj, const std::filesystem::path& path) const; }; class LevelWrapperObject : public GameObject { |