Skip to main content

InitializerList.ixx File

Composite initializer that chains multiple SpawnInitializers. 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

classInitializerList<N>

Composite initializer that executes multiple SpawnInitializers in sequence. More...

Description

Composite initializer that chains multiple SpawnInitializers.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file InitializerList.ixx
3 * @brief Composite initializer that chains multiple SpawnInitializers.
4 */
5module;
6
7#include <array>
8#include <memory>
9
10export module helios.engine.runtime.spawn.behavior.initializers.InitializerList;
11
12import helios.engine.runtime.spawn.behavior.SpawnInitializer;
13import helios.engine.runtime.spawn.SpawnPlanCursor;
14import helios.engine.runtime.spawn.SpawnContext;
15import helios.engine.ecs.GameObject;
16
17
19
20 /**
21 * @brief Composite initializer that executes multiple SpawnInitializers in sequence.
22 *
23 * @details InitializerList allows combining multiple initialization behaviors into
24 * a single initializer. Each initializer in the list is executed in order during
25 * the spawn process.
26 *
27 * **Usage:**
28 * ```cpp
29 * auto initializer = std::make_unique<InitializerList<2>>(
30 * std::make_unique<DirectionInitializer>(vec3f{1, 0, 0}),
31 * std::make_unique<VelocityInitializer>(100.0f)
32 * );
33 * ```
34 *
35 * @tparam N The number of initializers in the list. Must match the number of
36 * arguments passed to the constructor.
37 *
38 * @see SpawnInitializer
39 * @see SpawnContext
40 */
41 template<std::size_t N>
42 class InitializerList final : public SpawnInitializer {
43
44 /**
45 * @brief Fixed-size array of initializers to execute.
46 */
47 const std::array<std::unique_ptr<SpawnInitializer>, N> initializers_;
48
49 public:
50
51 /**
52 * @brief Constructs an InitializerList from variadic initializer arguments.
53 *
54 * @tparam Args Types of the initializer unique_ptrs.
55 *
56 * @param args Unique pointers to SpawnInitializer instances. The number of
57 * arguments must match the template parameter N.
58 */
59 template<typename... Args>
60 requires (sizeof...(Args) == N && (std::derived_from<Args, SpawnInitializer> && ...))
61 explicit InitializerList(std::unique_ptr<Args>&& ...args) : initializers_{std::move(args)...}{}
62
63 /**
64 * @brief Executes all initializers in sequence on the spawned GameObject.
65 *
66 * @param gameObject The GameObject being initialized.
67 * @param cursor The current spawn plan cursor with batch and index information.
68 * @param spawnContext Context providing access to spawn-related data.
69 */
72 const SpawnPlanCursor& cursor,
73 const SpawnContext& spawnContext
74 ) override {
75 for (std::size_t i = 0; i < initializers_.size(); ++i) {
76 initializers_[i]->initialize(
77 gameObject,
78 cursor,
79 spawnContext
80 );
81 }
82 }
83
84 };
85
86}
87
88

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.