diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 16:51:03 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 16:51:03 +0100 |
commit | f0ecbea57a4d75905c4ee79608807187cd8f3e72 (patch) | |
tree | 04a399dc7d400aaa9443be19ce13fd97e5822f95 /src/crepe/manager | |
parent | d228d4b3856606ad4395723b2703759a0ebe9832 (diff) |
WIP
Diffstat (limited to 'src/crepe/manager')
-rw-r--r-- | src/crepe/manager/ComponentManager.h | 24 | ||||
-rw-r--r-- | src/crepe/manager/ReplayManager.h | 17 |
2 files changed, 22 insertions, 19 deletions
diff --git a/src/crepe/manager/ComponentManager.h b/src/crepe/manager/ComponentManager.h index 19a8e81..94fd94f 100644 --- a/src/crepe/manager/ComponentManager.h +++ b/src/crepe/manager/ComponentManager.h @@ -21,13 +21,6 @@ class GameObject; * This class manages all components. It provides methods to add, delete and get components. */ class ComponentManager : public Manager { - // TODO: This relation should be removed! I (loek) believe that the scene manager should - // create/destroy components because the GameObject's are stored in concrete Scene classes, - // which will in turn call GameObject's destructor, which will in turn call - // ComponentManager::delete_components_by_id or something. This is a pretty major change, so - // here is a comment and temporary fix instead :tada: - friend class SceneManager; - public: ComponentManager(Mediator & mediator); ~ComponentManager(); // dbg_trace @@ -49,12 +42,7 @@ public: const vec2 & position = {0, 0}, double rotation = 0, double scale = 1); -protected: - /** - * GameObject is used as an interface to add/remove components, and the game programmer is - * supposed to use it instead of interfacing with the component manager directly. - */ - friend class GameObject; +public: /** * \brief Add a component to the ComponentManager * @@ -154,6 +142,16 @@ public: template <typename T> RefVector<T> get_components_by_tag(const std::string & tag) const; + struct SnapshotComponent { + by_type<by_id_index<std::vector<std::unique_ptr<Component>>>> components; + Component component; + }; + struct Snapshot { + + }; + Snapshot save(); + void restore(const Snapshot &); + private: /** * \brief Get object IDs by predicate function diff --git a/src/crepe/manager/ReplayManager.h b/src/crepe/manager/ReplayManager.h index 242eae4..c50196c 100644 --- a/src/crepe/manager/ReplayManager.h +++ b/src/crepe/manager/ReplayManager.h @@ -1,6 +1,8 @@ #pragma once #include "Manager.h" +#include "ComponentManager.h" +#include <unordered_map> namespace crepe { @@ -18,15 +20,18 @@ protected: void record_frame(); private: - bool recording; - struct Recording { - recording_t id; - std::vector<Memento> frames; - }; + typedef std::vector<ComponentManager::Snapshot> Recording; + + bool recording = false; + recording_t current_recording = -1; + + + std::unordered_map<recording_t, std::unique_ptr<Recording>> memory; public: void record_start(); recording_t record_end(); - + void play(recording_t handle); + void release(recording_t handle); }; } // namespace crepe |