GameWorld.ixx File
Central game state container for entities, resources, and the active level. More...
Included Headers
#include <cassert>
#include <format>
#include <helios/helios_config.h>
#include <memory>
#include <optional>
#include <span>
#include <string>
#include <unordered_map>
#include <helios.engine.common.concepts>
#include <helios.engine.runtime.world.Session>
#include <helios.engine.runtime.messaging.command.CommandHandlerRegistry>
#include <helios.util.log.LogManager>
#include <helios.util.log.Logger>
#include <helios.engine.ecs.View>
#include <helios.engine.ecs.GameObject>
#include <helios.engine.runtime.world.Manager>
#include <helios.engine.runtime.world.ResourceRegistry>
#include <helios.util.Guid>
#include <helios.engine.ecs.EntityManager>
#include <helios.engine.runtime.world.UpdateContext>
#include <helios.engine.runtime.world.Level>
#include <helios.engine.ecs.EntityHandle>
#include <helios.engine.ecs.EntityRegistry>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | runtime |
|
Runtime infrastructure for game execution and lifecycle orchestration. More... | |
| namespace | world |
|
World state management, resource registry, and per-frame update context. More... | |
Classes Index
| class | GameWorld |
|
Central game state container for entities, resources, and the active level. 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 46 of file GameWorld.ixx.
46#define HELIOS_LOG_SCOPE "GameWorld"
File Listing
The file content with the documentation metadata removed is:
43using namespace helios::engine::common::concepts;
44using namespace helios::engine::runtime::messaging::command;
46#define HELIOS_LOG_SCOPE "GameWorld"
47export namespace helios::engine::runtime::world {
141 inline static const helios::util::log::Logger& logger_ = helios::util::log::LogManager::loggerForScope(
142 HELIOS_LOG_SCOPE);
185 mutable helios::engine::ecs::EntityManager em_;
208 : em_(helios::engine::ecs::EntityManager(entityRegistry_, capacity)),
209 session_(Session(addGameObject()))
228 return session_;
236 [[nodiscard]] helios::engine::ecs::EntityManager& entityManager() {
237 return em_;
248 for (auto& mgr : resourceRegistry_.managers()) {
268 return level_ != nullptr;
279 return level_.get();
291 [[nodiscard]] bool hasManager() const {
292 return resourceRegistry_.has<T>();
304 [[nodiscard]] bool hasCommandBuffer() const {
305 return resourceRegistry_.has<T>();
324 T& registerManager(Args&&... args) {
325 return resourceRegistry_.emplace<T>(std::forward<Args>(args)...);
344 T& registerCommandBuffer(Args&&... args) {
345 return resourceRegistry_.emplace<T>(std::forward<Args>(args)...);
360 assert(resourceRegistry_.has<T>(), "Manager not registered");
361 return resourceRegistry_.get<T>();
373 T* tryManager() const noexcept {
374 return resourceRegistry_.tryGet<T>();
386 T* tryCommandBuffer() const noexcept {
387 return resourceRegistry_.tryGet<T>();
402 T& commandBuffer() const noexcept {
403 return resourceRegistry_.get<T>();
424 void registerCommandHandler(OwningT& owner) {
425 (commandHandlerRegistry_.template registerHandler<CommandType>(owner), ...);
433 [[nodiscard]] CommandHandlerRegistry& commandHandlerRegistry() noexcept {
434 return commandHandlerRegistry_;
446 void flushManagers(UpdateContext& updateContext) {
447 for (auto& mgr : resourceRegistry_.managers()) {
461 void flushCommandBuffers(UpdateContext& updateContext) {
462 for (auto& buff : resourceRegistry_.commandBuffers()) {
479 [[nodiscard]] helios::engine::ecs::GameObject addGameObject() {
480 const auto handle = em_.create();
481 return helios::engine::ecs::GameObject(handle, &em_);
509 return helios::engine::ecs::View<Components...>(&em_);
521 return helios::engine::ecs::View<const Components...>(&em_);
534 [[nodiscard]] std::optional<helios::engine::ecs::GameObject> find(const helios::engine::ecs::EntityHandle handle) {
535 if (!em_.isValid(handle)) {
539 return helios::engine::ecs::GameObject(handle, &em_);
554 [[nodiscard]] bool destroy(const helios::engine::ecs::EntityHandle handle) {
555 return em_.destroy(handle);
565 [[nodiscard]] std::optional<helios::engine::ecs::GameObject> find(const helios::engine::ecs::EntityHandle handle) const {
567 if (!em_.isValid(handle)) {
571 return helios::engine::ecs::GameObject(handle, &em_);
587 [[nodiscard]] helios::engine::ecs::GameObject clone(const helios::engine::ecs::GameObject gameObject) {
589 auto newGo = addGameObject();
593 em_.clone(gameObject.entityHandle(), newGo.entityHandle());
607 for (auto& mgr : resourceRegistry_.managers()) {
611 session_.reset();
624 ResourceRegistry& resourceRegistry() noexcept {
625 return resourceRegistry_;
631 const ResourceRegistry& resourceRegistry() const noexcept {
632 return resourceRegistry_;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.