Skip to main content

DelayedComponentEnablerInitializer Class Template

Initializer that schedules delayed activation of arbitrary components. More...

Declaration

template <typename... ComponentTypes> class helios::engine::runtime::spawn::behavior::initializers::DelayedComponentEnablerInitializer<ComponentTypes> { ... }

Base class

classSpawnInitializer

Abstract interface for initializing spawned entity state. More...

Public Constructors Index

template <typename... ComponentTypes>
DelayedComponentEnablerInitializer (const float delay, const size_t cycleLength=0)

Constructs the initializer with delay and optional cycle length. More...

Public Member Functions Index

template <typename... ComponentTypes>
voidinitialize (helios::engine::ecs::GameObject gameObject, const SpawnPlanCursor &cursor, const SpawnContext &spawnContext) override

Schedules delayed activation of the configured component types. More...

Private Member Attributes Index

template <typename... ComponentTypes>
const floatdelay_

Base delay in seconds between activations. More...

template <typename... ComponentTypes>
const size_tcycleLength_

Cycle length for repeating delay patterns. More...

template <typename... ComponentTypes>
std::vector< helios::engine::ecs::types::ComponentTypeId >deferredComponents_

Type IDs of components whose activation should be deferred. More...

Description

Initializer that schedules delayed activation of arbitrary components.

DelayedComponentEnablerInitializer defers the activation of specified components until a calculated delay has elapsed. This enables gameplay patterns such as:

  • **Collision immunity:** Newly spawned entities ignore collisions briefly
  • **Visibility fade-in:** Rendering components activate after spawn animation
  • **AI activation:** Behavior components enable after entity is fully placed
  • **Staggered waves:** Sequential spawns activate progressively

The delay for each entity is calculated as: `delay = (batchPosition + 1) * baseDelay`

An optional cycle length resets the batch position via modulo, useful for repeating spawn patterns where delay should not grow indefinitely.

Template Parameters
ComponentTypes

The component types whose activation should be deferred.

info

The entity must have a DelayedComponentEnabler component attached. The specified ComponentTypes must exist on the entity.

See Also

SpawnInitializer

See Also

DelayedComponentEnabler

Definition at line 51 of file DelayedComponentEnablerInitializer.ixx.

Public Constructors

DelayedComponentEnablerInitializer()

template <typename... ComponentTypes>
helios::engine::runtime::spawn::behavior::initializers::DelayedComponentEnablerInitializer< ComponentTypes >::DelayedComponentEnablerInitializer (const float delay, const size_t cycleLength=0)
inline

Constructs the initializer with delay and optional cycle length.

Parameters
delay

Base delay in seconds between each activation step.

cycleLength

Number of positions before the delay pattern repeats. Zero means no cycling (default).

Definition at line 80 of file DelayedComponentEnablerInitializer.ixx.

80 DelayedComponentEnablerInitializer(const float delay, const size_t cycleLength = 0) :
81 delay_(delay),
82 cycleLength_(cycleLength),
83 deferredComponents_{helios::engine::ecs::types::ComponentTypeId::id<ComponentTypes>() ...}
84 {}

Public Member Functions

initialize()

template <typename... ComponentTypes>
void helios::engine::runtime::spawn::behavior::initializers::DelayedComponentEnablerInitializer< ComponentTypes >::initialize (helios::engine::ecs::GameObject gameObject, const SpawnPlanCursor & cursor, const SpawnContext & spawnContext)
inline virtual

Schedules delayed activation of the configured component types.

Searches the entity's components for matches against the template ComponentTypes. Each matching component is registered with the entity's DelayedComponentEnabler for deferred activation. The delay duration depends on the spawn batch position and the configured base delay.

Parameters
gameObject

The entity to initialize.

cursor

Provides batch position for delay calculation.

spawnContext

Context data (unused).

Definition at line 98 of file DelayedComponentEnablerInitializer.ixx.

100 const SpawnPlanCursor& cursor,
101 const SpawnContext& spawnContext
102 ) override {
103
104 bool deferFound = false;
105
106 auto position = cycleLength_ != 0 ? cursor.position % cycleLength_ : cursor.position;
107
108 for (auto typeId : gameObject.componentTypeIds()) {
109
110 // Find the component that should be deferred.
111 const bool deferThisComponent = std::find(
112 deferredComponents_.begin(), deferredComponents_.end(), typeId
113 ) != deferredComponents_.end();
114
115 if (deferThisComponent) {
116 deferFound = true;
118 assert(dec && "Missing DelayedComponentEnabler");
119
120 dec->defer(gameObject, typeId, (position + 1) * delay_);
121 }
122 }
123
124 assert(deferFound && "Unexpected missing deferrable component");
125 }

References helios::engine::ecs::GameObject::componentTypeIds, helios::engine::ecs::GameObject::get and helios::engine::runtime::spawn::types::SpawnPlanCursor::position.

Private Member Attributes

cycleLength_

template <typename... ComponentTypes>
const size_t helios::engine::runtime::spawn::behavior::initializers::DelayedComponentEnablerInitializer< ComponentTypes >::cycleLength_

Cycle length for repeating delay patterns.

If non-zero, position indices wrap around after this many spawns. If zero, positions increase indefinitely.

Definition at line 64 of file DelayedComponentEnablerInitializer.ixx.

64 const size_t cycleLength_;

deferredComponents_

template <typename... ComponentTypes>
std::vector<helios::engine::ecs::types::ComponentTypeId> helios::engine::runtime::spawn::behavior::initializers::DelayedComponentEnablerInitializer< ComponentTypes >::deferredComponents_

Type IDs of components whose activation should be deferred.

Definition at line 69 of file DelayedComponentEnablerInitializer.ixx.

69 std::vector<helios::engine::ecs::types::ComponentTypeId> deferredComponents_;

delay_

template <typename... ComponentTypes>
const float helios::engine::runtime::spawn::behavior::initializers::DelayedComponentEnablerInitializer< ComponentTypes >::delay_

Base delay in seconds between activations.

Definition at line 56 of file DelayedComponentEnablerInitializer.ixx.

56 const float delay_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.