From 3e94ecb3dac5003a3d58210ed1a4d1f1cb2083d1 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 12 Nov 2024 22:43:32 +0100 Subject: add script unit tests + major refactoring --- src/crepe/Component.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/crepe/Component.h') diff --git a/src/crepe/Component.h b/src/crepe/Component.h index 0fe60b2..c6d72df 100644 --- a/src/crepe/Component.h +++ b/src/crepe/Component.h @@ -2,8 +2,6 @@ #include "types.h" -#include - namespace crepe { class ComponentManager; @@ -15,13 +13,21 @@ class ComponentManager; * interface for all components. */ class Component { +public: + struct Data { + //! The ID of the GameObject this component belongs to + const game_object_id_t id; + //! The manager of this component + ComponentManager & component_manager; + }; + protected: - //! Only the ComponentManager can create components - friend class crepe::ComponentManager; /** - * \param id The id of the GameObject this component belongs to + * \param base Data */ - Component(game_object_id_t id); + Component(const Data & base); + //! Only the ComponentManager can create components + friend class crepe::ComponentManager; public: virtual ~Component() = default; @@ -37,8 +43,7 @@ public: virtual int get_instances_max() const { return -1; } public: - //! The id of the GameObject this component belongs to - const game_object_id_t game_object_id; + Data data; //! Whether the component is active bool active = true; }; -- cgit v1.2.3