Merge pull request #1893 from MoritzBrueckner/on-application-state

Add "On Application State" node
This commit is contained in:
Lubos Lenco 2020-09-27 20:36:54 +02:00 committed by GitHub
commit 95cc79339a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,20 @@
package armory.logicnode;
@:access(iron.Trait)
class OnApplicationStateNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
tree.notifyOnInit(init);
}
function init() {
kha.System.notifyOnApplicationState(
() -> runOutput(0), // On foreground
null, // On resume
null, // On pause
() -> runOutput(1), // On background
() -> runOutput(2) // On shutdown
);
}
}

View file

@ -0,0 +1,17 @@
from arm.logicnode.arm_nodes import *
class OnApplicationStateNode(ArmLogicTreeNode):
"""Listen to different application state changes."""
bl_idname = 'LNOnApplicationStateNode'
bl_label = 'On Application State'
arm_version = 1
def init(self, context):
super().init(context)
self.add_output('ArmNodeSocketAction', 'On Foreground')
self.add_output('ArmNodeSocketAction', 'On Background')
self.add_output('ArmNodeSocketAction', 'On Shutdown')
add_node(OnApplicationStateNode, category=PKG_AS_CATEGORY)