Skip to content

Deep/complex cyclic relations can have undefined behaviour when despawning entities. #41

@thygrrr

Description

@thygrrr

This test will fail.

    [Fact]
    private void DespawnWithRelationDespawnsAllEntities()
    {
        var world = new World();
        var entities = new List<Entity>();
        
        var parent = world.Spawn();
        parent.Add<TagForDespawn>();
        parent.Add(-1);
        entities.Add(parent);

        for (var i = 0; i < 100; i++) {
            var entity = world.Spawn();
            entity.Add(i);
            
            entities.Add(entity);
            
            if (i % 5 == 2) {
                entity.Add<RelationComponent>(parent);
            }

            entity.Add<ComponentA>();

            if (i % 3 == 0) {
                entity.Add<TagForDespawn>();
            }

            parent = entity;
        }

        world.Query<int>().Compile().Despawn();
        
        foreach (var entity in entities) Assert.False(entity.Alive, $"Entity {entity} should be despawned");
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions