Skip to content

Commit 77abf2e

Browse files
committed
Change get accessors from registry to views where possible
1 parent 39b0505 commit 77abf2e

File tree

3 files changed

+563
-503
lines changed

3 files changed

+563
-503
lines changed

ecsact/entt/wrapper/dynamic.hh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ auto component_add_trivial(
6969
template<typename C>
7070
auto context_remove(
7171
ecsact_system_execution_context* context,
72-
[[maybe_unused]] ecsact_component_like_id component_id
72+
[[maybe_unused]] ecsact_component_like_id component_id,
73+
auto& view
7374
) -> void {
7475
assert(ecsact_id_cast<ecsact_component_like_id>(C::id) == component_id);
7576

@@ -88,7 +89,7 @@ auto context_remove(
8889

8990
// Stop here (tag)
9091
if constexpr(!std::is_empty_v<C>) {
91-
auto component = registry.template get<C>(entity);
92+
auto component = view.template get<C>(entity);
9293

9394
auto& remove_storage =
9495
registry.template emplace_or_replace<beforeremove_storage<C>>(entity);
@@ -100,7 +101,8 @@ auto context_remove(
100101
template<typename C>
101102
auto component_remove_trivial(
102103
::entt::registry& registry,
103-
ecsact::entt::entity_id entity_id
104+
ecsact::entt::entity_id entity_id,
105+
auto& view
104106
) -> void {
105107
using ecsact::entt::component_removed;
106108
using ecsact::entt::component_updated;
@@ -113,7 +115,7 @@ auto component_remove_trivial(
113115
registry.template emplace_or_replace<component_removed<C>>(entity_id);
114116

115117
if constexpr(!std::is_empty_v<C>) {
116-
auto component = registry.template get<C>(entity_id);
118+
auto component = view.template get<C>(entity_id);
117119

118120
auto& remove_storage =
119121
registry.template emplace_or_replace<beforeremove_storage<C>>(entity_id);
@@ -126,21 +128,23 @@ template<typename C>
126128
auto context_get(
127129
ecsact_system_execution_context* context,
128130
[[maybe_unused]] ecsact_component_like_id component_id,
129-
void* out_component_data
131+
void* out_component_data,
132+
auto& view
130133
) -> void {
131134
auto entity = context->entity;
132135
const auto& registry = *context->registry;
133136

134137
assert(registry.template any_of<C>(entity));
135138

136-
*static_cast<C*>(out_component_data) = registry.template get<C>(entity);
139+
*static_cast<C*>(out_component_data) = view.template get<C>(entity);
137140
}
138141

139142
template<typename C>
140143
auto context_update(
141144
ecsact_system_execution_context* context,
142145
[[maybe_unused]] ecsact_component_like_id component_id,
143-
const void* in_component_data
146+
const void* in_component_data,
147+
auto& view
144148
) -> void {
145149
using ecsact::entt::component_updated;
146150
using ecsact::entt::detail::exec_beforechange_storage;
@@ -154,6 +158,7 @@ auto context_update(
154158
auto& current_component = registry.template get<C>(entity);
155159
auto& beforechange =
156160
registry.template get<exec_beforechange_storage<C>>(entity);
161+
157162
if(!beforechange.has_update_occurred) {
158163
beforechange.value = current_component;
159164
beforechange.has_update_occurred = true;

0 commit comments

Comments
 (0)