The Table Engine
|
Core class representing an entity in the game world. More...
#include <gameobject.h>
Public Member Functions | |
GameObject (std::string tag) | |
Constructs a new GameObject with the specified tag. More... | |
std::string | getId () |
Gets the unique identifier of the GameObject. More... | |
std::string | getTag () |
Gets the tag identifier of the GameObject. More... | |
template<typename T > | |
T * | getComponent () |
Gets a component of the specified type. More... | |
template<typename T > | |
void | addComponent (T *component) |
Adds a component to the GameObject. More... | |
template<typename T > | |
T * | getScript () |
Gets a script of the specified type. More... | |
template<typename T > | |
void | addScript (T *script) |
Adds a script to the GameObject. More... | |
SceneNode * | getSceneNode () |
Gets the SceneNode associated with this GameObject. More... | |
void | setSceneNode (SceneNode *sceneNode) |
Sets the SceneNode for this GameObject. More... | |
std::vector< GameObject * > | getChildren () |
Gets all child GameObjects. More... | |
void | input () |
Processes input for this GameObject and its components. More... | |
void | update () |
Updates this GameObject and its components. More... | |
void | render () |
Renders this GameObject and its components. More... | |
Private Member Functions | |
~GameObject () | |
Destructor that cleans up the GameObject and its SceneNode. More... | |
Private Attributes | |
std::string | m_id |
Unique identifier for the GameObject. More... | |
std::string | m_tag |
Category identifier (e.g., "Enemy", "Projectile") More... | |
std::vector< Component * > | m_components |
List of attached components. More... | |
std::vector< Script * > | m_scripts |
List of attached scripts. More... | |
SceneNode * | m_sceneNode |
Node in the scene graph hierarchy. More... | |
Friends | |
class | SceneNode |
Core class representing an entity in the game world.
GameObject serves as the base class for all game entities. It manages components and scripts, handles lifecycle events (input, update, render), and maintains relationships within the scene hierarchy.
Definition at line 20 of file gameobject.h.
|
private |
Destructor that cleans up the GameObject and its SceneNode.
Definition at line 14 of file gameobject.cpp.
GameObject::GameObject | ( | std::string | tag | ) |
Constructs a new GameObject with the specified tag.
tag | Category identifier for the object |
Definition at line 7 of file gameobject.cpp.
void GameObject::addComponent | ( | T * | component | ) |
Adds a component to the GameObject.
T | The type of component to add |
component | Pointer to the component instance |
Definition at line 133 of file gameobject.h.
void GameObject::addScript | ( | T * | script | ) |
Adds a script to the GameObject.
T | The type of script to add |
script | Pointer to the script instance |
Definition at line 150 of file gameobject.h.
std::vector< GameObject * > GameObject::getChildren | ( | ) |
Gets all child GameObjects.
Definition at line 44 of file gameobject.cpp.
T * GameObject::getComponent |
Gets a component of the specified type.
T | The type of component to retrieve |
Definition at line 123 of file gameobject.h.
std::string GameObject::getId | ( | ) |
Gets the unique identifier of the GameObject.
Definition at line 28 of file gameobject.cpp.
SceneNode * GameObject::getSceneNode | ( | ) |
Gets the SceneNode associated with this GameObject.
Definition at line 36 of file gameobject.cpp.
T * GameObject::getScript |
Gets a script of the specified type.
T | The type of script to retrieve |
Definition at line 140 of file gameobject.h.
std::string GameObject::getTag | ( | ) |
Gets the tag identifier of the GameObject.
Definition at line 32 of file gameobject.cpp.
void GameObject::input | ( | ) |
Processes input for this GameObject and its components.
Definition at line 57 of file gameobject.cpp.
void GameObject::render | ( | ) |
Renders this GameObject and its components.
Definition at line 75 of file gameobject.cpp.
void GameObject::setSceneNode | ( | SceneNode * | sceneNode | ) |
Sets the SceneNode for this GameObject.
sceneNode | Pointer to the SceneNode |
Definition at line 40 of file gameobject.cpp.
void GameObject::update | ( | ) |
Updates this GameObject and its components.
Definition at line 66 of file gameobject.cpp.
|
friend |
Definition at line 21 of file gameobject.h.
|
private |
List of attached components.
Definition at line 27 of file gameobject.h.
|
private |
Unique identifier for the GameObject.
Definition at line 24 of file gameobject.h.
|
private |
Node in the scene graph hierarchy.
Definition at line 30 of file gameobject.h.
|
private |
List of attached scripts.
Definition at line 28 of file gameobject.h.
|
private |
Category identifier (e.g., "Enemy", "Projectile")
Definition at line 25 of file gameobject.h.