Fix ecs::dispatcher to work with ecs::without

This commit is contained in:
Nikita Lisitsa 2024-06-19 14:37:09 +03:00
parent bd202d08ae
commit 37a3d7f827

View file

@ -48,30 +48,24 @@ namespace psemek::ecs
handlers_[Event::uuid()].push_back([system = std::move(system), this, cache = container_->cache<Components...>()](void const * event_ptr) mutable {
auto const & event = *reinterpret_cast<Event const *>(event_ptr);
if constexpr (std::invocable<System, Event const &, ecs::container &, handle, Components & ...>)
{
container_->apply<Components...>([&](ecs::container & container, ecs::handle handle, Components & ... components){
system(event, container, handle, components...);
}, cache);
}
else if constexpr (std::invocable<System, Event const &, ecs::container &, Components & ...>)
{
container_->apply<Components...>([&](ecs::container & container, Components & ... components){
system(event, container, components...);
}, cache);
}
else if constexpr (std::invocable<System, Event const &, handle, Components & ...>)
{
container_->apply<Components...>([&](ecs::handle handle, Components & ... components){
system(event, handle, components...);
}, cache);
}
else
{
container_->apply<Components...>([&](Components & ... components){
system(event, components...);
}, cache);
}
container_->apply<Components...>([&]<typename ... FilteredComponents>(ecs::container & container, ecs::handle entity, FilteredComponents & ... filtered_components){
if constexpr (std::invocable<System, Event const &, ecs::container &, handle, FilteredComponents & ...>)
{
system(event, container, entity, filtered_components...);
}
else if constexpr (std::invocable<System, Event const &, ecs::container &, FilteredComponents & ...>)
{
system(event, container, filtered_components...);
}
else if constexpr (std::invocable<System, Event const &, handle, FilteredComponents & ...>)
{
system(event, entity, filtered_components...);
}
else
{
system(event, filtered_components...);
}
});
});
}