Skip to main content

GameWorld.ixx File

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

Included Headers

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 57 of file GameWorld.ixx.

57#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 <span>
12#include <string>
13
14export module helios.engine.runtime.world.GameWorld;
15
16import helios.engine.runtime.world.Session;
17
18import helios.engine.core.thread.JobSystem;
19
20import helios.engine.runtime.timing.TimerManager;
21
22import helios.ecs.Entity;
23import helios.engine.runtime.world.RuntimeEnvironment;
24import helios.engine.platform.environment.types;
25
26import helios.engine.runtime.messaging.command.CommandHandlerRegistry;
27import helios.engine.runtime.messaging.command.CommandBufferRegistry;
28
29import helios.engine.runtime.world.ManagerRegistry;
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.View;
44
45import helios.engine.runtime.messaging.command.concepts;
46
47import helios.engine.runtime.world.EngineWorld;
48import helios.engine.runtime.world.concepts;
49
50using namespace helios::engine::core::thread;
52using namespace helios::engine::runtime::messaging::command::concepts;
54using namespace helios::engine::runtime::world::concepts;
57#define HELIOS_LOG_SCOPE "GameWorld"
58export namespace helios::engine::runtime::world {
59
68 class GameWorld {
69
70
71
72 protected:
73
74
82
88 std::unique_ptr<Level> level_ = nullptr;
89
90
99
109
114
119
124
129
130 public:
131
142 {};
143
147 GameWorld(const GameWorld&) = delete;
148 GameWorld operator=(const GameWorld&) = delete;
149 GameWorld(const GameWorld&&) = delete;
150 GameWorld operator=(const GameWorld&&) = delete;
151
158 return session_;
159 }
160
167 return jobSystem_;
168 }
169
177 }
178
179
180
191 for (auto& mgr : resourceRegistry_.managers()) {
193 }
194
195 for (auto& buff : resourceRegistry_.commandBuffers()) {
197 }
198
199 return *this;
200 }
201
207 void setLevel(std::unique_ptr<Level> level) noexcept {
208 level_ = std::move(level);
209 }
210
217 return level_ != nullptr;
218 }
219
228 return level_.get();
229 }
230
238 template<typename T>
239 requires IsManagerLike<T>
240 [[nodiscard]] bool hasManager() const {
241 return resourceRegistry_.has<T>();
242 }
243
251 template<typename T>
253 [[nodiscard]] bool hasCommandBuffer() const {
254 return resourceRegistry_.has<T>();
255 }
256
271 template<typename T, typename... Args>
272 requires IsManagerLike<T>
273 T& registerManager(Args&&... args) {
274 return resourceRegistry_.emplace<T>(std::forward<Args>(args)...);
275 }
276
291 template<typename T, typename... Args>
294 return resourceRegistry_.emplace<T>(std::forward<Args>(args)...);
295 }
296
306 template<typename T>
307 requires IsManagerLike<T>
309 assert(resourceRegistry_.has<T>() && "Manager not registered");
310 return resourceRegistry_.get<T>();
311 }
312
320 template<typename T>
321 requires IsManagerLike<T>
323 return resourceRegistry_.tryGet<T>();
324 }
325
333 template<typename T>
336 return resourceRegistry_.tryGet<T>();
337 }
338
349 template<typename T>
352 return resourceRegistry_.get<T>();
353 }
354
355
371 template<typename... CommandType, typename OwningT>
372 requires IsCommandHandlerLike<OwningT, CommandType...>
375 }
376
384 }
385
386
393 void reset() {
394 for (auto& mgr : resourceRegistry_.managers()) {
395 mgr->reset();
396 }
397
399 }
400
411 return resourceRegistry_;
412 }
413
418 return resourceRegistry_;
419 }
420
428 }
429
437 }
438
446 }
447
455 }
456
457
464 return engineWorld_;
465 }
466
475 template <typename THandle, typename... Components>
476 [[nodiscard]] auto view() {
477 return engineWorld_.view<THandle, Components...>();
478 }
479
489 template<typename THandle>
490 [[nodiscard]] auto find(const THandle handle) noexcept {
491 return engineWorld_.template find<THandle>(handle);
492 }
493
503 template<typename THandle>
504 [[nodiscard]] auto add(const typename THandle::StrongId_type strongId = typename THandle::StrongId_type{}, const bool isActive = true) noexcept {
506 entity.setActive(isActive);
507 return entity;
508 }
509
519 template<typename THandle>
520 [[nodiscard]] auto destroy(const THandle handle) noexcept {
521 return engineWorld_.template destroy<THandle>(handle);
522 }
523
531 }
532
533
541 }
542
549 template<typename THandle>
551 return engineWorld_.template entityManager<THandle>();
552 }
553
554 };
555
556}
557

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.