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

Removing entity that was removed before causes entity list change. #40

Open
SergeyRomanko opened this issue Apr 22, 2016 · 2 comments
Open

Comments

@SergeyRomanko
Copy link

Hi!
Here is code that illustrates issue.

`package {
import flash.display.Sprite;

import ash.core.Engine;
import ash.core.Entity;

public class AshTest extends Sprite {

    public var engine:Engine = new Engine();

    public function AshTest() {

        var a:Entity = new Entity("a");
        var b:Entity = new Entity("b");
        var c:Entity = new Entity("c");
        var d:Entity = new Entity("d");

        engine.addEntity(a);
        engine.addEntity(b);
        engine.addEntity(c);
        engine.addEntity(d);

        print();    //a, b, c, d

        engine.removeEntity(b);
        engine.removeEntity(c);

        print();    //a, d  <-- ok

        engine.removeEntity(b);     //<- delete b again. problem here

        print();    //a, c, d <-- error

    }

    private function print():void {
        var result:Array = [];
        var entites:Vector.<Entity> = engine.entities;
        for (var i:int = 0; i < entites.length; i++) {
            result[result.length] = entites[i].name;
        }
        trace(result.join(", "));
    }

}

}`

It's self-evident that programmer should not remove entities that are already removed. But it would be better if engine will work correctly in this situation.

@dyarosla
Copy link

@SergeyRomanko
Copy link
Author

Yep, I know why this happen. This is still issue to solve.

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