Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
Actor Class Reference

Base class representing an actor in the scene. More...

#include <Actor.h>

Inheritance diagram for Actor:
Camera

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

TransformmTransform = nullptr
 Transform representing position, rotation, scale.
 
ScenemScene = nullptr
 Scene this actor belongs to.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Actor()

Actor::Actor ( )

◆ ~Actor()

Actor::~Actor ( )
virtual

Member Function Documentation

◆ AddComponent()

void Actor::AddComponent ( Component * pComponent)

Adds a component to the actor. The component can be of various types (render, collider, etc.).

Parameters
pComponentThe component to add to the actor.

◆ Destroy()

void Actor::Destroy ( )
virtual

Called to destroy the actor, marking it as dead.

◆ GetComponentOfType()

template<typename C>
C * Actor::GetComponentOfType ( ) const
inline

Gets a component of a specific type attached to this actor.

Parameters
CThe type of component to retrieve.
Returns
Pointer to the component if found, nullptr otherwise.

◆ GetPosition()

Vector3 Actor::GetPosition ( ) const

Returns the position of the actor in world space.

Returns
The actor's position.

◆ GetState()

ActorState Actor::GetState ( ) const

Returns the current state of the actor (Active, Paused, Dead).

Returns
The actor's state.

◆ OnCollide()

virtual void Actor::OnCollide ( Actor * collidedActor)
inlinevirtual

Called when this actor collides with another actor. Override this to handle collision behavior.

Parameters
collidedActorThe actor that collided with this actor.

◆ RemoveComponent()

void Actor::RemoveComponent ( Component * pComponent)

Removes a specific component from the actor.

Parameters
pComponentThe component to remove.

◆ SetActive()

void Actor::SetActive ( bool isActive)

Sets the actor's active state, enabling or disabling components accordingly.

Parameters
isActiveTrue to activate the actor, false to pause it.

◆ SetScene()

void Actor::SetScene ( Scene * pScene)

Sets the scene for this actor.

Parameters
pSceneThe scene this actor belongs to.

◆ SetupComponents()

virtual void Actor::SetupComponents ( )
inlinevirtual

Called to set up the actor's components after initialization.

Reimplemented in Camera.

◆ Start()

void Actor::Start ( )
virtual

Called once at the start of the scene, after setup.

◆ Update()

void Actor::Update ( )
virtual

Called every frame to update the actor and its component.

Reimplemented in Camera.

◆ UpdateComponentsTransform()

void Actor::UpdateComponentsTransform ( )

Updates all components' world transforms.

Member Data Documentation

◆ mScene

Scene* Actor::mScene = nullptr

Scene this actor belongs to.

◆ mTransform

Transform* Actor::mTransform = nullptr

Transform representing position, rotation, scale.


The documentation for this class was generated from the following files: