diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-07 20:08:09 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-07 20:08:09 +0100 |
commit | 1c4156ee127b14760ed3b1a0cd16ad12180c7ac6 (patch) | |
tree | 211505d5328f24c9f9beabf8f874d9e13ef92130 /src/crepe/api/GameObject.h | |
parent | 9df087ede0b539ecbd2778236c7d1143362b384d (diff) | |
parent | 3d2428af8e8d9d49b4ade52d4806a7dae4cf1ab8 (diff) |
merge `master` into `loek/savemgr`
Diffstat (limited to 'src/crepe/api/GameObject.h')
-rw-r--r-- | src/crepe/api/GameObject.h | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/src/crepe/api/GameObject.h b/src/crepe/api/GameObject.h index b5d6399..d703730 100644 --- a/src/crepe/api/GameObject.h +++ b/src/crepe/api/GameObject.h @@ -1,22 +1,63 @@ #pragma once -#include <cstdint> #include <string> +#include "types.h" + namespace crepe { +class Vector2; + +/** + * \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. + */ class GameObject { public: - GameObject(uint32_t id, std::string name, std::string tag, int layer); - + /** + * This constructor creates a new GameObject. It creates a new + * Transform and Metadata component and adds them to the ComponentManager. + * + * \param id The id of the GameObject + * \param name The name of the GameObject + * \param tag The tag of the GameObject + * \param position The position of the GameObject + * \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, + double rotation, double scale); + /** + * \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. + * + * \param parent The parent GameObject + */ + void set_parent(const GameObject & parent); + /** + * \brief Add a component to the GameObject + * + * 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 + * \param args The arguments to create the component + * \return The created component + */ template <typename T, typename... Args> T & add_component(Args &&... args); - uint32_t id; - std::string name; - std::string tag; - bool active; - int layer; +public: + //! The id of the GameObject + const game_object_id_t id; }; } // namespace crepe |