Skip to content

Commit 62040a2

Browse files
committed
Initial commit, make remove callbacks invoke on empty components
1 parent fa50a30 commit 62040a2

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

ecsact/entt/runtime.hh

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,16 +1028,41 @@ private:
10281028
if constexpr(C::transient) {
10291029
return;
10301030
}
1031+
});
1032+
}
10311033

1032-
if(comp.component_id == static_cast<ecsact_component_id>(C::id)) {
1033-
if constexpr(!std::is_empty_v<C>) {
1034-
_pre_exec_update_component<C>(
1035-
info,
1036-
info.entities_map.at(entity),
1037-
*static_cast<const C*>(comp.component_data)
1034+
void _trigger_remove_component_events
1035+
( registry_info& info
1036+
, execution_events_collector& events_collector
1037+
)
1038+
{
1039+
using boost::mp11::mp_for_each;
1040+
1041+
mp_for_each<typename package::components>([&]<typename C>(C) {
1042+
if constexpr(C::transient) return;
1043+
1044+
if constexpr(std::is_empty_v<C>) {
1045+
::entt::basic_view removed_view{
1046+
info.registry.template storage<component_removed<C>>(),
1047+
};
1048+
for(entt_entity_type entity : empty_removed_view<C>) {
1049+
events_collector.invoke_remove_callback<C>(
1050+
info.get_ecsact_entity_id(entity)
1051+
);
1052+
}
1053+
} else {
1054+
::entt::basic_view removed_view{
1055+
info.registry.template storage<detail::temp_storage<C>>(),
1056+
info.registry.template storage<component_removed<C>>(),
1057+
};
1058+
for(entt_entity_type entity : stored_removed_view<C>) {
1059+
events_collector.invoke_remove_callback<C>(
1060+
info.get_ecsact_entity_id(entity),
1061+
removed_view.template get<detail::temp_storage<C>>(entity).value
1062+
);
1063+
info.registry.template storage<detail::temp_storage<C>>().remove(
1064+
entity
10381065
);
1039-
} else {
1040-
assert(!std::is_empty_v<C>);
10411066
}
10421067
}
10431068
});

0 commit comments

Comments
 (0)