armory/Sources/armory/logicnode/ObjectNode.hx

29 lines
670 B
Haxe
Raw Permalink Normal View History

2017-03-21 03:06:38 +01:00
package armory.logicnode;
2017-11-20 15:16:52 +01:00
import iron.object.Object;
2017-04-04 23:11:31 +02:00
2017-04-08 20:05:35 +02:00
class ObjectNode extends LogicNode {
2017-03-21 03:06:38 +01:00
2019-12-19 23:54:08 +01:00
public var objectName: String;
public var value: Object = null;
2017-03-21 03:06:38 +01:00
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree, objectName: String = "") {
2017-04-08 00:34:45 +02:00
this.objectName = objectName;
2017-04-04 23:11:31 +02:00
super(tree);
2017-03-21 03:06:38 +01:00
}
2019-12-19 23:54:08 +01:00
override function get(from: Int): Dynamic {
2017-04-08 00:34:45 +02:00
if (inputs.length > 0) return inputs[0].get();
2018-06-08 12:36:59 +02:00
if (value == null) value = objectName != "" ? iron.Scene.active.getChild(objectName) : tree.object;
2017-04-03 22:29:46 +02:00
return value;
}
2019-12-19 23:54:08 +01:00
override function set(value: Dynamic) {
2017-04-08 00:34:45 +02:00
if (inputs.length > 0) inputs[0].set(value);
else {
objectName = value != null ? value.name : "";
this.value = value;
}
2017-04-03 22:29:46 +02:00
}
2017-03-21 03:06:38 +01:00
}