Skip to main content

DelayedComponentEnablerSystem.ixx File

System that processes delayed component activations. More...

Included Headers

#include <vector> #include <helios.engine.runtime.world.tags.SystemRole> #include <helios.ecs.ComponentOpsRegistry> #include <helios.ecs.types.ComponentTypeId> #include <helios.engine.runtime.lifecycle.components.DelayedComponentEnabler> #include <helios.engine.runtime.world.UpdateContext> #include <helios.ecs.components.Active> #include <helios.engine.runtime.world.GameWorld>

Namespaces Index

namespacehelios
namespaceengine
namespaceruntime
namespacelifecycle
namespacesystems

Classes Index

classDelayedComponentEnablerSystem<THandle>

System that processes delayed component activations each frame. More...

Description

System that processes delayed component activations.

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7
8#include <vector>
9
10export module helios.engine.runtime.lifecycle.systems.DelayedComponentEnablerSystem;
11
12
13import helios.engine.runtime.world.GameWorld;
14import helios.engine.runtime.world.UpdateContext;
15import helios.engine.runtime.lifecycle.components.DelayedComponentEnabler;
16import helios.ecs.types.ComponentTypeId;
17
18import helios.ecs.ComponentOpsRegistry;
19
20import helios.ecs.components.Active;
21
22import helios.engine.runtime.world.tags.SystemRole;
23
25
43 template<typename THandle>
45
49 std::vector<helios::ecs::types::ComponentTypeId<THandle>> sync_;
50
51
52 public:
53
66
67 const float delta = updateContext.deltaTime();
68
69 for (auto [entity, dce, active] : updateContext.view<
72 helios::ecs::components::Active<THandle>
73 >().whereEnabled()) {
74
75 sync_.clear();
76
77 auto deferredComponents = dce->deferredComponents();
78
79 for (auto& deferredComponent : deferredComponents) {
80
81 deferredComponent.delta = std::max(deferredComponent.delta - delta, 0.0f);
82
83 const auto componentTypeId = deferredComponent.componentTypeId;
84
85 if (deferredComponent.delta <= 0) {
86 auto* rawCmp = entity.raw(componentTypeId);
87 auto ops = helios::ecs::ComponentOpsRegistry<THandle>::ops(componentTypeId);
88
89 if (rawCmp && ops.enable) {
90 ops.enable(rawCmp);
91 }
92
93 sync_.push_back(componentTypeId);
94 }
95 }
96
97 dce->sync(sync_);
98 }
99 }
100 };
101
102}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.