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

31 lines
619 B
Haxe

package armory.logicnode;
import iron.object.Object;
import armory.system.Event;
class SendEventNode extends LogicNode {
var entries: Array<TEvent> = null;
public function new(tree: LogicTree) {
super(tree);
}
override function run(from: Int) {
var name: String = inputs[1].get();
var object: Object = inputs.length > 2 ? inputs[2].get() : tree.object;
if (object == null) return;
var all = Event.get(name);
if (all != null) {
entries = [];
for (e in all) if (e.mask == object.uid) entries.push(e);
}
if (entries == null) return;
for (e in entries) e.onEvent();
runOutput(0);
}
}