Przeglądaj źródła

workaround for an issue of VS2019

Michele Caini 6 lat temu
rodzic
commit
d921306dd8
3 zmienionych plików z 18 dodań i 2 usunięć
  1. 3 0
      TODO
  2. 4 2
      src/entt/entity/helper.hpp
  3. 11 0
      test/entt/entity/helper.cpp

+ 3 - 0
TODO

@@ -27,3 +27,6 @@ TODO
 * make meta work across boundaries
   - inline variables are fine here, only the head represents a problem
   - we should always resolve by looking into the list of types when working across boundaries, no direct resolve
+* signals: entity/registry/component instead of registry/entity/component
+  - dependency becomes a short circuit on the registry
+  - deprecate dependency

+ 4 - 2
src/entt/entity/helper.hpp

@@ -149,7 +149,8 @@ void dependency(basic_registry<Entity> &reg, const Entity entt) {
  */
 template<typename... Dependency, typename Component, typename Entity>
 void connect(sink<void(basic_registry<Entity> &, const Entity, Component &)> sink) {
-    sink.template connect<dependency<Entity, Dependency...>>();
+    constexpr auto function = &dependency<Entity, Dependency...>;
+    sink.template connect<function>();
 }
 
 
@@ -173,7 +174,8 @@ void connect(sink<void(basic_registry<Entity> &, const Entity, Component &)> sin
  */
 template<typename... Dependency, typename Component, typename Entity>
 void disconnect(sink<void(basic_registry<Entity> &, const Entity, Component &)> sink) {
-    sink.template disconnect<dependency<Entity, Dependency...>>();
+    constexpr auto function = &dependency<Entity, Dependency...>;
+    sink.template disconnect<function>();
 }
 
 

+ 11 - 0
test/entt/entity/helper.cpp

@@ -26,8 +26,12 @@ TEST(Helper, AsGroup) {
 TEST(Helper, Dependency) {
     entt::registry registry;
     const auto entity = registry.create();
+
+    ASSERT_TRUE(registry.on_construct<int>().empty());
+
     entt::connect<double, float>(registry.on_construct<int>());
 
+    ASSERT_FALSE(registry.on_construct<int>().empty());
     ASSERT_FALSE(registry.has<double>(entity));
     ASSERT_FALSE(registry.has<float>(entity));
 
@@ -62,9 +66,16 @@ TEST(Helper, Dependency) {
     registry.remove<int>(entity);
     registry.remove<double>(entity);
     registry.remove<float>(entity);
+
+    ASSERT_FALSE(registry.has<int>(entity));
+    ASSERT_FALSE(registry.has<double>(entity));
+    ASSERT_FALSE(registry.has<float>(entity));
+
     entt::disconnect<double, float>(registry.on_construct<int>());
     registry.assign<int>(entity);
 
+    ASSERT_TRUE(registry.on_construct<int>().empty());
+    ASSERT_TRUE(registry.has<int>(entity));
     ASSERT_FALSE(registry.has<double>(entity));
     ASSERT_FALSE(registry.has<float>(entity));
 }