|
StevEngine
StevEngine is a customizable C++ game engine.
|
Core game object class. More...
#include <main/GameObject.hpp>
Public Member Functions | |
| Utilities::ID | Id () const |
| Get object's unique ID. | |
| Utilities::Vector3 | GetPosition () const |
| Get local position. | |
| Utilities::Quaternion | GetRotation () const |
| Get local rotation. | |
| Utilities::Vector3 | GetScale () const |
| Get local scale. | |
| void | SetPosition (Utilities::Vector3 position, bool announce=true) |
| Set local position. | |
| void | SetRotation (Utilities::Quaternion rotation, bool announce=true) |
| Set local rotation. | |
| void | SetScale (Utilities::Vector3 scale, bool announce=true) |
| Set local scale. | |
| void | SetTransform (Utilities::Vector3 position, Utilities::Quaternion rotation, Utilities::Vector3 scale, bool announce=true) |
| Set full local transform. | |
| Utilities::Vector3 | GetWorldPosition () const |
| Get world position. | |
| Utilities::Quaternion | GetWorldRotation () const |
| Get world rotation. | |
| Utilities::Vector3 | GetWorldScale () const |
| Get world scale. | |
| ~GameObject () | |
| Utilities::Stream | Export (Utilities::StreamType type) const |
| Serialize object to a stream. | |
| void | Import (Utilities::Stream &stream) |
| Load object from serialized data. | |
| GameObject (Utilities::ID id, std::string name, std::string scene) | |
| Should never be called directly, use Scene::CreateObject. | |
| template<typename EventType> | |
| Utilities::ID | Subscribe (EventFunction< EventType > handler, bool allowFromChild=true) |
| Subscribe to object events. | |
| template<typename EventType> | |
| void | Publish (const EventType &event) |
| Publish an event. | |
| void | Unsubscribe (const std::string eventId, const Utilities::ID handlerId) |
| Unsubscribe from events. | |
| int | AddChild (const Utilities::ID &gameObjectID) |
| Add child object. | |
| void | RemoveChild (int index) |
| Remove child at index. | |
| GameObject & | GetChild (int index) const |
| Get child object. | |
| uint32_t | GetChildCount () const |
| Get number of children. | |
| bool | HasParent () const |
| Check if object has a parent. | |
| GameObject & | GetParent () const |
| Get parent object. | |
| Scene & | GetScene () const |
| Get containing Scene. | |
| template<class T> requires std::is_base_of_v<Component, T> | |
| T * | GetComponent (bool log=true) |
| Get component of specified type. | |
| template<class T> | |
| std::enable_if< std::is_base_of< Component, T >::value, std::vector< T * > >::type | GetAllComponents () |
| Get all components of specified type. | |
| std::vector< Component * > | GetAllComponents () const |
| Get all components of any type. | |
| template<class T> requires std::is_base_of_v<Component,T> | |
| std::vector< T * > | GetAllComponentsInChildren () |
| Get components of type from this object and all children. | |
| template<class T> requires std::is_base_of_v<Component,T> | |
| T * | AddComponent (T *component) |
| Add component to object. | |
| template<class T> requires std::is_base_of_v<Component,T> | |
| void | RemoveAllComponents () |
| Remove all components of specified type. | |
| template<class T> requires std::is_base_of_v<Component,T> | |
| void | RemoveComponent (T *component) |
| Remove specific component instance. | |
Public Attributes | |
| std::string | name |
| Object name/label. | |
Friends | |
| class | SceneManager |
| class | Scene |
Core game object class.
Base class for all entities in the game world. Handles transform hierarchy, component management, and event propagation.
| StevEngine::GameObject::~GameObject | ( | ) |
Log::Normal(std::format("Destroying object with id {}", id), true);
| StevEngine::GameObject::GameObject | ( | Utilities::ID | id, |
| std::string | name, | ||
| std::string | scene ) |
Should never be called directly, use Scene::CreateObject.
Constructs a GameObject with the specified properties.
| int StevEngine::GameObject::AddChild | ( | const Utilities::ID & | gameObjectID | ) |
Add child object.
| gameObjectID | ID of child object |
|
inline |
| Utilities::Stream StevEngine::GameObject::Export | ( | Utilities::StreamType | type | ) | const |
Serialize object to a stream.
| type | Type of stream to export to |
|
inline |
Get all components of specified type.
| T | Component type to get |
|
inline |
Get all components of any type.
|
inline |
Get components of type from this object and all children.
| T | Component type to get |
| GameObject & StevEngine::GameObject::GetChild | ( | int | index | ) | const |
Get child object.
| index | Child index |
| uint32_t StevEngine::GameObject::GetChildCount | ( | ) | const |
Get number of children.
|
inline |
Get component of specified type.
| T | Component type to get |
| log | Whether to log if component not found |
| GameObject & StevEngine::GameObject::GetParent | ( | ) | const |
Get parent object.
| Utilities::Vector3 StevEngine::GameObject::GetPosition | ( | ) | const |
Get local position.
| Utilities::Quaternion StevEngine::GameObject::GetRotation | ( | ) | const |
Get local rotation.
| Utilities::Vector3 StevEngine::GameObject::GetScale | ( | ) | const |
Get local scale.
| Scene & StevEngine::GameObject::GetScene | ( | ) | const |
| Utilities::Vector3 StevEngine::GameObject::GetWorldPosition | ( | ) | const |
Get world position.
| Utilities::Quaternion StevEngine::GameObject::GetWorldRotation | ( | ) | const |
Get world rotation.
| Utilities::Vector3 StevEngine::GameObject::GetWorldScale | ( | ) | const |
Get world scale.
|
inline |
Check if object has a parent.
|
inline |
Get object's unique ID.
| void StevEngine::GameObject::Import | ( | Utilities::Stream & | stream | ) |
Load object from serialized data.
| stream | Stream containing serialized object data |
|
inline |
Publish an event.
| EventType | Type of event to publish |
| event | Event to publish |
|
inline |
| void StevEngine::GameObject::RemoveChild | ( | int | index | ) |
Remove child at index.
| index | Index of child to remove |
|
inline |
Remove specific component instance.
| T | Component type to remove |
| component | Pointer to component to remove |
| void StevEngine::GameObject::SetPosition | ( | Utilities::Vector3 | position, |
| bool | announce = true ) |
Set local position.
| position | New position |
| announce | Whether to trigger transform event |
| void StevEngine::GameObject::SetRotation | ( | Utilities::Quaternion | rotation, |
| bool | announce = true ) |
Set local rotation.
| rotation | New rotation |
| announce | Whether to trigger transform event |
| void StevEngine::GameObject::SetScale | ( | Utilities::Vector3 | scale, |
| bool | announce = true ) |
Set local scale.
| scale | New scale |
| announce | Whether to trigger transform event |
| void StevEngine::GameObject::SetTransform | ( | Utilities::Vector3 | position, |
| Utilities::Quaternion | rotation, | ||
| Utilities::Vector3 | scale, | ||
| bool | announce = true ) |
Set full local transform.
| position | New position |
| rotation | New rotation |
| scale | New scale |
| announce | Whether to trigger transform event |
|
inline |
Subscribe to object events.
| EventType | Type of event to subscribe to |
| handler | Function to handle event |
| allowFromChild | Whether to receive events from children |
|
inline |
Unsubscribe from events.
| eventId | Event type identifier |
| handlerId | Handler ID to unsubscribe |