aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/Component.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-07 20:08:09 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-07 20:08:09 +0100
commit1c4156ee127b14760ed3b1a0cd16ad12180c7ac6 (patch)
tree211505d5328f24c9f9beabf8f874d9e13ef92130 /src/crepe/Component.h
parent9df087ede0b539ecbd2778236c7d1143362b384d (diff)
parent3d2428af8e8d9d49b4ade52d4806a7dae4cf1ab8 (diff)
merge `master` into `loek/savemgr`
Diffstat (limited to 'src/crepe/Component.h')
-rw-r--r--src/crepe/Component.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/crepe/Component.h b/src/crepe/Component.h
index bc44865..0fe60b2 100644
--- a/src/crepe/Component.h
+++ b/src/crepe/Component.h
@@ -1,22 +1,46 @@
#pragma once
+#include "types.h"
+
#include <cstdint>
namespace crepe {
class ComponentManager;
+/**
+ * \brief Base class for all components
+ *
+ * This class is the base class for all components. It provides a common
+ * interface for all components.
+ */
class Component {
protected:
+ //! Only the ComponentManager can create components
friend class crepe::ComponentManager;
- Component(uint32_t id);
+ /**
+ * \param id The id of the GameObject this component belongs to
+ */
+ Component(game_object_id_t id);
public:
virtual ~Component() = default;
+ /**
+ * \brief Get the maximum number of instances for this component
+ *
+ * This method returns -1 by default, which means that there is no limit
+ * for the number of instances. Concrete components can override this method
+ * to set a limit.
+ *
+ * \return The maximum number of instances for this component
+ */
+ virtual int get_instances_max() const { return -1; }
public:
- uint32_t game_object_id;
- bool active;
+ //! The id of the GameObject this component belongs to
+ const game_object_id_t game_object_id;
+ //! Whether the component is active
+ bool active = true;
};
} // namespace crepe