armory/Sources/armory/logicnode/OnTimerNode.hx
2019-12-19 23:54:08 +01:00

28 lines
444 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);
}
}
}