GameWorld Class
Runtime root object coordinating world domains, resources, and frame services. More...
Declaration
Public Constructors Index
| GameWorld (const size_t capacity=ENTITY_MANAGER_DEFAULT_CAPACITY) | |
|
Constructs GameWorld and creates internal session/environment entities. More... | |
| GameWorld (const GameWorld &)=delete | |
|
Non-copyable, non-movable. More... | |
| GameWorld (const GameWorld &&)=delete | |
Public Operators Index
| GameWorld | operator= (const GameWorld &)=delete |
| GameWorld | operator= (const GameWorld &&)=delete |
Public Member Functions Index
| Session & | session () |
|
Returns a reference to the current game session. More... | |
| RuntimeEnvironment & | runtimeEnvironment () |
|
Returns a reference to the current runtime platform. More... | |
| GameWorld & | init () |
|
Initializes managers and command buffers. More... | |
| void | setLevel (std::unique_ptr< Level > level) noexcept |
|
Sets the current level for the game world. More... | |
| bool | hasLevel () const noexcept |
|
Checks if a level is currently loaded. More... | |
| const Level * | level () const noexcept |
|
Retrieves the currently loaded level. More... | |
template <typename T> | |
| bool | hasManager () const |
template <typename T> | |
| bool | hasCommandBuffer () const |
|
Checks whether a CommandBuffer of type T is registered. More... | |
template <typename T, typename... Args> | |
| T & | registerManager (Args &&... args) |
template <typename T, typename... Args> | |
| T & | registerCommandBuffer (Args &&... args) |
|
Registers and constructs a CommandBuffer of type T. More... | |
template <typename T> | |
| T & | manager () const noexcept |
template <typename T> | |
| T * | tryManager () const noexcept |
|
Retrieves a registered Manager by type, or nullptr if not found. More... | |
template <typename T> | |
| T * | tryCommandBuffer () const noexcept |
|
Retrieves a registered CommandBuffer by type, or nullptr if not found. More... | |
template <typename T> | |
| T & | commandBuffer () const noexcept |
|
Retrieves a registered CommandBuffer by type. More... | |
template <typename... CommandType, typename OwningT> | |
| void | registerCommandHandler (OwningT &owner) |
|
Registers a command handler for one or more command types. More... | |
| CommandHandlerRegistry & | commandHandlerRegistry () noexcept |
|
Returns a reference to the CommandHandlerRegistry. More... | |
| void | flushManagers (UpdateContext &updateContext) |
|
Flushes all registered Managers. More... | |
| void | flushCommandBuffers (UpdateContext &updateContext) |
|
Flushes all registered CommandBuffers. More... | |
| void | reset () |
|
Resets all managers and the session to their initial state. More... | |
| ResourceRegistry & | resourceRegistry () noexcept |
|
Returns a reference to the ResourceRegistry. More... | |
| const ResourceRegistry & | resourceRegistry () const noexcept |
|
Returns a reference to the ResourceRegistry. More... | |
| PlatformWorld & | platformWorld () noexcept |
|
Returns the platform-domain world. More... | |
| RenderResourceWorld & | renderResourceWorld () noexcept |
|
Returns the render-resource domain world. More... | |
| RenderTargetWorld & | renderTargetWorld () noexcept |
|
Returns the render-target domain world. More... | |
| GameObjectWorld & | gameObjectWorld () noexcept |
|
Returns the game-object domain world. More... | |
| EngineWorld & | engineWorld () noexcept |
|
Returns the aggregate typed world used for handle-routed operations. More... | |
template <typename THandle, typename... Components> | |
| auto | view () |
|
Builds a typed ECS view for a handle domain and component set. More... | |
template <typename THandle> | |
| auto | find (const THandle handle) noexcept |
|
Finds an entity facade by handle. More... | |
template <typename THandle> | |
| auto | add (const typename THandle::StrongId_type strongId=typename THandle::StrongId_type{}, const bool isActive=true) noexcept |
|
Adds a new entity in the domain inferred from THandle. More... | |
template <typename THandle> | |
| auto | destroy (const THandle handle) noexcept |
|
Destroys an entity in the domain inferred from THandle. More... | |
| helios::engine::runtime::messaging::command::CommandBufferRegistry & | commandBufferRegistry () noexcept |
|
Returns direct access to the command-buffer registry. More... | |
Protected Member Attributes Index
| std::unique_ptr< Level > | level_ = nullptr |
|
The current level loaded in the game world. More... | |
| ResourceRegistry | resourceRegistry_ |
|
Type-indexed registry for Managers and CommandBuffers. More... | |
| CommandHandlerRegistry | commandHandlerRegistry_ |
|
Registry mapping command types to their handler function pointers. More... | |
| EngineWorld | engineWorld_ {} |
|
Aggregate multi-domain entity world. More... | |
| Session | session_ |
| RuntimeEnvironment | runtimeEnvironment_ |
|
Runtime environment facade for platform readiness state. More... | |
Protected Static Attributes Index
| static const helios::engine::util::log::Logger & | logger_ = ... |
Description
Runtime root object coordinating world domains, resources, and frame services.
GameWorld owns the EngineWorld (entity domains), Session, RuntimeEnvironment, and runtime registries for managers/command buffers. It also exposes typed convenience APIs (add, find, view, destroy) that delegate to EngineWorld.
Definition at line 70 of file GameWorld.ixx.
Public Constructors
GameWorld()
| inline explicit |
Constructs GameWorld and creates internal session/environment entities.
The constructor creates one game-object entity for Session and one platform entity for RuntimeEnvironment.
Definition at line 136 of file GameWorld.ixx.
GameWorld()
Non-copyable, non-movable.
Definition at line 144 of file GameWorld.ixx.
GameWorld()
Definition at line 146 of file GameWorld.ixx.
Public Operators
operator=()
Definition at line 145 of file GameWorld.ixx.
operator=()
Definition at line 147 of file GameWorld.ixx.
Public Member Functions
add()
| inline noexcept |
Adds a new entity in the domain inferred from THandle.
- Template Parameters
-
THandle Handle type.
- Parameters
-
strongId Optional strong id value used by the handle domain.
- Returns
Domain-specific entity facade for the created entity.
Definition at line 523 of file GameWorld.ixx.
commandBuffer()
| inline noexcept |
Retrieves a registered CommandBuffer by type.
- Template Parameters
-
T The CommandBuffer type. Must satisfy IsCommandBufferLike.
- Precondition
A CommandBuffer of type T must already be registered. Use tryCommandBuffer<T>() when the buffer is optional.
- Returns
Reference to the CommandBuffer.
Definition at line 340 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::get and resourceRegistry_.
commandBufferRegistry()
| inline noexcept |
Returns direct access to the command-buffer registry.
- Returns
Reference to the internal CommandBufferRegistry.
Definition at line 548 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::commandBufferRegistry and resourceRegistry.
commandHandlerRegistry()
| inline noexcept |
Returns a reference to the CommandHandlerRegistry.
- Returns
Reference to the CommandHandlerRegistry.
Definition at line 371 of file GameWorld.ixx.
Reference commandHandlerRegistry_.
destroy()
| inline noexcept |
Destroys an entity in the domain inferred from THandle.
- Template Parameters
-
THandle Handle type.
- Parameters
-
handle Entity handle to destroy.
- Returns
Domain-specific destroy result.
Definition at line 539 of file GameWorld.ixx.
References engineWorld_ and helios::engine::runtime::registerComponents.
engineWorld()
| inline noexcept |
Returns the aggregate typed world used for handle-routed operations.
- Returns
Reference to EngineWorld.
Definition at line 482 of file GameWorld.ixx.
Reference engineWorld_.
Referenced by helios::engine::runtime::gameloop::GameLoop::update.
find()
| inline noexcept |
Finds an entity facade by handle.
- Template Parameters
-
THandle Handle type.
- Parameters
-
handle Entity handle to resolve.
- Returns
Domain-specific entity facade (or empty facade if not found).
Definition at line 509 of file GameWorld.ixx.
References engineWorld_ and helios::engine::runtime::registerComponents.
flushCommandBuffers()
| inline |
Flushes all registered CommandBuffers.
Iterates over all CommandBuffers in registration order and invokes flush(updateContext) on each. Called by the GameLoop at commit points before Managers are flushed.
- Parameters
-
updateContext The current frame's update context.
Definition at line 399 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::commandBuffers, helios::engine::runtime::registerComponents and resourceRegistry_.
Referenced by helios::engine::runtime::gameloop::GameLoop::onPassCommit and helios::engine::runtime::gameloop::GameLoop::phaseCommit.
flushManagers()
| inline |
Flushes all registered Managers.
Iterates over all Managers in registration order and invokes flush(updateContext) on each. Called by the GameLoop at commit points after the CommandBuffer has been flushed.
- Parameters
-
updateContext The current frame's update context.
Definition at line 384 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::managers, helios::engine::runtime::registerComponents and resourceRegistry_.
Referenced by helios::engine::runtime::gameloop::GameLoop::onPassCommit and helios::engine::runtime::gameloop::GameLoop::phaseCommit.
gameObjectWorld()
| inline noexcept |
Returns the game-object domain world.
- Returns
Reference to GameObjectWorld.
Definition at line 472 of file GameWorld.ixx.
References engineWorld_ and helios::engine::runtime::world::EngineWorld::gameObjectWorld.
hasCommandBuffer()
| inline |
Checks whether a CommandBuffer of type T is registered.
- Template Parameters
-
T The CommandBuffer type. Must satisfy IsCommandBufferLike.
- Returns
True if the CommandBuffer is registered.
Definition at line 242 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::has and resourceRegistry_.
hasLevel()
| inline noexcept |
hasManager()
| inline |
Checks whether a Manager of type T is registered.
- Template Parameters
-
T The Manager type. Must satisfy IsManagerLike.
- Returns
True if the Manager is registered.
Definition at line 229 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::has and resourceRegistry_.
init()
| inline |
Initializes managers and command buffers.
Should be called after all resources have been registered and before the game loop starts. Manager init() receives the CommandHandlerRegistry so managers can register command handlers without a hard GameWorld dependency. Command buffers are initialized afterward and bound to the same handler registry.
Definition at line 178 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::commandBuffers, commandHandlerRegistry_, helios::engine::runtime::world::ResourceRegistry::get, init, helios::engine::runtime::world::ResourceRegistry::managers, helios::engine::runtime::registerComponents, resourceRegistry_ and helios::engine::runtime::world::ResourceRegistry::tryGet.
Referenced by init.
level()
| inline noexcept |
Retrieves the currently loaded level.
- Returns
Const pointer to the active Level.
Calling this method when hasLevel() returns false results in undefined behavior.
Definition at line 216 of file GameWorld.ixx.
Reference level_.
Referenced by setLevel and helios::engine::runtime::gameloop::GameLoop::update.
manager()
| inline noexcept |
Retrieves a registered Manager by type.
- Template Parameters
-
T The Manager type. Must satisfy IsManagerLike.
- Returns
Reference to the Manager.
- Precondition
A Manager of type T must be registered.
Definition at line 297 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::get, helios::engine::runtime::world::ResourceRegistry::has, helios::engine::runtime::registerComponents and resourceRegistry_.
platformWorld()
| inline noexcept |
Returns the platform-domain world.
- Returns
Reference to PlatformWorld.
Definition at line 445 of file GameWorld.ixx.
References engineWorld_ and helios::engine::runtime::world::EngineWorld::platformWorld.
registerCommandBuffer()
| inline |
Registers and constructs a CommandBuffer of type T.
Delegates to ResourceRegistry::emplace. The buffer is constructed in-place with forwarded arguments and owned by the CommandBufferRegistry.
- Template Parameters
-
T The CommandBuffer type. Must satisfy IsCommandBufferLike.
Args Constructor argument types.
- Parameters
-
args Arguments forwarded to the T constructor.
- Returns
Reference to the newly registered CommandBuffer.
Definition at line 282 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::emplace, helios::engine::runtime::registerComponents and resourceRegistry_.
registerCommandHandler()
| inline |
Registers a command handler for one or more command types.
Stores a type-erased function pointer for each CommandType that routes to owner.submit(cmd). During flush, the TypedCommandBuffer uses the CommandHandlerRegistry to dispatch queued commands to the registered handler.
- Template Parameters
-
CommandType The command types to register handlers for.
OwningT The handler type. Must satisfy IsCommandHandlerLike.
- Parameters
-
owner Reference to the handler instance. Must outlive the GameWorld.
- See Also
CommandHandlerRegistry
Definition at line 362 of file GameWorld.ixx.
References commandHandlerRegistry_ and helios::engine::runtime::registerComponents.
registerManager()
| inline |
Registers and constructs a Manager of type T.
Delegates to ResourceRegistry::emplace. The Manager is constructed in-place with forwarded arguments and owned by the ManagerRegistry.
- Template Parameters
-
T The Manager type. Must satisfy IsManagerLike.
Args Constructor argument types.
- Parameters
-
args Arguments forwarded to the T constructor.
- Returns
Reference to the newly registered Manager.
Definition at line 262 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::emplace, helios::engine::runtime::registerComponents and resourceRegistry_.
renderResourceWorld()
| inline noexcept |
Returns the render-resource domain world.
- Returns
Reference to RenderResourceWorld.
Definition at line 454 of file GameWorld.ixx.
References engineWorld_ and helios::engine::runtime::world::EngineWorld::renderResourceWorld.
renderTargetWorld()
| inline noexcept |
Returns the render-target domain world.
- Returns
Reference to RenderTargetWorld.
Definition at line 463 of file GameWorld.ixx.
References engineWorld_ and helios::engine::runtime::world::EngineWorld::renderTargetWorld.
reset()
| inline |
Resets all managers and the session to their initial state.
Called during level transitions or game restarts to clear accumulated state. Invokes reset() on all managers and the session.
Definition at line 411 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::managers, helios::engine::runtime::registerComponents, helios::engine::runtime::world::Session::reset, resourceRegistry_ and session_.
resourceRegistry()
| inline noexcept |
Returns a reference to the ResourceRegistry.
Use for direct resource access. Prefer the convenience methods registerManager(), registerCommandBuffer(), manager(), tryManager(), and tryCommandBuffer() for type-constrained access.
- Returns
Reference to the ResourceRegistry.
Definition at line 429 of file GameWorld.ixx.
Reference resourceRegistry_.
Referenced by commandBufferRegistry.
resourceRegistry()
| inline noexcept |
Returns a reference to the ResourceRegistry.
Use for direct resource access. Prefer the convenience methods registerManager(), registerCommandBuffer(), manager(), tryManager(), and tryCommandBuffer() for type-constrained access.
- Returns
Reference to the ResourceRegistry.
Definition at line 436 of file GameWorld.ixx.
Reference resourceRegistry_.
runtimeEnvironment()
| inline |
Returns a reference to the current runtime platform.
- Returns
Reference to the Platform.
Definition at line 163 of file GameWorld.ixx.
Reference runtimeEnvironment_.
Referenced by helios::engine::runtime::gameloop::GameLoop::update.
session()
| inline |
Returns a reference to the current game session.
- Returns
Reference to the Session.
Definition at line 154 of file GameWorld.ixx.
Reference session_.
Referenced by helios::engine::runtime::gameloop::GameLoop::isRunning and helios::engine::runtime::gameloop::GameLoop::update.
setLevel()
| inline noexcept |
Sets the current level for the game world.
Definition at line 196 of file GameWorld.ixx.
tryCommandBuffer()
| inline noexcept |
Retrieves a registered CommandBuffer by type, or nullptr if not found.
- Template Parameters
-
T The CommandBuffer type. Must satisfy IsCommandBufferLike.
- Returns
Pointer to the CommandBuffer, or nullptr if not registered.
Definition at line 324 of file GameWorld.ixx.
References resourceRegistry_ and helios::engine::runtime::world::ResourceRegistry::tryGet.
Referenced by helios::engine::runtime::gameloop::Pass::addSystem.
tryManager()
| inline noexcept |
Retrieves a registered Manager by type, or nullptr if not found.
- Template Parameters
-
T The Manager type. Must satisfy IsManagerLike.
- Returns
Pointer to the Manager, or nullptr if not registered.
Definition at line 311 of file GameWorld.ixx.
References resourceRegistry_ and helios::engine::runtime::world::ResourceRegistry::tryGet.
view()
| inline |
Builds a typed ECS view for a handle domain and component set.
- Template Parameters
-
THandle Handle domain type.
Components Component types to include.
- Returns
Domain-specific view.
Definition at line 495 of file GameWorld.ixx.
References engineWorld_, helios::engine::runtime::registerComponents and helios::engine::runtime::world::EngineWorld::view.
Protected Member Attributes
commandHandlerRegistry_
| protected |
Registry mapping command types to their handler function pointers.
Used by TypedCommandBuffer during flush to route commands to the correct handler. Handlers are usually registered by managers in init(CommandHandlerRegistry&); direct registration via registerCommandHandler<CommandTypes...>(owner) is still supported.
Definition at line 110 of file GameWorld.ixx.
Referenced by commandHandlerRegistry, init and registerCommandHandler.
engineWorld_
| protected |
Aggregate multi-domain entity world.
Definition at line 115 of file GameWorld.ixx.
Referenced by destroy, engineWorld, find, gameObjectWorld, platformWorld, renderResourceWorld, renderTargetWorld and view.
level_
| protected |
resourceRegistry_
| protected |
Type-indexed registry for Managers and CommandBuffers.
Provides O(1) type-based access via ManagerRegistry and CommandBufferRegistry. Owns all registered Manager and CommandBuffer instances via ConceptModelRegistry.
Definition at line 100 of file GameWorld.ixx.
Referenced by commandBuffer, flushCommandBuffers, flushManagers, hasCommandBuffer, hasManager, init, manager, registerCommandBuffer, registerManager, reset, resourceRegistry, resourceRegistry, tryCommandBuffer and tryManager.
runtimeEnvironment_
| protected |
Runtime environment facade for platform readiness state.
Definition at line 125 of file GameWorld.ixx.
Referenced by runtimeEnvironment.
session_
Protected Static Attributes
logger_
| protected static |
The logger used with this GameWorld instance.
- Initialiser
Defaults to HELIOS_LOG_SCOPE.
Definition at line 82 of file GameWorld.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.