entity: deprecate handle::remove_all and registry::remove_all

This commit is contained in:
Michele Caini
2021-05-06 14:52:33 +02:00
parent cf522d60ca
commit e5d4f1bb58
4 changed files with 13 additions and 19 deletions

View File

@@ -224,6 +224,7 @@ struct basic_handle {
* @brief Removes all the components from a handle and makes it orphaned.
* @sa basic_registry::remove_all
*/
[[deprecated("No longer supported")]]
void remove_all() const {
static_assert(sizeof...(Type) == 0, "Invalid operation");
reg->remove_all(entt);

View File

@@ -748,6 +748,7 @@ public:
*
* @param entity A valid entity identifier.
*/
[[deprecated("Use ::destroy(entity)/::create(entity) instead")]]
void remove_all(const entity_type entity) {
ENTT_ASSERT(valid(entity), "Invalid entity");

View File

@@ -186,20 +186,6 @@ TEST(BasicHandle, Component) {
ASSERT_EQ(nullptr, std::get<1>(handle.try_get<int, char, double>()));
}
TEST(BasicHandle, RemoveAll) {
entt::registry registry;
const auto entity = registry.create();
entt::handle handle{registry, entity};
ASSERT_EQ(3, handle.emplace<int>(3));
ASSERT_EQ('c', handle.emplace_or_replace<char>('c'));
ASSERT_TRUE((handle.all_of<int, char>()));
handle.remove_all();
ASSERT_FALSE((handle.any_of<int, char>()));
}
TEST(BasicHandle, FromEntity) {
entt::registry registry;
const auto entity = registry.create();

View File

@@ -593,18 +593,24 @@ TEST(Registry, Each) {
TEST(Registry, Orphans) {
entt::registry registry;
entt::registry::size_type tot{};
entt::entity entities[3u]{};
registry.emplace<int>(registry.create());
registry.create();
registry.emplace<int>(registry.create());
registry.create(std::begin(entities), std::end(entities));
registry.emplace<int>(entities[0u]);
registry.emplace<int>(entities[2u]);
registry.orphans([&](auto) { ++tot; });
ASSERT_EQ(tot, 1u);
tot = {};
registry.each([&](auto entity) { registry.remove_all(entity); });
registry.erase<int>(entities[0u]);
registry.erase<int>(entities[2u]);
tot = {};
registry.orphans([&](auto) { ++tot; });
ASSERT_EQ(tot, 3u);
registry.clear();
tot = {};