Replace ecs sparse component with default-constructed ones upon entity destruction
This commit is contained in:
parent
61885dde25
commit
9b18e664e8
1 changed files with 7 additions and 0 deletions
|
|
@ -270,6 +270,7 @@ namespace psemek::util
|
|||
void remove_entity(entity_handle h) override
|
||||
{
|
||||
auto id = unpack(h).entity;
|
||||
remove_entity_impl(id, std::make_index_sequence<sizeof...(Components)>{});
|
||||
list_[id] = list_head_;
|
||||
list_head_ = id;
|
||||
destroyed_at_[id] = ++version_;
|
||||
|
|
@ -334,6 +335,12 @@ namespace psemek::util
|
|||
created_at_[id] = version_;
|
||||
return pack(this->id_, id, version_);
|
||||
}
|
||||
|
||||
template <std::size_t ... I>
|
||||
void remove_entity_impl(entity_id id, std::index_sequence<I...>)
|
||||
{
|
||||
((std::get<I>(this->entity_components_)[id] = {}), ...);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ... Components>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue