diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-18 14:08:36 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-18 14:08:36 +0100 |
commit | 20fc8401083e23e414feae2a9a4d217b228b8f15 (patch) | |
tree | 08c9e9c4ddcde5438eb54f6b051895c0896f935b /src/crepe/api/GameObject.h | |
parent | 60669b60e63532bc264ecd6d106bd15f0688a5b6 (diff) | |
parent | 121b64b1cb6cfead5814070c8b0185d3d7308095 (diff) |
Merge remote-tracking branch 'origin/master' into niels/rendering_color
Diffstat (limited to 'src/crepe/api/GameObject.h')
-rw-r--r-- | src/crepe/api/GameObject.h | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/crepe/api/GameObject.h b/src/crepe/api/GameObject.h index d703730..34ef8bb 100644 --- a/src/crepe/api/GameObject.h +++ b/src/crepe/api/GameObject.h @@ -2,25 +2,26 @@ #include <string> +#include "Vector2.h" #include "types.h" namespace crepe { -class Vector2; +class ComponentManager; /** * \brief Represents a GameObject * - * This class represents a GameObject. The GameObject class is only used - * as an interface for the game programmer. The actual implementation is - * done in the ComponentManager. + * This class represents a GameObject. The GameObject class is only used as an interface for + * the game programmer. The actual implementation is done in the ComponentManager. */ class GameObject { -public: +private: /** - * This constructor creates a new GameObject. It creates a new - * Transform and Metadata component and adds them to the ComponentManager. + * This constructor creates a new GameObject. It creates a new Transform and Metadata + * component and adds them to the ComponentManager. * + * \param component_manager Reference to component_manager * \param id The id of the GameObject * \param name The name of the GameObject * \param tag The tag of the GameObject @@ -28,15 +29,19 @@ public: * \param rotation The rotation of the GameObject * \param scale The scale of the GameObject */ - GameObject(game_object_id_t id, const std::string & name, - const std::string & tag, const Vector2 & position, + GameObject(ComponentManager & component_manager, game_object_id_t id, + const std::string & name, const std::string & tag, const Vector2 & position, double rotation, double scale); + //! ComponentManager instances GameObject + friend class ComponentManager; + +public: /** * \brief Set the parent of this GameObject * - * This method sets the parent of this GameObject. It sets the parent - * in the Metadata component of this GameObject and adds this GameObject - * to the children list of the parent GameObject. + * This method sets the parent of this GameObject. It sets the parent in the Metadata + * component of this GameObject and adds this GameObject to the children list of the parent + * GameObject. * * \param parent The parent GameObject */ @@ -44,8 +49,8 @@ public: /** * \brief Add a component to the GameObject * - * This method adds a component to the GameObject. It forwards the - * arguments to the ComponentManager. + * This method adds a component to the GameObject. It forwards the arguments to the + * ComponentManager. * * \tparam T The type of the component * \tparam Args The types of the arguments @@ -58,6 +63,9 @@ public: public: //! The id of the GameObject const game_object_id_t id; + +protected: + ComponentManager & component_manager; }; } // namespace crepe |