Skip to main content

DelayedComponentEnabler Class

Component that manages delayed activation of other components. More...

Declaration

class helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler { ... }

Public Constructors Index

DelayedComponentEnabler ()=default

Default constructor. More...

DelayedComponentEnabler (const DelayedComponentEnabler &other)

Copy constructor for cloning during spawn. More...

DelayedComponentEnabler (DelayedComponentEnabler &&) noexcept=default

Public Operators Index

DelayedComponentEnabler &operator= (const DelayedComponentEnabler &)=default
DelayedComponentEnabler &operator= (DelayedComponentEnabler &&) noexcept=default

Public Member Functions Index

std::span< DeferredComponent >deferredComponents () noexcept

Returns a view of all currently deferred components. More...

voidsync (std::span< helios::engine::core::data::ComponentTypeId > removeList)

Removes activated components from the deferred list. More...

voiddefer (helios::engine::ecs::GameObject gameObject, helios::engine::core::data::ComponentTypeId componentTypeId, const float delta)

Schedules a component for delayed activation. More...

Private Member Attributes Index

std::vector< DeferredComponent >deferredComponents_

List of components pending delayed activation. More...

Description

Component that manages delayed activation of other components.

DelayedComponentEnabler maintains a list of components that should be activated after a specified delay. This is useful for gameplay patterns where newly spawned entities need temporary immunity or staggered activation:

  • **Collision immunity:** Projectiles ignore collisions briefly after spawn
  • **AI warmup:** Behavior components activate after positioning completes
  • **Visual fade-in:** Rendering components enable after spawn effects
  • **Staggered waves:** Sequential entities activate progressively

The component works in conjunction with DelayedComponentEnablerSystem, which decrements timers each frame and enables components when their delay expires.

info

Components are disabled immediately when deferred and re-enabled automatically by the system when the delay reaches zero.

See Also

DelayedComponentEnablerSystem

See Also

DelayedComponentEnablerInitializer

Definition at line 44 of file DelayedComponentEnabler.ixx.

Public Constructors

DelayedComponentEnabler()

helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::DelayedComponentEnabler ()
default

Default constructor.

Definition at line 71 of file DelayedComponentEnabler.ixx.

Referenced by DelayedComponentEnabler, DelayedComponentEnabler, operator= and operator=.

DelayedComponentEnabler()

helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::DelayedComponentEnabler (const DelayedComponentEnabler & other)
inline

Copy constructor for cloning during spawn.

Parameters
other

The source component to copy from.

Definition at line 78 of file DelayedComponentEnabler.ixx.

79 : deferredComponents_(other.deferredComponents_) {}

Reference DelayedComponentEnabler.

DelayedComponentEnabler()

helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::DelayedComponentEnabler (DelayedComponentEnabler &&)
noexcept default

Definition at line 82 of file DelayedComponentEnabler.ixx.

Reference DelayedComponentEnabler.

Public Operators

operator=()

DelayedComponentEnabler & helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::operator= (const DelayedComponentEnabler &)
default

Definition at line 81 of file DelayedComponentEnabler.ixx.

Reference DelayedComponentEnabler.

operator=()

DelayedComponentEnabler & helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::operator= (DelayedComponentEnabler &&)
noexcept default

Definition at line 83 of file DelayedComponentEnabler.ixx.

Reference DelayedComponentEnabler.

Public Member Functions

defer()

void helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::defer (helios::engine::ecs::GameObject gameObject, helios::engine::core::data::ComponentTypeId componentTypeId, const float delta)
inline

Schedules a component for delayed activation.

The specified component is immediately disabled and added to the deferred list. If the component is already deferred, its delay is updated to the new value.

Parameters
componentTypeId

Type identifier of the component to defer.

delta

Delay in seconds before activation.

info

Asserts if delta <= 0 or if the component does not exist on the entity.

Definition at line 120 of file DelayedComponentEnabler.ixx.

120 void defer(
122 helios::engine::core::data::ComponentTypeId componentTypeId, const float delta) {
123 assert(delta > 0 && "delta must be greater than 0");
124
125 const bool hasCmp = gameObject.has(componentTypeId);
126 assert(hasCmp && "ComponentTypeId not part of GameObject");
127
128 const auto it = std::ranges::find_if(deferredComponents_,
129 [componentTypeId](const auto& item) {
130 return item.componentTypeId == componentTypeId;
131 });
132
133 gameObject.disableComponent(componentTypeId);
134
135 if (it == deferredComponents_.end()) {
136 deferredComponents_.push_back({delta, componentTypeId});
137 } else {
138 it->delta = delta;
139 }
140 }

References helios::engine::ecs::GameObject::disableComponent and helios::engine::ecs::GameObject::has.

deferredComponents()

std::span< DeferredComponent > helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::deferredComponents ()
inline noexcept

Returns a view of all currently deferred components.

Returns

Span of DeferredComponent entries with remaining delays.

Definition at line 90 of file DelayedComponentEnabler.ixx.

90 std::span<DeferredComponent> deferredComponents() noexcept {
91 return deferredComponents_;
92 }

Reference deferredComponents.

Referenced by deferredComponents.

sync()

void helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::sync (std::span< helios::engine::core::data::ComponentTypeId > removeList)
inline

Removes activated components from the deferred list.

Called by the system after enabling components to clean up entries that have completed their delay period.

Parameters
removeList

Component type IDs to remove from tracking.

Definition at line 102 of file DelayedComponentEnabler.ixx.

102 void sync(std::span<helios::engine::core::data::ComponentTypeId> removeList) {
103 std::erase_if(deferredComponents_, [&](const DeferredComponent& dc) {
104 return std::ranges::find(removeList, dc.componentTypeId) != removeList.end();
105 });
106 }

Private Member Attributes

deferredComponents_

std::vector<DeferredComponent> helios::engine::mechanics::lifecycle::components::DelayedComponentEnabler::deferredComponents_

List of components pending delayed activation.

Definition at line 64 of file DelayedComponentEnabler.ixx.

64 std::vector<DeferredComponent> deferredComponents_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.