Skip to main content

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

namespacehelios
namespaceengine
namespaceruntime
namespaceworld

Classes Index

classGameWorld

Runtime root object coordinating world domains, resources, and frame services. More...

Macro Definitions Index

#defineHELIOS_LOG_SCOPE   "GameWorld"

Description

Central game state container for entities, resources, and the active level.

Macro Definitions

HELIOS_LOG_SCOPE

#define HELIOS_LOG_SCOPE   "GameWorld"

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:

1
5module;
6
7#include <cassert>
8#include <format>
10#include <memory>
11#include <optional>
12#include <span>
13#include <string>
14#include <unordered_map>
15#include <cstddef>
16
17export module helios.engine.runtime.world.GameWorld;
18
19import helios.engine.runtime.world.Session;
20
21import helios.engine.runtime.timing.TimerManager;
22
23import helios.ecs.Entity;
24import helios.engine.runtime.world.RuntimeEnvironment;
25import helios.engine.platform.environment.types;
26
27import helios.engine.runtime.messaging.command.CommandHandlerRegistry;
28import helios.engine.runtime.messaging.command.CommandBufferRegistry;
29
30import helios.engine.runtime.world.ResourceRegistry;
31
32import helios.engine.runtime.world.UpdateContext;
33import helios.engine.runtime.world.GameObject;
34import helios.engine.runtime.world.types.GameObjectId;
35import helios.engine.runtime.world.types.GameObjectHandle;
36import helios.engine.runtime.world.Manager;
37
38import helios.engine.util.Guid;
39import helios.engine.util.log.Logger;
40import helios.engine.util.log.LogManager;
41import helios.engine.runtime.world.Level;
42
43import helios.ecs.types.EntityHandle;
44import helios.ecs.EntityManager;
45import helios.ecs.EntityRegistry;
46import helios.ecs.View;
47
48import helios.engine.runtime.messaging.command.concepts;
49
50import helios.engine.runtime.world.EngineWorld;
51import helios.engine.runtime.world.concepts;
52
54using namespace helios::engine::runtime::messaging::command::concepts;
56using namespace helios::engine::runtime::world::concepts;
59#define HELIOS_LOG_SCOPE "GameWorld"
60export namespace helios::engine::runtime::world {
61
70 class GameWorld {
71
72
73
74 protected:
75
76
84
90 std::unique_ptr<Level> level_ = nullptr;
91
92
101
111
116
121
126
127
128 public:
129
139 {};
140
144 GameWorld(const GameWorld&) = delete;
145 GameWorld operator=(const GameWorld&) = delete;
146 GameWorld(const GameWorld&&) = delete;
147 GameWorld operator=(const GameWorld&&) = delete;
148
155 return session_;
156 }
157
165 }
166
167
168
179 for (auto& mgr : resourceRegistry_.managers()) {
181 }
182
183 assert(resourceRegistry_.tryGet<TimerManager>() && "TimerManager must be registered before initializing command buffers");
184 for (auto& buff : resourceRegistry_.commandBuffers()) {
186 }
187
188 return *this;
189 }
190
196 void setLevel(std::unique_ptr<Level> level) noexcept {
197 level_ = std::move(level);
198 }
199
206 return level_ != nullptr;
207 }
208
217 return level_.get();
218 }
219
227 template<typename T>
228 requires IsManagerLike<T>
229 [[nodiscard]] bool hasManager() const {
230 return resourceRegistry_.has<T>();
231 }
232
240 template<typename T>
242 [[nodiscard]] bool hasCommandBuffer() const {
243 return resourceRegistry_.has<T>();
244 }
245
260 template<typename T, typename... Args>
261 requires IsManagerLike<T>
263 return resourceRegistry_.emplace<T>(std::forward<Args>(args)...);
264 }
265
280 template<typename T, typename... Args>
283 return resourceRegistry_.emplace<T>(std::forward<Args>(args)...);
284 }
285
295 template<typename T>
296 requires IsManagerLike<T>
298 assert(resourceRegistry_.has<T>() && "Manager not registered");
299 return resourceRegistry_.get<T>();
300 }
301
309 template<typename T>
310 requires IsManagerLike<T>
312 return resourceRegistry_.tryGet<T>();
313 }
314
322 template<typename T>
325 return resourceRegistry_.tryGet<T>();
326 }
327
338 template<typename T>
341 return resourceRegistry_.get<T>();
342 }
343
344
360 template<typename... CommandType, typename OwningT>
361 requires IsCommandHandlerLike<OwningT, CommandType...>
364 }
365
373 }
374
385 for (auto& mgr : resourceRegistry_.managers()) {
386 mgr->flush(updateContext);
387 }
388 }
389
400 for (auto& buff : resourceRegistry_.commandBuffers()) {
401 buff->flush(updateContext);
402 }
403 }
404
411 void reset() {
412
413 for (auto& mgr : resourceRegistry_.managers()) {
414 mgr->reset();
415 }
416
418 }
419
430 return resourceRegistry_;
431 }
432
437 return resourceRegistry_;
438 }
439
447 }
448
456 }
457
465 }
466
474 }
475
476
483 return engineWorld_;
484 }
485
494 template <typename THandle, typename... Components>
495 [[nodiscard]] auto view() {
496 return engineWorld_.view<THandle, Components...>();
497 }
498
508 template<typename THandle>
509 [[nodiscard]] auto find(const THandle handle) noexcept {
510 return engineWorld_.template find<THandle>(handle);
511 }
512
522 template<typename THandle>
523 [[nodiscard]] auto add(const typename THandle::StrongId_type strongId = typename THandle::StrongId_type{}, const bool isActive = true) noexcept {
525 entity.setActive(isActive);
526 return entity;
527 }
528
538 template<typename THandle>
539 [[nodiscard]] auto destroy(const THandle handle) noexcept {
540 return engineWorld_.template destroy<THandle>(handle);
541 }
542
550 }
551
552 };
553
554}
555

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.