Class Actor
Defined in File Actor.hpp
Class Documentation
-
class Actor
An object that exists within a World.
Public Functions
-
inline const Transform &GetLocalTransform() const
Get the actor’s local transform relative to its parent.
- Returns:
The local-space transform
-
inline void SetLocalTransform(Transform transform)
Update the local transform of the actor relative to its parent.
- Parameters:
transform – The new local-space transform
-
glm::mat4 GetWorldTransformationMatrix() const
Calculate the world-space transformation matrix of the actor.
- Returns:
The world-space transformation matrix
-
Transform GetWorldTransform() const
Get the effective transform of the actor in world-space.
- Returns:
The world-space transform
-
inline ActorRef GetParent() const
Access the parent of this actor.
- Returns:
The parent actor, or a null handle if this actor is toplevel
-
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(ActorRef newParent)
Change the parent of this actor.
- Parameters:
newParent – The new parent of this actor
- Throws:
BadValueException – If a null ref is provided
BadValueException – If a ref to the same actor being reparented is provided
-
template<typename T>
inline bool HasComponent() const Check if a component is on an actor.
- Returns:
Whether a component of the type is on the actor
-
template<typename T, typename ...Args>
inline T &MountComponent(Args&&... args, bool enabled = true) Create a new component and add it to this actor.
- Parameters:
args – The arguments to the component constructor
enabled – Whether the component should start enabled or not
- Throws:
ExistingValueException – If a component of this type already exists on the actor
-
Component &MountComponent(const std::string &factoryID, bool enabled = true)
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
enabled – Whether the component should start enabled or not
- 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
-
Component &MountComponent(const std::string &factoryID, std::function<void(Component&)> configure, bool enabled = true)
Create a new component and add it to this actor, with a callback for intial configuration.
- Parameters:
factoryID – The ID of the Component factory in with the CodeRegistry to create the component
configure – A callback accepting the instantiated component to run for initial configuration
enabled – Whether the component should start enabled or not
- 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>
inline T &GetComponent() const 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>
inline void UnmountComponent() Remove a component from the actor.
- Throws:
NonexistentValueException – If a component of this type does not exist on the actor
-
inline std::unordered_map<std::type_index, Component*> GetAllComponents() const
Get a list of all the components on the actor.
- Returns:
References to all actor components
-
template<typename F>
inline std::unordered_map<std::type_index, Component*> GetComponentsFiltered(F filter) const Get a filtered list of all the components on the actor.
- Parameters:
filter – The filter function to check each component against, returning true for matching components
- Returns:
References to all matching actor components
-
inline std::vector<ActorRef> GetAllChildren() const
Get all the children of the actor.
- Returns:
All child entities
Public Members
-
const xg::Guid guid
Actor ID, unique.
-
inline const Transform &GetLocalTransform() const