Просмотр исходного кода

sparse_set/storage: deprecated ::destroy, use ::erase instead

Michele Caini 6 лет назад
Родитель
Сommit
a6aad25117

+ 2 - 2
src/entt/entity/observer.hpp

@@ -190,7 +190,7 @@ class basic_observer {
         template<std::size_t Index>
         static void discard_if(basic_observer &obs, const basic_registry<Entity> &, const Entity entt) {
             if(auto *value = obs.view.try_get(entt); value && !(*value &= (~(1 << Index)))) {
-                obs.view.destroy(entt);
+                obs.view.erase(entt);
             }
         }
 
@@ -226,7 +226,7 @@ class basic_observer {
         template<std::size_t Index>
         static void discard_if(basic_observer &obs, const basic_registry<Entity> &, const Entity entt) {
             if(auto *value = obs.view.try_get(entt); value && !(*value &= (~(1 << Index)))) {
-                obs.view.destroy(entt);
+                obs.view.erase(entt);
             }
         }
 

+ 2 - 2
src/entt/entity/registry.hpp

@@ -82,7 +82,7 @@ class basic_registry {
 
         void remove(basic_registry &owner, const Entity entt) {
             destruction.publish(owner, entt);
-            this->destroy(entt);
+            this->erase(entt);
         }
 
         template<typename It>
@@ -160,7 +160,7 @@ class basic_registry {
         void discard_if([[maybe_unused]] basic_registry &owner, const Entity entt) {
             if constexpr(sizeof...(Owned) == 0) {
                 if(current.contains(entt)) {
-                    current.destroy(entt);
+                    current.erase(entt);
                 }
             } else {
                 if(const auto cpools = std::forward_as_tuple(owner.assure<Owned>()...); std::get<0>(cpools).contains(entt) && (std::get<0>(cpools).index(entt) < current)) {

+ 7 - 1
src/entt/entity/sparse_set.hpp

@@ -427,7 +427,7 @@ public:
      *
      * @param entt A valid entity identifier.
      */
-    void destroy(const entity_type entt) {
+    void erase(const entity_type entt) {
         ENTT_ASSERT(contains(entt));
         const auto curr = page(entt);
         const auto pos = offset(entt);
@@ -437,6 +437,12 @@ public:
         direct.pop_back();
     }
 
+    /*! @copydoc erase */
+    [[deprecated("use ::erase instead")]]
+    void destroy(const entity_type entt) {
+        erase(entt);
+    }
+
     /**
      * @brief Swaps two entities in the internal packed array.
      *

+ 8 - 2
src/entt/entity/storage.hpp

@@ -404,11 +404,17 @@ public:
      *
      * @param entt A valid entity identifier.
      */
-    void destroy(const entity_type entt) {
+    void erase(const entity_type entt) {
         auto other = std::move(instances.back());
         instances[underlying_type::index(entt)] = std::move(other);
         instances.pop_back();
-        underlying_type::destroy(entt);
+        underlying_type::erase(entt);
+    }
+
+    /*! @copydoc erase */
+    [[deprecated("use ::erase instead")]]
+    void destroy(const entity_type entt) {
+        erase(entt);
     }
 
     /**