Class Actor
Defined in File Actor.hpp
Inheritance Relationships
Base Type
public std::enable_shared_from_this< Actor >
Class Documentation
-
class Actor : public 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
-
void MountComponent(const std::string &factoryID)
Create a new component and add it to this actor.
- Parameters:
factoryID – The ID of the Component factory in with the CodeRegistry to create the component
- Throws:
ExistingValueException – If a component of this type already exists on the actor
NonexistentValueException – If the CodeRegistry does not have a Component actory registered for the provided ID
-
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