Skip to main content

EmitterInitializer Class

Initializer that configures spawned entities based on emitter state. More...

Declaration

class helios::engine::runtime::spawn::behavior::initializers::EmitterInitializer { ... }

Base class

classSpawnInitializer

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

Public Member Functions Index

voidinitialize (helios::engine::ecs::GameObject gameObject, const SpawnPlanCursor &cursor, const SpawnContext &spawnContext) override

Initializes entity with emitter's velocity direction. More...

Description

Initializer that configures spawned entities based on emitter state.

EmitterInitializer uses the velocity from the EmitterContext to set the direction and movement intent of spawned entities. This is commonly used for projectiles that should inherit direction from the firing entity.

Components affected:

  • **Move2DComponent:** Sets move intent in emitter's direction
  • **DirectionComponent:** Sets direction to normalized emitter velocity
  • **SteeringComponent:** Sets steering intent in emitter's direction
Precondition

The SpawnContext must contain a valid EmitterContext.

See Also

SpawnInitializer

See Also

EmitterContext

Definition at line 40 of file EmitterInitializer.ixx.

Public Member Functions

initialize()

void helios::engine::runtime::spawn::behavior::initializers::EmitterInitializer::initialize (helios::engine::ecs::GameObject gameObject, const SpawnPlanCursor & cursor, const SpawnContext & spawnContext)
inline virtual

Initializes entity with emitter's velocity direction.

Parameters
gameObject

The entity to initialize.

cursor

The current position within the spawn batch (unused).

spawnContext

Context containing the emitter information.

Precondition

spawnContext.emitterContext must have a value.

Definition at line 53 of file EmitterInitializer.ixx.

55 const SpawnPlanCursor& cursor,
56 const SpawnContext& spawnContext
57 ) override {
58
59 const auto& emitterContext = spawnContext.emitterContext;
60 assert(emitterContext.has_value() && "Unexpected missing value for emitterContext");
61
62 const auto velocity = emitterContext.value().velocity;
63 auto direction = velocity.normalize();
64
66 m2c->setMoveIntent(direction, 1.0f);
67 }
68
70 dc->setDirection(direction);
71 }
72
74 hc->setSteeringIntent(direction, 1.0f);
75 }
76 }

References helios::engine::runtime::spawn::types::SpawnContext::emitterContext and helios::engine::ecs::GameObject::get.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.