Represents an object in the scene. A GameObject can contain multiple components and be part of a hierarchy.
More...
#include <GameObject.hpp>
Represents an object in the scene. A GameObject can contain multiple components and be part of a hierarchy.
◆ GameObject()
| Engine::GameObject::GameObject |
( |
const std::string & | name = "GameObject" | ) |
|
Creates a GameObject with an optional name.
- Parameters
-
◆ ~GameObject()
| Engine::GameObject::~GameObject |
( |
| ) |
|
Destructor responsible for cleaning up components.
◆ AddComponent()
template<typename T, typename... Args>
| T * Engine::GameObject::AddComponent |
( |
Args &&... | args | ) |
|
|
inline |
Adds a new component of type T to this GameObject.
- Template Parameters
-
- Returns
- Pointer to the created component
◆ GetAllComponents()
| const std::vector< Component * > & Engine::GameObject::GetAllComponents |
( |
| ) |
const |
Returns all components attached to the GameObject.
◆ GetChildren()
| const std::vector< GameObject * > & Engine::GameObject::GetChildren |
( |
| ) |
const |
Returns the children GameObjects.
◆ GetComponent()
template<typename T>
| T * Engine::GameObject::GetComponent |
( |
| ) |
|
|
inline |
Returns the first component of type T attached to this GameObject.
- Template Parameters
-
- Returns
- Pointer to the component if found
◆ GetName()
| const std::string & Engine::GameObject::GetName |
( |
| ) |
const |
◆ GetParent()
| GameObject * Engine::GameObject::GetParent |
( |
| ) |
const |
◆ GetTransform()
| Transform * Engine::GameObject::GetTransform |
( |
| ) |
|
◆ HasComponent()
template<typename T>
| bool Engine::GameObject::HasComponent |
( |
| ) |
const |
|
inline |
Checks whether the GameObject contains a component of type T.
- Template Parameters
-
- Returns
- True if the component exists
◆ RemoveComponent()
template<typename T>
| bool Engine::GameObject::RemoveComponent |
( |
| ) |
|
|
inline |
Removes a component of type T from this GameObject.
- Template Parameters
-
- Returns
- True if the component was removed
◆ SetName()
| void Engine::GameObject::SetName |
( |
const std::string & | newName | ) |
|
◆ SetParent()
| void Engine::GameObject::SetParent |
( |
GameObject * | newParent | ) |
|
Sets the parent GameObject. Updates the hierarchy structure.
- Parameters
-
◆ Update()
| void Engine::GameObject::Update |
( |
float | dt | ) |
|
Updates all components attached to this GameObject.
- Parameters
-
| dt | Delta time between frames |
The documentation for this class was generated from the following file: