diff --git a/src/Flecs.NET.Tests/Cpp/ModuleTests.cs b/src/Flecs.NET.Tests/Cpp/ModuleTests.cs index e2be2db..d491ad7 100644 --- a/src/Flecs.NET.Tests/Cpp/ModuleTests.cs +++ b/src/Flecs.NET.Tests/Cpp/ModuleTests.cs @@ -377,4 +377,17 @@ private void RenameNamespaceNested() Assert.True(nsChild != 0); Assert.True(nsChild.Has(Ecs.Module)); } + + [Fact] + private void RenameReparentRootModule() + { + using World world = World.Create(); + + Entity m = world.Import(); + Entity p = m.Parent(); + + Assert.True(p != 0); + Assert.Equal("Namespace", p.Name()); + Assert.Equal("ReparentRootModule", m.Name()); + } } diff --git a/src/Flecs.NET.Tests/Helpers.cs b/src/Flecs.NET.Tests/Helpers.cs index 8762ea7..a218601 100644 --- a/src/Flecs.NET.Tests/Helpers.cs +++ b/src/Flecs.NET.Tests/Helpers.cs @@ -302,6 +302,14 @@ public void InitModule(World world) } } +public class ReparentRootModule : IFlecsModule +{ + public void InitModule(World world) + { + world.Module("Namespace.ReparentRootModule"); + } +} + namespace Namespace { public struct NestedNameSpaceType; diff --git a/src/Flecs.NET/Core/World.cs b/src/Flecs.NET/Core/World.cs index b40d0ff..11c9061 100644 --- a/src/Flecs.NET/Core/World.cs +++ b/src/Flecs.NET/Core/World.cs @@ -3076,7 +3076,7 @@ public Entity ToEntity(T value) where T : Enum // Module was reparented, cleanup old parent(s) Entity current = prevParent; - do + while (current != 0) { Entity next = current.Parent(); @@ -3086,7 +3086,7 @@ public Entity ToEntity(T value) where T : Enum current.Destruct(); current = next; - } while (current != 0); + } return Entity(result); }