|
SleakEngine 0.1.0
C++23 multi-backend game engine
|
#include <Component.hpp>
Public Member Functions | |
| Component (GameObject *object) | |
| virtual | ~Component ()=default |
| virtual void | FixedUpdate (float fixedDeltaTime) |
| GameObject * | GetOwner () |
| virtual bool | Initialize ()=0 |
| One-time setup, called after the component is attached and the owner is initialized. | |
| bool | IsInitialized () const |
| True once Initialize() has run and succeeded. | |
| virtual void | LateUpdate (float deltaTime) |
| virtual void | OnDestroy () |
| Called when the component is detached or the owner is destroyed. | |
| virtual void | OnDisable () |
| virtual void | OnEnable () |
| virtual void | Update (float deltaTime)=0 |
| Public Member Functions inherited from Sleak::Object | |
| Object (const std::string &name="Object") | |
| virtual | ~Object ()=default |
| std::string | GetDebugName () const |
| Name plus unique ID, for logs where names can repeat. | |
| const std::string & | GetName () const |
| uint64_t | GetUniqueID () const |
| void | SetName (const std::string &value) |
Protected Attributes | |
| bool | bIsInitialized |
| GameObject * | owner |
Friends | |
| class | GameObject |
Base for behavior attached to a GameObject. Owner deletes it via GameObject::RemoveComponent(), never directly.
Derive from Component to add your own behavior to an object. The constructor must take the owning GameObject* as its first parameter, because GameObject::AddComponent() supplies it and forwards the rest. Initialize() and Update() are pure virtual; FixedUpdate(), LateUpdate(), OnEnable(), OnDisable(), and OnDestroy() are optional.
The owning GameObject holds components in a RefPtr and destroys them with itself, so never delete a component directly. Reach the owner through GetOwner() to find sibling components.
Lifecycle: the object calls Initialize() once (immediately if the object is already initialized when the component is attached, and otherwise during the object's own Initialize()), then OnEnable() if the object is active, then Update() every frame.
Definition at line 59 of file Component.hpp.
|
inline |
Definition at line 61 of file Component.hpp.
|
virtualdefault |
|
inlinevirtual |
Definition at line 68 of file Component.hpp.
|
inline |
Definition at line 76 of file Component.hpp.
|
pure virtual |
One-time setup, called after the component is attached and the owner is initialized.
Implemented in Sleak::AnimatorComponent, Sleak::CameraController, Sleak::ColliderComponent, Sleak::FirstPersonController, Sleak::FreeLookCameraController, Sleak::MaterialComponent, Sleak::MeshComponent, Sleak::RigidbodyComponent, and Sleak::TransformComponent.
|
inline |
True once Initialize() has run and succeeded.
Definition at line 81 of file Component.hpp.
|
inlinevirtual |
Definition at line 69 of file Component.hpp.
|
inlinevirtual |
Called when the component is detached or the owner is destroyed.
Definition at line 72 of file Component.hpp.
|
inlinevirtual |
Reimplemented in Sleak::MaterialComponent.
Definition at line 74 of file Component.hpp.
|
inlinevirtual |
Reimplemented in Sleak::MaterialComponent.
Definition at line 73 of file Component.hpp.
|
pure virtual |
|
friend |
Definition at line 88 of file Component.hpp.
|
protected |
Definition at line 85 of file Component.hpp.
|
protected |
Definition at line 84 of file Component.hpp.