Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::Actor Class Reference

Represents an entity in the game world that can have components and a transform. More...

#include <Actor.h>

Inheritance diagram for clt::Actor:
Beach BowlingBall BowlingLane Water Zombie clt::CubeActor clt::EditorCamera

Public Member Functions

 Actor (Level *pLevel, std::string pName="Actor")
 Constructor for the Actor class.
 
 ~Actor ()
 Destructor for the Actor class.
 
virtual void Start ()
 Called when the actor is first created or spawned.
 
virtual void Update ()
 Virtual method to update the actor.
 
virtual void Destroy ()
 Called when the actor is being destroyed.
 
template<typename T , typename... Args>
T * AddComponent (Args &&... args)
 Adds a component of type T to the actor.
 
template<typename T >
void RemoveComponent ()
 Removes a component of type T from the actor.
 
template<typename T >
T * GetComponentOfType ()
 Gets a pointer to the component of type T attached to this actor.
 
bool LineTrace (Vector3 start, Vector3 direction, float maxDistance, raycastHit &hit, bool debugPersistant=false, bool ignoreSelf=true)
 Performs a line trace (raycast) from a start point in a direction.
 
Transform GetTransform () const
 Gets the transform of the actor.
 
Vector3 GetActorLocation () const
 Gets the position of the actor.
 
Vector3 GetScale () const
 Gets the scale of the actor.
 
std::string GetName () const
 Gets the name of the actor.
 
Quaternion GetRotation () const
 Gets the rotation of the actor as a quaternion.
 
void SetActorLocation (const Vector3 &loc)
 Sets the location of the actor.
 
void SetActorLocation (const Vector2 &loc)
 Sets the location of the actor using a 2D vector.
 
void SetActorScale (const Vector3 &scale)
 Sets the scale of the actor.
 
void SetActorScale (const Vector2 &scale)
 Sets the scale of the actor using a 2D vector.
 
void SetActorScale (float scale)
 Sets the uniform scale of the actor.
 
void SetActorRotation (const Quaternion &rot)
 Sets the rotation of the actor.
 
void SetActorRotation (float rot)
 Sets the rotation of the actor using a float value.
 
void SetActorRotation (const Vector3 &rot)
 Sets the rotation of the actor using a vector (Euler angles).
 
void SetActorTransform (const Vector3 &location, const Vector3 &rotation, const Vector3 &scale)
 Sets the transform of the actor.
 
void AddActorLocationOffset (const Vector3 &locOffset)
 Adds an offset to the actor's location.
 
void AddActorLocationOffset (const Vector2 &locOffset)
 Adds an offset to the actor's location using a 2D vector.
 
void AddActorRotationOffset (Quaternion rotOffset)
 Adds an offset to the actor's rotation.
 
void AddActorRotationOffset (Vector3 rotOffset)
 Adds an offset to the actor's rotation using a vector (Euler angles).
 
void AddActorRotationOffset (float rotOffset)
 Adds an offset to the actor's rotation using a float value.
 
LevelGetLevel () const
 Gets the level the actor is attached to.
 

Public Attributes

friend Level
 

Detailed Description

Represents an entity in the game world that can have components and a transform.

The Actor class is the base class for all objects that can be placed or spawned in a level. It manages its own transform, state, and a collection of components that define its behavior.

Constructor & Destructor Documentation

◆ Actor()

Actor::Actor ( Level * pLevel,
std::string pName = "Actor" )

Constructor for the Actor class.

Parameters
pLevelThe level to which this actor belongs.
pNameThe name of the actor (default: "Actor").

Member Function Documentation

◆ AddActorLocationOffset() [1/2]

void clt::Actor::AddActorLocationOffset ( const Vector2 & locOffset)
inline

Adds an offset to the actor's location using a 2D vector.

Parameters
locOffsetThe location offset.

◆ AddActorLocationOffset() [2/2]

void clt::Actor::AddActorLocationOffset ( const Vector3 & locOffset)
inline

Adds an offset to the actor's location.

Parameters
locOffsetThe location offset.

◆ AddActorRotationOffset() [1/3]

void clt::Actor::AddActorRotationOffset ( float rotOffset)
inline

Adds an offset to the actor's rotation using a float value.

Parameters
rotOffsetThe rotation offset.

◆ AddActorRotationOffset() [2/3]

void clt::Actor::AddActorRotationOffset ( Quaternion rotOffset)
inline

Adds an offset to the actor's rotation.

Parameters
rotOffsetThe rotation offset as a quaternion.

◆ AddActorRotationOffset() [3/3]

void clt::Actor::AddActorRotationOffset ( Vector3 rotOffset)
inline

Adds an offset to the actor's rotation using a vector (Euler angles).

Parameters
rotOffsetThe rotation offset.

◆ AddComponent()

