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

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.