aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ComponentManager.h
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-22 11:14:13 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-22 11:14:13 +0100
commit08fee6eff251337dd4dca2b514a9c06d57ede0af (patch)
treeead93ad5594e1254a66a6429a600f080880f4d90 /src/crepe/ComponentManager.h
parent07bca38a27f794ed6a2f74536f7a909530ce7df0 (diff)
Implemented persistent objects
Diffstat (limited to 'src/crepe/ComponentManager.h')
-rw-r--r--src/crepe/ComponentManager.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/crepe/ComponentManager.h b/src/crepe/ComponentManager.h
index 0956d1e..8fc7d6c 100644
--- a/src/crepe/ComponentManager.h
+++ b/src/crepe/ComponentManager.h
@@ -101,6 +101,15 @@ 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
+ */
+ void set_persistent(game_object_id_t id);
public:
/**
@@ -139,6 +148,9 @@ private:
std::unordered_map<std::type_index, std::vector<std::vector<std::unique_ptr<Component>>>>
components;
+ //! Persistent flag for each GameObject
+ std::vector<bool> persistent = {false};
+
//! ID of next GameObject allocated by \c ComponentManager::new_object
game_object_id_t next_id = 0;
};