armory/Sources/armory/logicnode/OnTimerNode.hx
2018-10-22 10:10:33 +02:00

28 lines
443 B
Haxe

package armory.logicnode;
class OnTimerNode extends LogicNode {
var duration = 0.0;
var repeat = false;
public function new(tree:LogicTree) {
super(tree);
tree.notifyOnUpdate(update);
}
function update() {
if (duration <= 0.0) {
duration = inputs[0].get();
repeat = inputs[1].get();
}
duration -= iron.system.Time.delta;
if (duration <= 0.0) {
if (!repeat) tree.removeUpdate(update);
runOutput(0);
}
}
}