2016-07-10 00:51:39 +02:00
|
|
|
package armory.trait.internal;
|
2015-11-26 15:36:17 +01:00
|
|
|
|
2016-07-10 00:51:39 +02:00
|
|
|
import iron.Trait;
|
2015-11-26 15:36:17 +01:00
|
|
|
|
2016-10-12 17:52:27 +02:00
|
|
|
@:keep
|
2015-11-26 15:36:17 +01:00
|
|
|
class NodeExecutor extends Trait {
|
|
|
|
|
2016-10-15 20:19:09 +02:00
|
|
|
var baseNode:armory.logicnode.Node;
|
|
|
|
var nodeInits:Array<Void->Void> = [];
|
|
|
|
var nodeUpdates:Array<Void->Void> = [];
|
|
|
|
|
|
|
|
public function new() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
notifyOnUpdate(update);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function start(baseNode:armory.logicnode.Node) {
|
|
|
|
this.baseNode = baseNode;
|
|
|
|
baseNode.start(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
if (nodeInits.length > 0) {
|
|
|
|
for (f in nodeInits) { if (nodeInits.length == 0) break; f(); f = null; }
|
|
|
|
nodeInits.splice(0, nodeInits.length);
|
|
|
|
}
|
|
|
|
for (f in nodeUpdates) f();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function notifyOnNodeInit(f:Void->Void) {
|
|
|
|
nodeInits.push(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function notifyOnNodeUpdate(f:Void->Void) {
|
|
|
|
nodeUpdates.push(f);
|
|
|
|
}
|
2015-11-26 15:36:17 +01:00
|
|
|
}
|