Class Component
Defined in File Component.hpp
Inheritance Relationships
Derived Type
public Cacao::Script
(Class Script)
Class Documentation
-
class Component
An object attached to an Actor that performs tasks on its behalf.
Subclassed by Cacao::Script
Public Functions
-
inline bool IsEnabled() const
Check if the component is enabled.
This takes into account both if the component itself is enabled and its owning Actor is active
Note
This will return false if the owning Actor is inactive
-
inline void SetEnabled(bool state)
Activate or deactivate the component.
- Parameters:
state – The new activation state
-
inline std::shared_ptr<Actor> GetOwner() const
Get the owning actor of this component.
- Throws:
NonexistentValueException – If the actor no longer exists
- Returns:
A reference to the owning actor
Protected Functions
-
inline virtual void OnMount()
Runs when the component is first mounted on an Actor.
Note
All setup should be performed here, NOT in the constructor. Only when this function is called is the component properly configured.
-
inline virtual void OnEnable()
Runs when the component is enabled or when the owning Actor becomes active if the component was already enabled.
-
inline virtual void OnDisable()
Runs when the component is disabled or when the owning Actor becomes inactive if the component was already enabled.
Protected Attributes
-
std::weak_ptr<Actor> actor
Warning
Do not lock and store this pointer for longer than necessary (i.e. function scope)! Doing so will break world tree unwinding!
Friends
- friend class Actor
- friend class ComponentExporter
-
inline bool IsEnabled() const