26 std::optional<std::reference_wrapper<GameObject>> parent_;
28 bool marked_for_deletion_{
false};
30 std::vector<std::function<void(
Component&)>> on_detach_actions_;
31 std::vector<std::function<void(
Component&)>> on_attach_actions_;
41 [[nodiscard]]
bool active() const noexcept;
96 std::optional<std::reference_wrapper<
GameObject>>&
Base class for all components that can be attached to GameObjects.
Definition component.h:24
virtual void on_deserialize(const std::vector< uint8_t > &, size_t &)
Deserializes the component's state from a byte array.
const std::optional< std::reference_wrapper< GameObject > > & parent() const noexcept
Gets the parent GameObject of this component.
void remove_on_attach(size_t index)
virtual std::string type_name() const =0
Provides a consistent type name for the component.
virtual void on_serialize(std::vector< uint8_t > &) const
Serializes the component's state into a byte array.
size_t add_on_detach(const std::function< void(Component &)> &action)
Adds an action to be performed when the component is attached.
virtual void on_detach()
Called when the component is detached from a GameObject.
bool marked_for_deletion() const noexcept
Activates the component.
void remove_on_detach(size_t index)
size_t add_on_attach(const std::function< void(Component &)> &action)
Retrieves the type information of the component.
Component & mark_for_deletion() noexcept
virtual void update(float dt)=0
bool active() const noexcept
Checks if the component is active.
virtual void on_attach()
Called when the component is attached to a GameObject.
virtual ~Component()=default
Concept to constrain types to be derived from Component.
Definition gameObject.h:33
Definition component.h:122