Skip to main content

EmitterInitializer.ixx File

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

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespaceruntime

Runtime infrastructure for game execution and lifecycle orchestration. More...

namespacespawn

Entity spawning infrastructure for the helios engine. More...

namespacebehavior

Spawn behavior strategies for positioning and initializing entities. More...

namespaceinitializers

Concrete SpawnInitializer implementations. More...

Classes Index

classEmitterInitializer

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

Description

Initializer that configures spawned entities based on emitter state.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file EmitterInitializer.ixx
3 * @brief Initializer that configures spawned entities based on emitter state.
4 */
5module;
6
7#include <cassert>
8
9export module helios.engine.runtime.spawn.behavior.initializers.EmitterInitializer;
10
11import helios.engine.runtime.spawn.behavior.SpawnInitializer;
12import helios.engine.runtime.spawn.types.SpawnPlanCursor;
13import helios.engine.runtime.spawn.types.SpawnContext;
14import helios.engine.ecs.GameObject;
15import helios.engine.modules.physics.motion.components.Move2DComponent;
16import helios.engine.modules.physics.motion.components.DirectionComponent;
17import helios.engine.modules.physics.motion.components.SteeringComponent;
18
19
22
23 /**
24 * @brief Initializer that configures spawned entities based on emitter state.
25 *
26 * @details EmitterInitializer uses the velocity from the EmitterContext to
27 * set the direction and movement intent of spawned entities. This is commonly
28 * used for projectiles that should inherit direction from the firing entity.
29 *
30 * Components affected:
31 * - **Move2DComponent:** Sets move intent in emitter's direction
32 * - **DirectionComponent:** Sets direction to normalized emitter velocity
33 * - **SteeringComponent:** Sets steering intent in emitter's direction
34 *
35 * @pre The SpawnContext must contain a valid EmitterContext.
36 *
37 * @see SpawnInitializer
38 * @see EmitterContext
39 */
40 class EmitterInitializer final : public SpawnInitializer {
41
42 public:
43
44 /**
45 * @brief Initializes entity with emitter's velocity direction.
46 *
47 * @param gameObject The entity to initialize.
48 * @param cursor The current position within the spawn batch (unused).
49 * @param spawnContext Context containing the emitter information.
50 *
51 * @pre spawnContext.emitterContext must have a value.
52 */
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 }
77
78 };
79
80}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.