template<typename T , typename... Args>
T * clt::Actor::AddComponent ( Args &&... args)
inline

Adds a component of type T to the actor.

Template Parameters
TThe type of the component to add (must derive from Component).
ArgsConstructor argument types for the component.
Parameters
argsArguments to forward to the component's constructor.
Returns
Pointer to the newly added component, or nullptr if a component of this type already exists.

◆ Destroy()

virtual void clt::Actor::Destroy ( )
inlinevirtual

Called when the actor is being destroyed.

Override this method to implement custom cleanup logic.

◆ GetActorLocation()

Vector3 clt::Actor::GetActorLocation ( ) const
inline

Gets the position of the actor.

Returns
The position of the actor.

◆ GetComponentOfType()

template<typename T >
T * clt::Actor::GetComponentOfType ( )
inline

Gets a pointer to the component of type T attached to this actor.

Template Parameters
TThe type of the component to retrieve (must derive from Component).
Returns
Pointer to the component if found, nullptr otherwise.

◆ GetLevel()

Level * clt::Actor::GetLevel ( ) const
inline

Gets the level the actor is attached to.

Returns
The level the actor is attached to.

◆ GetName()

std::string clt::Actor::GetName ( ) const
inline

Gets the name of the actor.

Returns
The name of the actor.

◆ GetRotation()

Quaternion clt::Actor::GetRotation ( ) const
inline

Gets the rotation of the actor as a quaternion.

Returns
The rotation of the actor.

◆ GetScale()

Vector3 clt::Actor::GetScale ( ) const
inline

Gets the scale of the actor.

Returns
The scale of the actor.

◆ GetTransform()

Transform clt::Actor::GetTransform ( ) const
inline

Gets the transform of the actor.

Returns
The transform of the actor.

◆ LineTrace()

bool Actor::LineTrace ( Vector3 start,
Vector3 direction,
float maxDistance,
raycastHit & hit,
bool debugPersistant = false,
bool ignoreSelf = true )

Performs a line trace (raycast) from a start point in a direction.

Parameters
startThe starting point of the trace.
directionThe direction of the trace.
maxDistanceThe maximum distance to trace.
hitThe result of the trace if a hit occurs.
debugPersistantWhether to persist debug visualization.
ignoreSelfWhether to ignore this actor in the trace.
Returns
True if something was hit, false otherwise.

◆ RemoveComponent()

template<typename T >
void clt::Actor::RemoveComponent ( )
inline

Removes a component of type T from the actor.

Template Parameters
TThe type of the component to remove (must derive from Component).

If the component exists, it will be removed after the current update cycle.

◆ SetActorLocation() [1/2]

void clt::Actor::SetActorLocation ( const Vector2 & loc)
inline

Sets the location of the actor using a 2D vector.

Parameters
locThe new location.

◆ SetActorLocation() [2/2]

void clt::Actor::SetActorLocation ( const Vector3 & loc)
inline

Sets the location of the actor.

Parameters
locThe new location.

◆ SetActorRotation() [1/3]

void clt::Actor::SetActorRotation ( const Quaternion & rot)
inline

Sets the rotation of the actor.

Parameters
rotThe new rotation as a quaternion.

◆ SetActorRotation() [2/3]

void clt::Actor::SetActorRotation ( const Vector3 & rot)
inline

Sets the rotation of the actor using a vector (Euler angles).

Parameters
rotThe new rotation as Euler angles.

◆ SetActorRotation() [3/3]

void clt::Actor::SetActorRotation ( float rot)
inline

Sets the rotation of the actor using a float value.

Parameters
rotThe new rotation value.

◆ SetActorScale() [1/3]

void clt::Actor::SetActorScale ( const Vector2 & scale)
inline

Sets the scale of the actor using a 2D vector.

Parameters
scaleThe new scale.

◆ SetActorScale() [2/3]

void clt::Actor::SetActorScale ( const Vector3 & scale)
inline

Sets the scale of the actor.

Parameters
scaleThe new scale.

◆ SetActorScale() [3/3]

void clt::Actor::SetActorScale ( float scale)
inline

Sets the uniform scale of the actor.

Parameters
scaleThe new scale value.

◆ SetActorTransform()

void clt::Actor::SetActorTransform ( const Vector3 & location,
const Vector3 & rotation,
const Vector3 & scale )
inline

Sets the transform of the actor.

Parameters
locationThe new location.
rotationThe new rotation (Euler angles).
scaleThe new scale.

◆ Start()

virtual void clt::Actor::Start ( )
inlinevirtual

Called when the actor is first created or spawned.

Override this method to implement custom initialization logic.

Reimplemented in Zombie.

◆ Update()

virtual void clt::Actor::Update ( )
inlinevirtual

Virtual method to update the actor.

Override this method to implement custom per-frame update logic.

Reimplemented in BowlingBall, BowlingLane, Water, and Zombie.


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