diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-01 15:05:28 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-01 15:05:28 +0100 |
commit | 5981ab2262a98b80a1339f86a6b71093576a9b35 (patch) | |
tree | 325ff71fc2482a6960656f0ced80db874945a938 /src/crepe/ComponentManager.h | |
parent | 4d6d5a6ff5366877cbc7b8e24110b56a332a7353 (diff) | |
parent | 647eb8e318f1ed1e3ec18505ea4df57025e6ffd5 (diff) |
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/gameloop
Diffstat (limited to 'src/crepe/ComponentManager.h')
-rw-r--r-- | src/crepe/ComponentManager.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/crepe/ComponentManager.h b/src/crepe/ComponentManager.h index 1cb0b5f..480124f 100644 --- a/src/crepe/ComponentManager.h +++ b/src/crepe/ComponentManager.h @@ -99,6 +99,16 @@ protected: * This method deletes all components. */ void delete_all_components(); + /** + * \brief Set a GameObject as persistent + * + * This method sets a GameObject as persistent. If a GameObject is persistent, its + * components will not be deleted. + * + * \param id The id of the GameObject to set as persistent + * \param persistent The persistent flag + */ + void set_persistent(game_object_id_t id, bool persistent); public: /** @@ -137,6 +147,9 @@ private: std::unordered_map<std::type_index, std::vector<std::vector<std::unique_ptr<Component>>>> components; + //! Persistent flag for each GameObject + std::unordered_map<game_object_id_t, bool> persistent; + //! ID of next GameObject allocated by \c ComponentManager::new_object game_object_id_t next_id = 0; }; |