Ash
Ash copied to clipboard
Removing entity that was removed before causes entity list change.
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.
This is due to
https://github.com/richardlord/Ash/blob/master/src/ash/core/EntityList.as#L48
Yep, I know why this happen. This is still issue to solve.