Fixed entity deletion bug

Fixed bug where deleted entity would retain Components/Tags.
This commit is contained in:
Stephen Seo 2016-03-14 11:39:37 +09:00
parent c6002149d3
commit de07c8ad1a
2 changed files with 9 additions and 1 deletions

View file

@ -111,6 +111,9 @@ namespace EC
// swap lhs entity with rhs entity // swap lhs entity with rhs entity
std::swap(entities[lhs], entities[rhs]); std::swap(entities[lhs], entities[rhs]);
// clear deleted bitset
std::get<BitsetType>(entities[rhs]).reset();
// inc/dec pointers // inc/dec pointers
++lhs; --rhs; ++lhs; --rhs;
} }

View file

@ -109,10 +109,15 @@ TEST(EC, Manager)
manager.addTag<T0>(e2); manager.addTag<T0>(e2);
auto updateTagOnly = [] (std::size_t id) { std::size_t count = 0;
auto updateTagOnly = [&count] (std::size_t id) {
std::cout << "UpdateTagOnly was run." << std::endl; std::cout << "UpdateTagOnly was run." << std::endl;
++count;
}; };
manager.forMatchingSignature<EC::Meta::TypeList<T0> >(updateTagOnly); manager.forMatchingSignature<EC::Meta::TypeList<T0> >(updateTagOnly);
EXPECT_EQ(2, count);
} }