diff --git a/tests/zecsy.cpp b/tests/zecsy.cpp index 89e9d89..f6135e8 100644 --- a/tests/zecsy.cpp +++ b/tests/zecsy.cpp @@ -177,8 +177,10 @@ TEST_CASE("Attach multiple components to an entity and verify all are correctly REQUIRE(e.has()); REQUIRE(w.has(e)); - e.remove(); + e.remove(); REQUIRE_FALSE(e.has()); REQUIRE_FALSE(w.has(e)); + REQUIRE_FALSE(e.has()); + REQUIRE_FALSE(e.has()); } diff --git a/zecsy.hpp b/zecsy.hpp index 3423ad4..4a6d621 100644 --- a/zecsy.hpp +++ b/zecsy.hpp @@ -39,7 +39,7 @@ namespace zecsy template void set(const T&... comps); - template + template void remove(); private: entity_id id = 0; @@ -78,6 +78,10 @@ namespace zecsy template void remove(entity_id e); + + template + requires(sizeof...(Rest) >= 0) + void remove(entity_id e); private: using comp_index = std::type_index; using comp_to_bitset = std::unordered_map; @@ -117,7 +121,7 @@ namespace zecsy template void set(entity_id e, const T&... comps); - template + template void remove(entity_id e); private: zecsy_bits entities_bitset; @@ -277,16 +281,16 @@ namespace zecsy entity_dict[typeid(T)].erase(e); } - template + template inline void world::remove(entity_id e) { - storage.remove(e); + storage.remove(e); } - template + template inline void entity::remove() { - w->remove(id); + w->remove(id); } template @@ -320,4 +324,13 @@ namespace zecsy set(e, comp1); (set(e, rest_comps), ...); } + + template + requires(sizeof...(Rest) >= 0) + inline void component_storage::remove(entity_id e) + { + remove(e); + remove(e); + (remove(e), ...); + } };