Skip to content

IllegalArgumentException when removing entity and then removing components #77

@chrisapril

Description

@chrisapril

Hi!

i have made a litte test and i got an IllegalArgumentException. First i remove the entity and after this i remove some components from the entity.

public class Test {
    /**
     * @param args
     */
    public static void main(String[] args) {

        PooledEngine engine = new PooledEngine();

        engine.addSystem((new Issue206SystemTest()).new TestSystemA("A"));
        engine.addSystem((new Issue206SystemTest()).new TestSystemAB("AB"));

        Entity e = engine.createEntity();
        e.add(new TestComponentA());
        e.add(new TestComponentB());
        engine.addEntity(e);

        int d = 0;

        engine.update(d++);
        System.out.println(d + "=------------------------------------------");

        engine.update(d++);
        System.out.println(d + "=------------------------------------------");

        System.out.println(d + "= deleting " + e);
        engine.removeEntity(e);

        System.out.println(d + "= removing components from " + e);
        e.remove(TestComponentB.class);
        e.remove(TestComponentA.class);

        engine.update(d++);
        System.out.println(d + "=------------------------------------------");

    }

    public static class TestComponentA extends Component {
    }

    public static class TestComponentB extends Component {
    }

    public static class TestComponentC extends Component {
    }

    class TestSystemA extends IteratingSystem {

        private String name;

        public TestSystemA(String name) {
            super(Family.getFor(TestComponentA.class));
            this.name = name;
        }

        @Override
        public void processEntity(Entity e, float d) {
            System.out.println("System [" + name + "] processed: " + e);
        }

    }

    class TestSystemAB extends IteratingSystem {

        private String name;

        public TestSystemAB(String name) {
            super(Family.getFor(TestComponentA.class, TestComponentB.class));
            this.name = name;
        }

        @Override
        public void processEntity(Entity e, float d) {
            System.out.println("System [" + name + "] processed: " + e);
        }

    }

}

1=------------------------------------------
2=------------------------------------------
2= deleting com.badlogic.ashley.core.PooledEngine$PooledEntity@0
2= removing components from com.badlogic.ashley.core.PooledEngine$PooledEntity@0
Exception in thread "main" java.lang.IllegalArgumentException: object cannot be null.
at com.badlogic.ashley.core.PooledEngine$ComponentPools.free(PooledEngine.java:160)
at com.badlogic.ashley.core.PooledEngine$PooledEntity.remove(PooledEngine.java:113)
at com.krautfactory.tests.ashley.Test.main(Test.java:44)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions