Closed sonygod closed 3 years ago
what do you mean by "not work"?
I mean when removing system components , it should be not call update() function again.
but currently it's still execute update function?
how to stop the update function?
entities and systems will be removed after the current update
import exp.ecs.system.System;
import exp.ecs.node.Node;
import exp.ecs.Engine;
class PlayerC<Event> extends System<Event> {
@:nodes var nodes:Node<Player, Weapon>;
var num:Float = 1.;
public function new() {
super();
}
override public function onAdded(e:Engine<Event>) {
super.onAdded(e);
}
override function update(dt:Float) {
super.update(dt);
trace("update");//still excute after engine.systems.remove(this, true);
engine.systems.remove(this, true);
}
}
hello ,still excuting after call engine.systems.remove(this, true);
I found the problem here
system.onAdded(engine);//why readd to engine system again after remove ?
override function operate(item:Item<System<Event>>, operation:Operation) {
var system = item.data;
switch operation {
case Add:
queue.add(item);
system.onAdded(engine);
case Remove | RemoveAndDestroy:
queue.add(item);
system.onAdded(engine);//why readd to engine system again after remove ?
if(operation == RemoveAndDestroy)
system.destroy();
}
}
oh right that is obviously wrong
@kevinresol will you take a look and fixed?
Should be simple and obvious to fix, how about a PR?
Please PR or it is a wontfix, since a new version is in the works