GameWorld.ixx File
Central game state container for entities, resources, and the active level. More...
Included Headers
#include <cassert>
#include <format>
#include <helios-engine-config.h>
#include <memory>
#include <optional>
#include <span>
#include <string>
#include <unordered_map>
#include <cstddef>
#include <helios.engine.runtime.world.EngineWorld>
#include <helios.ecs.EntityManager>
#include <helios.ecs.types.EntityHandle>
#include <helios.engine.util.log.LogManager>
#include <helios.engine.util.log.Logger>
#include <helios.engine.util.Guid>
#include <helios.engine.runtime.world.RuntimeEnvironment>
#include <helios.engine.runtime.timing.TimerManager>
#include <helios.engine.runtime.world.types.GameObjectId>
#include <helios.engine.runtime.messaging.command.concepts>
#include <helios.engine.runtime.world.Session>
#include <helios.engine.platform.environment.types>
#include <helios.engine.runtime.world.concepts>
#include <helios.engine.runtime.messaging.command.CommandHandlerRegistry>
#include <helios.engine.runtime.messaging.command.CommandBufferRegistry>
#include <helios.engine.runtime.world.ResourceRegistry>
#include <helios.ecs.View>
#include <helios.engine.runtime.world.UpdateContext>
#include <helios.ecs.Entity>
#include <helios.engine.runtime.world.GameObject>
#include <helios.ecs.EntityRegistry>
#include <helios.engine.runtime.world.types.GameObjectHandle>
#include <helios.engine.runtime.world.Level>
#include <helios.engine.runtime.world.Manager>
Namespaces Index
| namespace | helios |
| namespace | engine |
| namespace | runtime |
| namespace | world |
Classes Index
| class | GameWorld |
|
Runtime root object coordinating world domains, resources, and frame services. More... | |
Macro Definitions Index
| #define | HELIOS_LOG_SCOPE "GameWorld" |
Description
Central game state container for entities, resources, and the active level.
Macro Definitions
HELIOS_LOG_SCOPE
|
Definition at line 59 of file GameWorld.ixx.
59#define HELIOS_LOG_SCOPE "GameWorld"
File Listing
The file content with the documentation metadata removed is:
9#include <helios-engine-config.h>
53using namespace helios::engine::runtime::timing;
55using namespace helios::engine::runtime::messaging::command;
57using namespace helios::engine::platform::environment::types;
58using namespace helios::engine::runtime::world::types;
59#define HELIOS_LOG_SCOPE "GameWorld"
60export namespace helios::engine::runtime::world {
82 inline static const helios::engine::util::log::Logger& logger_ = helios::engine::util::log::LogManager::loggerForScope(
83 HELIOS_LOG_SCOPE);
136 explicit GameWorld(const size_t capacity = ENTITY_MANAGER_DEFAULT_CAPACITY)
137 : session_(Session(engineWorld_.add<GameObjectHandle>())),
155 return session_;
163 [[nodiscard]] RuntimeEnvironment& runtimeEnvironment() {
164 return runtimeEnvironment_;
179 for (auto& mgr : resourceRegistry_.managers()) {
180 mgr->init(commandHandlerRegistry_);
183 assert(resourceRegistry_.tryGet<TimerManager>() && "TimerManager must be registered before initializing command buffers");
184 for (auto& buff : resourceRegistry_.commandBuffers()) {
185 buff->init(commandHandlerRegistry_, resourceRegistry_.get<TimerManager>());
206 return level_ != nullptr;
217 return level_.get();
228 requires IsManagerLike<T>
229 [[nodiscard]] bool hasManager() const {
230 return resourceRegistry_.has<T>();
241 requires IsCommandBufferLike<T>
242 [[nodiscard]] bool hasCommandBuffer() const {
243 return resourceRegistry_.has<T>();
260 template<typename T, typename... Args>
261 requires IsManagerLike<T>
262 T& registerManager(Args&&... args) {
263 return resourceRegistry_.emplace<T>(std::forward<Args>(args)...);
280 template<typename T, typename... Args>
281 requires IsCommandBufferLike<T>
282 T& registerCommandBuffer(Args&&... args) {
283 return resourceRegistry_.emplace<T>(std::forward<Args>(args)...);
296 requires IsManagerLike<T>
298 assert(resourceRegistry_.has<T>() && "Manager not registered");
299 return resourceRegistry_.get<T>();
310 requires IsManagerLike<T>
311 T* tryManager() const noexcept {
312 return resourceRegistry_.tryGet<T>();
323 requires IsCommandBufferLike<T>
324 T* tryCommandBuffer() const noexcept {
325 return resourceRegistry_.tryGet<T>();
339 requires IsCommandBufferLike<T>
340 T& commandBuffer() const noexcept {
341 return resourceRegistry_.get<T>();
360 template<typename... CommandType, typename OwningT>
361 requires IsCommandHandlerLike<OwningT, CommandType...>
362 void registerCommandHandler(OwningT& owner) {
363 (commandHandlerRegistry_.template registerHandler<CommandType>(owner), ...);
372 return commandHandlerRegistry_;
384 void flushManagers(UpdateContext& updateContext) {
385 for (auto& mgr : resourceRegistry_.managers()) {
386 mgr->flush(updateContext);
399 void flushCommandBuffers(UpdateContext& updateContext) {
400 for (auto& buff : resourceRegistry_.commandBuffers()) {
401 buff->flush(updateContext);
413 for (auto& mgr : resourceRegistry_.managers()) {
414 mgr->reset();
430 return resourceRegistry_;
436 const ResourceRegistry& resourceRegistry() const noexcept {
437 return resourceRegistry_;
445 [[nodiscard]] PlatformWorld& platformWorld() noexcept{
446 return engineWorld_.platformWorld();
455 return engineWorld_.renderResourceWorld();
464 return engineWorld_.renderTargetWorld();
473 return engineWorld_.gameObjectWorld();
482 [[nodiscard]] EngineWorld& engineWorld() noexcept{
483 return engineWorld_;
494 template <typename THandle, typename... Components>
496 return engineWorld_.view<THandle, Components...>();
510 return engineWorld_.template find<THandle>(handle);
523 [[nodiscard]] auto add(const typename THandle::StrongId_type strongId = typename THandle::StrongId_type{}, const bool isActive = true) noexcept {
524 auto entity = engineWorld_.template add<THandle>(strongId);
525 entity.setActive(isActive);
526 return entity;
540 return engineWorld_.template destroy<THandle>(handle);
548 helios::engine::runtime::messaging::command::CommandBufferRegistry& commandBufferRegistry() noexcept {
549 return resourceRegistry().commandBufferRegistry();
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.