Class Actor
Defined in File Actor.hpp
Inheritance Relationships
Base Type
protected std::enable_shared_from_this< Actor >
Class Documentation
-
class Actor : protected std::enable_shared_from_this<Actor>
An object that exists within a World.
Public Functions
-
glm::mat4 GetWorldTransformMatrix() const
Calculate the world-space transformation matrix of the actor.
- Returns:
The world-space transformation matrix
-
ActorHandle GetParent() const
Access the parent of this actor.
- Returns:
The parent actor, or a null handle if the parent is the world root
-
inline bool IsActive() const
Check if the actor is active.
This takes into account both if the actor is enabled and its parent Actor is active
Note
This will return false if the parent Actor is inactive
-
void SetActive(bool state)
Activate or deactivate the actor.
- Parameters:
state – The new activation state
-
void Reparent(ActorHandle newParent)
Change the parent of this actor.
- Parameters:
newParent – The new parent of this actor
-
template<typename T, typename ...Args>
inline void MountComponent(Args&&... args) Create a new component and add it to this actor.
- Parameters:
args – The arguments to the component constructor
- Throws:
ExistingValueException – If a component of this type already exists on the actor
Create a new component and add it to this actor.
- Parameters:
exporter – The handle to the ComponentExporter from which to construct the component
- Throws:
ExistingValueException – If a component of this type already exists on the actor
-
template<typename T, typename ...Args>
inline bool HasComponent() const Check if a component is on an actor.
- Returns:
Whether a component of the type is on the actor
Access a component on the actor.
- Throws:
NonexistentValueException – If a component of this type does not exist on the actor
- Returns:
The component
-
template<typename T, typename ...Args>
inline void DeleteComponent() Delete a component from the actor.
- Throws:
NonexistentValueException – If a component of this type does not exist on the actor
-
inline std::map<std::type_index, std::shared_ptr<Component>> GetAllComponents() const
Get a copy of all the components on the actor.
Note
This doesn’t actually copy the components, just their pointers, but this does increment the reference count
- Returns:
All actor components
-
inline std::vector<ActorHandle> GetAllChildren() const
Get all the children of the actor.
- Returns:
All child entities
Public Members
-
const xg::Guid guid
Actor ID, unique.
Public Static Functions
-
static ActorHandle Create(const std::string &name, ActorHandle parent)
Create a new actor.
- Parameters:
name – The initial name of the actor
parent – The initial actor parent
- Throws:
NonexistentValueException – If the provided parent is a null handle
- Returns:
A handle to the new actor
Create a new actor attached to the world root.
- Parameters:
name – The initial name of the actor
world – The world to place the actor in
- Returns:
A handle to the new actor
-
glm::mat4 GetWorldTransformMatrix() const