forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
28
leenkx/Sources/leenkx/logicnode/OnInitNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/OnInitNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import leenkx.trait.physics.PhysicsWorld;
|
||||
|
||||
@:access(iron.Trait)
|
||||
class OnInitNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
tree.notifyOnInit(init);
|
||||
}
|
||||
|
||||
function init() {
|
||||
#if lnx_physics
|
||||
var noPhysics = PhysicsWorld.active == null || PhysicsWorld.active._lateUpdate == null;
|
||||
noPhysics ? runOutput(0) : PhysicsWorld.active.notifyOnPreUpdate(physics_init);
|
||||
#else
|
||||
runOutput(0);
|
||||
#end
|
||||
}
|
||||
|
||||
#if lnx_physics
|
||||
function physics_init() {
|
||||
PhysicsWorld.active.removePreUpdate(physics_init);
|
||||
runOutput(0);
|
||||
}
|
||||
#end
|
||||
}
|
Reference in New Issue
Block a user