Bugfix: allow ecs constructors & destructors to mutate entities
This commit is contained in:
parent
045f399245
commit
2423547973
1 changed files with 4 additions and 4 deletions
|
|
@ -628,7 +628,7 @@ namespace psemek::ecs
|
||||||
{
|
{
|
||||||
static_assert(detail::all_different_types_v<std::remove_const_t<Components>...>, "all component types must be different");
|
static_assert(detail::all_different_types_v<std::remove_const_t<Components>...>, "all component types must be different");
|
||||||
|
|
||||||
using invocable_type = typename detail::filter_with<detail::invocable, std::tuple<Components const ...>, Function>::type;
|
using invocable_type = typename detail::filter_with<detail::invocable, std::tuple<Components ...>, Function>::type;
|
||||||
|
|
||||||
static_assert(invocable_type::value, "function is not invocable with these components");
|
static_assert(invocable_type::value, "function is not invocable with these components");
|
||||||
|
|
||||||
|
|
@ -636,7 +636,7 @@ namespace psemek::ecs
|
||||||
|
|
||||||
cache->constructor_factory = [function = std::move(function)](std::vector<std::uint32_t> const & column_indices) -> detail::table_callback {
|
cache->constructor_factory = [function = std::move(function)](std::vector<std::uint32_t> const & column_indices) -> detail::table_callback {
|
||||||
return [function, column_indices](container & container, detail::table & table, std::uint32_t row){
|
return [function, column_indices](container & container, detail::table & table, std::uint32_t row){
|
||||||
typename detail::filter_with<detail::static_apply_helper, std::tuple<Components const ...>>::type apply_helper(container, table.entity_handles());
|
typename detail::filter_with<detail::static_apply_helper, std::tuple<Components ...>>::type apply_helper(container, table.entity_handles());
|
||||||
|
|
||||||
for (std::size_t i = 0; i < apply_helper.column_count; ++i)
|
for (std::size_t i = 0; i < apply_helper.column_count; ++i)
|
||||||
apply_helper.pointers[i] = table.columns()[column_indices[i]]->data();
|
apply_helper.pointers[i] = table.columns()[column_indices[i]]->data();
|
||||||
|
|
@ -654,7 +654,7 @@ namespace psemek::ecs
|
||||||
{
|
{
|
||||||
static_assert(detail::all_different_types_v<std::remove_const_t<Components>...>, "all component types must be different");
|
static_assert(detail::all_different_types_v<std::remove_const_t<Components>...>, "all component types must be different");
|
||||||
|
|
||||||
using invocable_type = typename detail::filter_with<detail::invocable, std::tuple<Components const ...>, Function>::type;
|
using invocable_type = typename detail::filter_with<detail::invocable, std::tuple<Components ...>, Function>::type;
|
||||||
|
|
||||||
static_assert(invocable_type::value, "function is not invocable with these components");
|
static_assert(invocable_type::value, "function is not invocable with these components");
|
||||||
|
|
||||||
|
|
@ -662,7 +662,7 @@ namespace psemek::ecs
|
||||||
|
|
||||||
cache->destructor_factory = [function = std::move(function)](std::vector<std::uint32_t> const & column_indices) -> detail::table_callback {
|
cache->destructor_factory = [function = std::move(function)](std::vector<std::uint32_t> const & column_indices) -> detail::table_callback {
|
||||||
return [function, column_indices](container & container, detail::table & table, std::uint32_t row){
|
return [function, column_indices](container & container, detail::table & table, std::uint32_t row){
|
||||||
typename detail::filter_with<detail::static_apply_helper, std::tuple<Components const ...>>::type apply_helper(container, table.entity_handles());
|
typename detail::filter_with<detail::static_apply_helper, std::tuple<Components ...>>::type apply_helper(container, table.entity_handles());
|
||||||
|
|
||||||
for (std::size_t i = 0; i < apply_helper.column_count; ++i)
|
for (std::size_t i = 0; i < apply_helper.column_count; ++i)
|
||||||
apply_helper.pointers[i] = table.columns()[column_indices[i]]->data();
|
apply_helper.pointers[i] = table.columns()[column_indices[i]]->data();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue