diff options
Diffstat (limited to 'src/crepe/Component.h')
-rw-r--r-- | src/crepe/Component.h | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/crepe/Component.h b/src/crepe/Component.h index bc44865..eff5a58 100644 --- a/src/crepe/Component.h +++ b/src/crepe/Component.h @@ -1,22 +1,55 @@ #pragma once -#include <cstdint> +#include "types.h" 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 { +public: + //! Whether the component is active + bool active = true; + /** + * \brief The id of the GameObject this component belongs to + * + * \note Only systems are supposed to use this member, but since friend + * relations aren't inherited this needs to be public. + */ + const game_object_id_t game_object_id; + protected: - 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); + //! Only ComponentManager can create components + friend class ComponentManager; + + Component(const Component &) = delete; + Component(Component &&) = delete; + virtual Component & operator=(const Component &) = delete; + virtual Component & operator=(Component &&) = delete; public: virtual ~Component() = default; public: - uint32_t game_object_id; - bool active; + /** + * \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; } }; } // namespace crepe |