122 template <
typename T>
125 if (
dynamic_cast<T*
>(component) !=
nullptr) {
126 return static_cast<T*
>(component);
132 template <
typename T>
134 auto base_component =
static_cast<Component*
>(component);
136 component->setOwner(
this);
139 template <
typename T>
142 if (
dynamic_cast<T*
>(script) !=
nullptr) {
143 return static_cast<T*
>(script);
149 template <
typename T>
151 auto base_script =
static_cast<Script*
>(script);
153 base_script->setOwner(
this);
Base class for all game components, providing basic component functionalities.
Core class representing an entity in the game world.
std::vector< Component * > m_components
List of attached components.
std::string m_id
Unique identifier for the GameObject.
std::vector< Script * > m_scripts
List of attached scripts.
void render()
Renders this GameObject and its components.
T * getScript()
Gets a script of the specified type.
SceneNode * getSceneNode()
Gets the SceneNode associated with this GameObject.
std::string getTag()
Gets the tag identifier of the GameObject.
T * getComponent()
Gets a component of the specified type.
void input()
Processes input for this GameObject and its components.
std::vector< GameObject * > getChildren()
Gets all child GameObjects.
GameObject(std::string tag)
Constructs a new GameObject with the specified tag.
~GameObject()
Destructor that cleans up the GameObject and its SceneNode.
std::string m_tag
Category identifier (e.g., "Enemy", "Projectile")
void setSceneNode(SceneNode *sceneNode)
Sets the SceneNode for this GameObject.
void addComponent(T *component)
Adds a component to the GameObject.
SceneNode * m_sceneNode
Node in the scene graph hierarchy.
std::string getId()
Gets the unique identifier of the GameObject.
void update()
Updates this GameObject and its components.
void addScript(T *script)
Adds a script to the GameObject.
Represents a node in the scene graph, encapsulating a game object and its hierarchy.
Base class for scripting custom behaviors in game objects.
Defines the Component base class for all components in the game engine.
Defines the SceneNode and SceneTree classes for managing game objects within scenes.
Defines the Script class for attaching behavior to game objects.