Skip to content

Commit

Permalink
fixup: checking for dependency actions (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored Apr 18, 2023
1 parent 2fa2c35 commit be924bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions ecsact/entt/runtime.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,30 @@ namespace ecsact::entt {
template<typename Package>
class runtime {
/**
* Checks if type T is listd as one of the actions in the ecact package.
* Checks if type T is listd as one of the actions in the ecsact package or
* one of it's dependencies.
* @returns `true` if T is a component belonging to `package`, `false`
* otherwise.
*/
template<typename T>
static constexpr bool is_action() {
using boost::mp11::mp_any;
using boost::mp11::mp_append;
using boost::mp11::mp_apply;
using boost::mp11::mp_bind_front;
using boost::mp11::mp_transform_q;
using ecsact::entt::detail::mp_actions_t;
using ecsact::entt::detail::mp_package_dependencies_recursive;

using actions = typename mp_append<
mp_actions_t<Package>,
mp_package_dependencies_recursive<typename Package::dependencies>>::type;

return mp_apply<
mp_any,
mp_transform_q<
mp_bind_front<std::is_same, std::remove_cvref_t<T>>,
typename Package::actions>>::value;
actions>>::value;
}

using registry_info = ecsact_entt_rt::registry_info<Package>;
Expand Down
4 changes: 2 additions & 2 deletions runtime/dynamic.template.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ void ecsact_system_execution_context_action(
ecsact_system_execution_context* context,
void* out_action_data
) {
using boost::mp11::mp_for_each;
using ecsact::entt::detail::mp_for_each_available_action;

auto action_id = static_cast<ecsact_action_id>(context->system_id);

cast_and_use_ctx(context, [&](auto& context) {
mp_for_each<typename package::actions>([&]<typename A>(A) {
mp_for_each_available_action<package>([&]<typename A>(A) {
if(A::id == action_id) {
A& out_action = *reinterpret_cast<A*>(out_action_data);
out_action = *reinterpret_cast<const A*>(context.action);
Expand Down

0 comments on commit be924bf

Please sign in to comment.