Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New entities have the same parent of recycled entities #29

Closed
popcron opened this issue Nov 10, 2024 · 2 comments
Closed

New entities have the same parent of recycled entities #29

popcron opened this issue Nov 10, 2024 · 2 comments

Comments

@popcron
Copy link

popcron commented Nov 10, 2024

when a new created entity uses a recycled slot/position from a previously destroyed entity, it still has the same parent that the recycled entity did. i dont understand if entities are meant to be removed from their parents before deletion, or if the library should be able to handle this common case.

also, great library thank you!

this is the test code:

[Fact]
public void CreateThenDestroyEntityWithParent()
{
    using World world = new();
    Entity a = world.CreateEntity();
    Entity b = world.CreateEntity();
    a.AddChild(b);
    int id = b.Id;
    Entity parent = b.Parent;
    //a.RemoveChild(b); //<- this fixes it
    b.DeleteEntity();
    Entity c = world.CreateEntity();
    Assert.Equal(id, c.Id);
    Assert.NotEqual(c.Parent, parent);
}
@friflo
Copy link
Owner

friflo commented Nov 11, 2024

@popcron
thx for report and test case!

Fixed by: 52fb537

@friflo friflo closed this as completed Nov 11, 2024
@friflo
Copy link
Owner

friflo commented Nov 12, 2024

Fixed in 3.0.0-preview.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants