armory/Sources/armory/logicnode/OnEventNode.hx

33 lines
598 B
Haxe
Raw Normal View History

2017-04-16 14:46:35 +02:00
package armory.logicnode;
2018-03-03 13:09:08 +01:00
import armory.system.Event;
2017-04-16 14:46:35 +02:00
class OnEventNode extends LogicNode {
2019-12-19 23:54:08 +01:00
var _property0: String;
public var property0(get, set): String;
var listener: TEvent = null;
2017-04-16 14:46:35 +02:00
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-04-16 14:46:35 +02:00
super(tree);
2018-03-03 13:09:08 +01:00
tree.notifyOnRemove(onRemove);
2017-04-16 14:46:35 +02:00
}
2019-12-19 23:54:08 +01:00
function get_property0(): String {
2017-04-16 14:46:35 +02:00
return _property0;
}
2019-12-19 23:54:08 +01:00
function set_property0(s: String): String {
2018-03-03 13:09:08 +01:00
listener = Event.add(s, onEvent, tree.object.uid);
2017-04-16 14:46:35 +02:00
return _property0 = s;
}
function onEvent() {
2018-10-22 10:10:33 +02:00
runOutput(0);
2017-04-16 14:46:35 +02:00
}
2018-03-03 13:09:08 +01:00
function onRemove() {
if (listener != null) Event.removeListener(listener);
}
2017-04-16 14:46:35 +02:00
}