diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-12 22:45:12 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-12 22:45:12 +0100 |
commit | 23196be83778973d9688cc5d465e4e4a16476568 (patch) | |
tree | 91dee3b2c2e05d3b529cf537d12a7faf7ec21dc1 /src/crepe/manager/ReplayManager.h | |
parent | 297d621987c224db26eadfb9bde9235741387496 (diff) |
add documentation
Diffstat (limited to 'src/crepe/manager/ReplayManager.h')
-rw-r--r-- | src/crepe/manager/ReplayManager.h | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/src/crepe/manager/ReplayManager.h b/src/crepe/manager/ReplayManager.h index 7be18f3..d3af879 100644 --- a/src/crepe/manager/ReplayManager.h +++ b/src/crepe/manager/ReplayManager.h @@ -8,13 +8,14 @@ namespace crepe { -class ReplaySystem; - typedef size_t recording_t; /** * \brief Replay manager * + * The replay manager is responsible for creating, storing and restoring ComponentManager + * snapshots. Sequential snapshots can be recorded and replayed in combination with + * ReplaySystem. */ class ReplayManager : public Manager { // TODO: Delete recordings at end of scene @@ -22,31 +23,70 @@ public: ReplayManager(Mediator & mediator); public: + //! Start a new recording void record_start(); + /** + * \brief End the latest recording started by \c record_start() + * \returns Handle to recording + */ recording_t record_end(); + /** + * \brief Play a recording + * \param handle Handle to recording (as returned by \c record_end()) + */ void play(recording_t handle); + /** + * \brief Delete a recording from memory + * \param handle Handle to recording (as returned by \c record_end()) + */ void release(recording_t handle); public: + //! Internal state enum State { - IDLE, - RECORDING, - PLAYING, + IDLE, //!< Not doing anything + RECORDING, //!< Currently recording + PLAYING, //!< Currently playing back a recording }; + //! Get current internal state State get_state() const; public: + /** + * \brief Record a single frame to the current recording + * + * This function is called by ReplaySystem after the game programmer has called \c + * record_start() + */ void frame_record(); + /** + * \brief Play the next frame of the current recording + * + * \returns `true` if the recording is finished playing + * \returns `false` if there are more frames + * + * This function also automatically resets the internal state from PLAYING to IDLE at the end + * of a recording. + */ bool frame_step(); private: + /** + * \brief Recording data + */ struct Recording { + //! Current frame being shown size_t frame = 0; + //! All frames in recording std::vector<ComponentManager::Snapshot> frames; }; + //! Internal state State state = IDLE; - OptionalRef<Recording> recording; + //! Current recording handle recording_t id = -1; + //! Current recording data + OptionalRef<Recording> recording; + //! Recording storage std::unordered_map<recording_t, std::unique_ptr<Recording>> memory; }; |