GameWorld Class
Runtime root object coordinating world domains, resources, and frame services. More...
Declaration
Public Constructors Index
| GameWorld (JobSystem &jobSystem, 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... | |
| JobSystem & | jobSystem () |
|
Returns a reference to the job system used for parallel task execution. 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 | 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... | |
| ManagerRegistry & | managerRegistry () noexcept |
|
Returns direct access to the manager registry. More... | |
template <typename THandle> | |
| auto & | entityManager () noexcept |
|
Returns direct access to the entity manager for a specific handle type. 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... | |
| JobSystem & | jobSystem_ |
|
Reference to the job system used for parallel task execution. 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 68 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 138 of file GameWorld.ixx.
GameWorld()
Non-copyable, non-movable.
Definition at line 147 of file GameWorld.ixx.
GameWorld()
Definition at line 149 of file GameWorld.ixx.
Public Operators
operator=()
Definition at line 148 of file GameWorld.ixx.
operator=()
Definition at line 150 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 504 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 351 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 529 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 382 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 520 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 463 of file GameWorld.ixx.
Reference engineWorld_.
Referenced by helios::engine::runtime::gameloop::GameLoop::update.
entityManager()
| inline noexcept |
Returns direct access to the entity manager for a specific handle type.
- Template Parameters
-
THandle Handle type.
- Returns
Reference to the internal EntityManager for the specified handle type.
Definition at line 550 of file GameWorld.ixx.
References engineWorld_ and helios::engine::runtime::registerComponents.
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 490 of file GameWorld.ixx.
References engineWorld_ and helios::engine::runtime::registerComponents.
gameObjectWorld()
| inline noexcept |
Returns the game-object domain world.
- Returns
Reference to GameObjectWorld.
Definition at line 453 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 253 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 240 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 190 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::commandBuffers, commandHandlerRegistry_, init, helios::engine::runtime::world::ResourceRegistry::managerRegistry, helios::engine::runtime::world::ResourceRegistry::managers, helios::engine::runtime::registerComponents and resourceRegistry_.
Referenced by init.
jobSystem()
| inline |
Returns a reference to the job system used for parallel task execution.
- Returns
Reference to the JobSystem.
Definition at line 166 of file GameWorld.ixx.
Reference jobSystem_.
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 227 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 308 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::get, helios::engine::runtime::world::ResourceRegistry::has, helios::engine::runtime::registerComponents and resourceRegistry_.
managerRegistry()
| inline noexcept |
Returns direct access to the manager registry.
- Returns
Reference to the internal ManagerRegistry.
Definition at line 539 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::managerRegistry and resourceRegistry.
Referenced by helios::engine::runtime::gameloop::GameLoop::onPassEnd.
platformWorld()
| inline noexcept |
Returns the platform-domain world.
- Returns
Reference to PlatformWorld.
Definition at line 426 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 293 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::emplace 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 373 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 273 of file GameWorld.ixx.
References helios::engine::runtime::world::ResourceRegistry::emplace and resourceRegistry_.
renderResourceWorld()
| inline noexcept |
Returns the render-resource domain world.
- Returns
Reference to RenderResourceWorld.
Definition at line 435 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 444 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 393 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 410 of file GameWorld.ixx.
Reference resourceRegistry_.
Referenced by commandBufferRegistry and managerRegistry.
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 417 of file GameWorld.ixx.
Reference resourceRegistry_.
runtimeEnvironment()
| inline |
Returns a reference to the current runtime platform.
- Returns
Reference to the Platform.
Definition at line 175 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 157 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 207 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 335 of file GameWorld.ixx.
References resourceRegistry_ and helios::engine::runtime::world::ResourceRegistry::tryGet.
Referenced by helios::engine::runtime::gameloop::Pass::registerCallableSystem and helios::engine::runtime::gameloop::Pass::registerTypedSystem.
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 322 of file GameWorld.ixx.
References resourceRegistry_ and helios::engine::runtime::world::ResourceRegistry::tryGet.
Referenced by helios::engine::runtime::gameloop::Pass::registerManagerFlush and helios::engine::runtime::gameloop::Pass::registerManagerParallelFlush.
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 476 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 108 of file GameWorld.ixx.
Referenced by commandHandlerRegistry, init and registerCommandHandler.
engineWorld_
| protected |
Aggregate multi-domain entity world.
Definition at line 113 of file GameWorld.ixx.
Referenced by destroy, engineWorld, entityManager, find, gameObjectWorld, platformWorld, renderResourceWorld, renderTargetWorld and view.
jobSystem_
| protected |
Reference to the job system used for parallel task execution.
Definition at line 128 of file GameWorld.ixx.
Referenced by jobSystem.
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 98 of file GameWorld.ixx.
Referenced by commandBuffer, hasCommandBuffer, hasManager, init, manager, registerCommandBuffer, registerManager, reset, resourceRegistry, resourceRegistry, tryCommandBuffer and tryManager.
runtimeEnvironment_
| protected |
Runtime environment facade for platform readiness state.
Definition at line 123 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 80 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.