Skip to main content

bootstrap.ixx File

Engine bootstrap: component registration and GameWorld/GameLoop factory. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

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

namespacebootstrap

Description

Engine bootstrap: component registration and GameWorld/GameLoop factory.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file bootstrap.ixx
3 * @brief Engine bootstrap: component registration and GameWorld/GameLoop factory.
4 */
5module;
6
7#include <utility>
8#include <memory>
9
10export module helios.engine.bootstrap;
11
12import helios.engine.runtime.gameloop;
13import helios.engine.runtime.world;
14
15import helios.engine.state.Bindings;
16import helios.engine.runtime.messaging.command;
17
18import helios.engine.mechanics.lifecycle;
19import helios.engine.mechanics.gamestate;
20import helios.engine.mechanics.match;
21
22import helios.engine.mechanics.registry;
23import helios.engine.modules.registry;
24import helios.engine.ecs.registry;
25
26
27
28export namespace helios::engine::bootstrap {
29
30 using namespace helios::engine::runtime::world;
32
33 /**
34 * @brief Registers all component types with the ComponentReflector.
35 *
36 * @details This function must be called during engine initialization to
37 * enable runtime reflection features such as cloning, lifecycle callbacks
38 * (onAcquire, onRelease, onRemove), and enable/disable toggles.
39 *
40 * ## Usage
41 *
42 * ```cpp
43 * // Call once during engine startup
44 * helios::engine::bootstrap::registerAllComponents();
45 * ```
46 *
47 * @note New component types must be added to the respective module's
48 * registry.ixx file to participate in the reflection system.
49 *
50 * @see ComponentReflector
51 * @see ComponentOpsRegistry
52 */
53 inline void registerAllComponents() {
54
55 static bool done = false;
56 if (done) return;
57 done = true;
58
62
63 }
64
65 /**
66 * @brief Creates a pre-configured GameWorld and GameLoop pair.
67 *
68 * @details The factory heap-allocates both objects and performs the
69 * minimal setup required before application-specific configuration:
70 *
71 * - Registers the `EngineCommandBuffer` with the GameWorld's
72 * ResourceRegistry.
73 * - Tracks `GameState` and `MatchState` in the Session so that
74 * TypedPass state filtering works out of the box.
75 *
76 * The caller receives ownership via `unique_ptr` and is responsible
77 * for registering Managers, configuring phases/passes, calling
78 * `GameWorld::init()` and `GameLoop::init()`, and driving the
79 * main loop.
80 *
81 * ## Usage
82 *
83 * ```cpp
84 * helios::engine::bootstrap::registerAllComponents();
85 *
86 * auto [gameWorldPtr, gameLoopPtr] = helios::engine::bootstrap::makeGameWorld();
87 * auto& gameWorld = *gameWorldPtr;
88 * auto& gameLoop = *gameLoopPtr;
89 *
90 * // Application-specific setup
91 * gameWorld.registerResource<SpawnManager>();
92 * gameLoop.phase(PhaseType::Pre)
93 * .addPass<GameState>(GameState::Any)
94 * .addSystem<InputSystem>();
95 *
96 * gameWorld.init();
97 * gameLoop.init(gameWorld);
98 * ```
99 *
100 * @return A pair of (GameWorld, GameLoop) unique pointers.
101 *
102 * @see registerAllComponents
103 * @see GameWorld
104 * @see GameLoop
105 * @see EngineCommandBuffer
106 * @see Session::trackState
107 */
108 inline std::pair<std::unique_ptr<GameWorld>, std::unique_ptr<GameLoop>> makeGameWorld() {
109 auto gameLoop = std::make_unique<helios::engine::runtime::gameloop::GameLoop>();
110 auto gameWorld = std::make_unique<helios::engine::runtime::world::GameWorld>();
111
113
119
120 gameWorld->session().trackState<helios::engine::mechanics::gamestate::types::GameState>();
121 gameWorld->session().trackState<helios::engine::mechanics::match::types::MatchState>();
122
123 return std::make_pair(std::move(gameWorld), std::move(gameLoop));
124 }
125
126}
127

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.