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

Only half of Entities holding Relation to a Target Entity have their Component Removed on Despawn(target) #11

Open
thygrrr opened this issue Feb 8, 2024 · 1 comment

Comments

@thygrrr
Copy link

thygrrr commented Feb 8, 2024

I came across a somewhat serious bug in Archetypes.cs while working on my fork.

image

This issue comes from the forward-iteration of the table while it has elements being removed from it. This skips every other Entity.

foreach (var tableWithType in tablesWithType)
{
    for (var i = 0; i < tableWithType.Count; i++)
    {
        RemoveComponent(type, tableWithType.Identities[i]);
    }
}
@thygrrr
Copy link
Author

thygrrr commented Feb 8, 2024

naive fix:

foreach (var tableWithType in tablesWithType)
{
    for (var i = tableWithType.Count-1; i >= 0; i--)
    {
        RemoveComponent(type, tableWithType.Identities[i]);
    }
}

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

1 participant