Sfoglia il codice sorgente

observer: share discard_if

Michele Caini 1 anno fa
parent
commit
cc6e578f63
1 ha cambiato i file con 7 aggiunte e 14 eliminazioni
  1. 7 14
      src/entt/entity/observer.hpp

+ 7 - 14
src/entt/entity/observer.hpp

@@ -162,6 +162,13 @@ template<typename Registry, typename Mask, typename Allocator>
 class basic_observer {
     using storage_type = basic_storage<Mask, typename Registry::entity_type, Allocator>;
 
+    template<std::size_t Index>
+    static void discard_if(storage_type &obs, Registry &, const typename Registry::entity_type entt) {
+        if(obs.contains(entt) && !(obs.get(entt) &= (~(1 << Index)))) {
+            obs.erase(entt);
+        }
+    }
+
     template<typename>
     struct matcher_handler;
 
@@ -178,13 +185,6 @@ class basic_observer {
             }
         }
 
-        template<std::size_t Index>
-        static void discard_if(storage_type &obs, Registry &, const typename Registry::entity_type entt) {
-            if(obs.contains(entt) && !(obs.get(entt) &= (~(1 << Index)))) {
-                obs.erase(entt);
-            }
-        }
-
         template<std::size_t Index>
         static void connect(storage_type &obs, Registry &reg) {
             (reg.template on_destroy<Require>().template connect<&discard_if<Index>>(obs), ...);
@@ -222,13 +222,6 @@ class basic_observer {
             }
         }
 
-        template<std::size_t Index>
-        static void discard_if(storage_type &obs, Registry &, const typename Registry::entity_type entt) {
-            if(obs.contains(entt) && !(obs.get(entt) &= (~(1 << Index)))) {
-                obs.erase(entt);
-            }
-        }
-
         template<std::size_t Index>
         static void connect(storage_type &obs, Registry &reg) {
             (reg.template on_destroy<Require>().template connect<&discard_if<Index>>(obs), ...);