armory/Sources/armory/logicnode/TraitNode.hx

26 lines
676 B
Haxe
Raw Permalink Normal View History

2017-04-14 20:38:50 +02:00
package armory.logicnode;
class TraitNode extends LogicNode {
2019-12-19 23:54:08 +01:00
public var property0: String;
public var value: Dynamic = null;
2017-04-14 20:38:50 +02:00
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-04-14 20:38:50 +02:00
super(tree);
}
2019-12-19 23:54:08 +01:00
override function get(from: Int): Dynamic {
2018-05-05 13:36:20 +02:00
if (value != null) return value;
2019-12-19 23:54:08 +01:00
2018-05-05 13:36:20 +02:00
var cname = Type.resolveClass(Main.projectPackage + "." + property0);
if (cname == null) cname = Type.resolveClass(Main.projectPackage + ".node." + property0);
2020-04-10 20:43:59 +02:00
if (cname == null) throw 'No trait with the name "$property0" found, make sure that the trait is exported!';
2018-05-05 13:36:20 +02:00
value = Type.createInstance(cname, []);
2017-04-14 20:38:50 +02:00
return value;
}
2019-12-19 23:54:08 +01:00
override function set(value: Dynamic) {
2017-04-14 20:38:50 +02:00
this.value = value;
}
}