aboutsummaryrefslogtreecommitdiff
path: root/source/Game/Level.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-06-03 23:30:01 -0700
committerrtk0c <[email protected]>2022-06-03 23:30:01 -0700
commit791b3f354b378769bffe623b05f1305c91b77101 (patch)
tree5409b311e6232eb4a6d3f8259b780d76b8ee1c59 /source/Game/Level.hpp
parent60ccc62f4934e44ad5b905fdbcf458302b8d8a09 (diff)
Changeset: 64 [WIP] Rename directoriesmaster-switch-to-build2
Diffstat (limited to 'source/Game/Level.hpp')
-rw-r--r--source/Game/Level.hpp92
1 files changed, 0 insertions, 92 deletions
diff --git a/source/Game/Level.hpp b/source/Game/Level.hpp
deleted file mode 100644
index 9114a64..0000000
--- a/source/Game/Level.hpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#pragma once
-
-#include "EditorCore.hpp"
-#include "GameObject.hpp"
-
-#include <RcPtr.hpp>
-#include <Uid.hpp>
-
-#include <robin_hood.h>
-#include <filesystem>
-#include <vector>
-
-// Forward declarations
-class Level;
-class LevelManager;
-
-/// Represents a seralized GameObject tree.
-class Level : public RefCounted {
- friend class LevelManager;
-
-private:
- struct InstanciationEntry;
-
- LevelManager* mMan;
- Uid mUid;
- std::vector<InstanciationEntry> mEntries;
-
-public:
- Level();
- ~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 {
-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;
-
-public:
- void DiscoverFilesDesignatedLocation();
- void DiscoverFiles(const std::filesystem::path& dir);
-
- Level* FindLevel(const Uid& uid) const;
- /// Get or load the given level
- Level* LoadLevel(const Uid& uid);
- /// Send the given level to be loaded on another thread
- void PrepareLevel(const Uid& uid);
-
- /// 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 {
-private:
- RcPtr<Level> mLevel;
-
-public:
- LevelWrapperObject(GameWorld* world);
- ~LevelWrapperObject() override;
-
- Level* GetBoundLevel() const;
- void SetBoundLevel(Level* level);
-};