forked from LeenkxTeam/LNXSDK
Update leenkx/Sources/leenkx/logicnode/PlayAnimationTreeNode.hx
This commit is contained in:
@ -9,19 +9,38 @@ import iron.Scene;
|
|||||||
|
|
||||||
class PlayAnimationTreeNode extends LogicNode {
|
class PlayAnimationTreeNode extends LogicNode {
|
||||||
|
|
||||||
|
var object: Object;
|
||||||
|
var action: Dynamic;
|
||||||
|
var init: Bool = false;
|
||||||
|
|
||||||
public function new(tree: LogicTree) {
|
public function new(tree: LogicTree) {
|
||||||
super(tree);
|
super(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
override function run(from: Int) {
|
override function run(from: Int) {
|
||||||
var object: Object = inputs[1].get();
|
object = inputs[1].get();
|
||||||
var action: Dynamic = inputs[2].get();
|
action = inputs[2].get();
|
||||||
|
|
||||||
assert(Error, object != null, "The object input not be null");
|
assert(Error, object != null, "The object input not be null");
|
||||||
|
init = true;
|
||||||
|
tree.notifyOnUpdate(playAnim);
|
||||||
|
// TO DO: Investigate AnimAction get and PlayAnimationTree notifiers
|
||||||
|
}
|
||||||
|
|
||||||
|
function playAnim() {
|
||||||
|
if (init = false) return;
|
||||||
|
|
||||||
|
init = false;
|
||||||
|
tree.removeUpdate(playAnim);
|
||||||
|
|
||||||
var animation = object.animation;
|
var animation = object.animation;
|
||||||
if(animation == null) {
|
if(animation == null) {
|
||||||
#if lnx_skin
|
#if lnx_skin
|
||||||
animation = object.getBoneAnimation(object.uid);
|
animation = object.getBoneAnimation(object.uid);
|
||||||
|
if (animation == null) {
|
||||||
|
tree.notifyOnUpdate(playAnim);
|
||||||
|
init = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
cast(animation, BoneAnimation).setAnimationLoop(function f(mats) {
|
cast(animation, BoneAnimation).setAnimationLoop(function f(mats) {
|
||||||
action(mats);
|
action(mats);
|
||||||
});
|
});
|
||||||
@ -32,7 +51,6 @@ class PlayAnimationTreeNode extends LogicNode {
|
|||||||
action(mats);
|
action(mats);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
runOutput(0);
|
runOutput(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user