Clutter Engine 0.0.1
|
Represents an entity in the game world that can have components and a transform. More...
#include <Actor.h>
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. | |
Level * | GetLevel () const |
Gets the level the actor is attached to. | |
Public Attributes | |
friend | Level |
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.
Actor::Actor | ( | Level * | pLevel, |
std::string | pName = "Actor" ) |
Constructor for the Actor class.
pLevel | The level to which this actor belongs. |
pName | The name of the actor (default: "Actor"). |
|
inline |
Adds an offset to the actor's location using a 2D vector.
locOffset | The location offset. |
|
inline |
Adds an offset to the actor's location.
locOffset | The location offset. |
|
inline |
Adds an offset to the actor's rotation using a float value.
rotOffset | The rotation offset. |
|
inline |
Adds an offset to the actor's rotation.
rotOffset | The rotation offset as a quaternion. |
|
inline |
Adds an offset to the actor's rotation using a vector (Euler angles).
rotOffset | The rotation offset. |
|
inline |
Adds a component of type T to the actor.
T | The type of the component to add (must derive from Component). |
Args | Constructor argument types for the component. |
args | Arguments to forward to the component's constructor. |
|
inlinevirtual |
Called when the actor is being destroyed.
Override this method to implement custom cleanup logic.
|
inline |
Gets the position of the actor.
|
inline |
Gets a pointer to the component of type T attached to this actor.
T | The type of the component to retrieve (must derive from Component). |
|
inline |
Gets the level the actor is attached to.
|
inline |
Gets the name of the actor.
|
inline |
Gets the rotation of the actor as a quaternion.
|
inline |
Gets the scale of the actor.
|
inline |
Gets the transform of the actor.
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.
start | The starting point of the trace. |
direction | The direction of the trace. |
maxDistance | The maximum distance to trace. |
hit | The result of the trace if a hit occurs. |
debugPersistant | Whether to persist debug visualization. |
ignoreSelf | Whether to ignore this actor in the trace. |
|
inline |
Removes a component of type T from the actor.
T | The type of the component to remove (must derive from Component). |
If the component exists, it will be removed after the current update cycle.
|
inline |
Sets the location of the actor using a 2D vector.
loc | The new location. |
|
inline |
Sets the location of the actor.
loc | The new location. |
|
inline |
Sets the rotation of the actor.
rot | The new rotation as a quaternion. |
|
inline |
Sets the rotation of the actor using a vector (Euler angles).
rot | The new rotation as Euler angles. |
|
inline |
Sets the rotation of the actor using a float value.
rot | The new rotation value. |
|
inline |
Sets the scale of the actor using a 2D vector.
scale | The new scale. |
|
inline |
Sets the scale of the actor.
scale | The new scale. |
|
inline |
Sets the uniform scale of the actor.
scale | The new scale value. |
|
inline |
Sets the transform of the actor.
location | The new location. |
rotation | The new rotation (Euler angles). |
scale | The new scale. |
|
inlinevirtual |
Called when the actor is first created or spawned.
Override this method to implement custom initialization logic.
Reimplemented in Zombie.
|
inlinevirtual |
Virtual method to update the actor.
Override this method to implement custom per-frame update logic.
Reimplemented in BowlingBall, BowlingLane, Water, and Zombie.