From 37a3d7f82746b2a5f0546061600c89fa7b62ae27 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 19 Jun 2024 14:37:09 +0300 Subject: [PATCH] Fix ecs::dispatcher to work with ecs::without --- libs/ecs/include/psemek/ecs/dispatcher.hpp | 42 ++++++++++------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/libs/ecs/include/psemek/ecs/dispatcher.hpp b/libs/ecs/include/psemek/ecs/dispatcher.hpp index b0ea1f83..b534413e 100644 --- a/libs/ecs/include/psemek/ecs/dispatcher.hpp +++ b/libs/ecs/include/psemek/ecs/dispatcher.hpp @@ -48,30 +48,24 @@ namespace psemek::ecs handlers_[Event::uuid()].push_back([system = std::move(system), this, cache = container_->cache()](void const * event_ptr) mutable { auto const & event = *reinterpret_cast(event_ptr); - if constexpr (std::invocable) - { - container_->apply([&](ecs::container & container, ecs::handle handle, Components & ... components){ - system(event, container, handle, components...); - }, cache); - } - else if constexpr (std::invocable) - { - container_->apply([&](ecs::container & container, Components & ... components){ - system(event, container, components...); - }, cache); - } - else if constexpr (std::invocable) - { - container_->apply([&](ecs::handle handle, Components & ... components){ - system(event, handle, components...); - }, cache); - } - else - { - container_->apply([&](Components & ... components){ - system(event, components...); - }, cache); - } + container_->apply([&](ecs::container & container, ecs::handle entity, FilteredComponents & ... filtered_components){ + if constexpr (std::invocable) + { + system(event, container, entity, filtered_components...); + } + else if constexpr (std::invocable) + { + system(event, container, filtered_components...); + } + else if constexpr (std::invocable) + { + system(event, entity, filtered_components...); + } + else + { + system(event, filtered_components...); + } + }); }); }