aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ComponentManager.h
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-28 09:00:49 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-28 09:00:49 +0100
commit8635d1ace31232c295c6cb85ea215887c6fb1319 (patch)
tree898f572568ed6f6d9afd8a3c37abde3441e070a5 /src/crepe/ComponentManager.h
parent9d60b7b70abd832dc229c59114e465d457fcd0a3 (diff)
parentd1eed940b8119e95a14f1d08bf26184c7f0a0d8f (diff)
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/inputSystem
Diffstat (limited to 'src/crepe/ComponentManager.h')
-rw-r--r--src/crepe/ComponentManager.h13
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;
};