Claire's Game Engine
Full C++ Engine using OpenGL
|
Base class representing an actor in the scene. More...
#include <Actor.h>
Public Member Functions | |
Actor () | |
virtual | ~Actor () |
void | SetScene (Scene *pScene) |
Sets the scene for this actor. | |
void | AddComponent (Component *pComponent) |
Adds a component to the actor. The component can be of various types (render, collider, etc.). | |
void | RemoveComponent (Component *pComponent) |
Removes a specific component from the actor. | |
void | UpdateComponentsTransform () |
Updates all components' world transforms. | |
void | SetActive (bool isActive) |
Sets the actor's active state, enabling or disabling components accordingly. | |
ActorState | GetState () const |
Returns the current state of the actor (Active, Paused, Dead). | |
Vector3 | GetPosition () const |
Returns the position of the actor in world space. | |
virtual void | SetupComponents () |
Called to set up the actor's components after initialization. | |
virtual void | Start () |
Called once at the start of the scene, after setup. | |
virtual void | Update () |
Called every frame to update the actor and its component. | |
virtual void | Destroy () |
Called to destroy the actor, marking it as dead. | |
virtual void | OnCollide (Actor *collidedActor) |
Called when this actor collides with another actor. Override this to handle collision behavior. | |
template<typename C> | |
C * | GetComponentOfType () const |
Gets a component of a specific type attached to this actor. | |
Public Attributes | |
Transform * | mTransform = nullptr |
Transform representing position, rotation, scale. | |
Scene * | mScene = nullptr |
Scene this actor belongs to. | |
Base class representing an actor in the scene.
Actors are entities that can contain multiple components such as renderers, colliders, etc. They manage their own lifecycle (setup, start, update, destroy) and interact with the scene.
Actor::Actor | ( | ) |
|
virtual |
void Actor::AddComponent | ( | Component * | pComponent | ) |
Adds a component to the actor. The component can be of various types (render, collider, etc.).
pComponent | The component to add to the actor. |
|
virtual |
Called to destroy the actor, marking it as dead.
|
inline |
Gets a component of a specific type attached to this actor.
C | The type of component to retrieve. |
Vector3 Actor::GetPosition | ( | ) | const |
Returns the position of the actor in world space.
ActorState Actor::GetState | ( | ) | const |
Returns the current state of the actor (Active, Paused, Dead).
|
inlinevirtual |
Called when this actor collides with another actor. Override this to handle collision behavior.
collidedActor | The actor that collided with this actor. |
void Actor::RemoveComponent | ( | Component * | pComponent | ) |
Removes a specific component from the actor.
pComponent | The component to remove. |
void Actor::SetActive | ( | bool | isActive | ) |
Sets the actor's active state, enabling or disabling components accordingly.
isActive | True to activate the actor, false to pause it. |
void Actor::SetScene | ( | Scene * | pScene | ) |
Sets the scene for this actor.
pScene | The scene this actor belongs to. |
|
inlinevirtual |
Called to set up the actor's components after initialization.
Reimplemented in Camera.
|
virtual |
Called once at the start of the scene, after setup.
|
virtual |
Called every frame to update the actor and its component.
Reimplemented in Camera.
void Actor::UpdateComponentsTransform | ( | ) |
Updates all components' world transforms.