forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class OnApplicationStateNode(LnxLogicTreeNode):
|
||||
"""Listens to different application state changes."""
|
||||
bl_idname = 'LNOnApplicationStateNode'
|
||||
bl_label = 'On Application State'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxNodeSocketAction', 'On Foreground')
|
||||
self.add_output('LnxNodeSocketAction', 'On Background')
|
||||
self.add_output('LnxNodeSocketAction', 'On Shutdown')
|
73
leenkx/blender/lnx/logicnode/event/LN_on_event.py
Normal file
73
leenkx/blender/lnx/logicnode/event/LN_on_event.py
Normal file
@ -0,0 +1,73 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class OnEventNode(LnxLogicTreeNode):
|
||||
"""Activates the output when the given event is received.
|
||||
|
||||
@seeNode Send Event to Object
|
||||
@seeNode Send Global Event"""
|
||||
bl_idname = 'LNOnEventNode'
|
||||
bl_label = 'On Event'
|
||||
lnx_version = 2
|
||||
lnx_section = 'custom'
|
||||
|
||||
operators = {
|
||||
'init': 'Init',
|
||||
'update': 'Update',
|
||||
'custom': 'Custom'
|
||||
}
|
||||
|
||||
def set_mode(self, context):
|
||||
if self.property1 != 'custom':
|
||||
if len(self.inputs) > 1:
|
||||
self.inputs.remove(self.inputs[0])
|
||||
else:
|
||||
if len(self.inputs) < 2:
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.inputs.move(1, 0)
|
||||
|
||||
# Use a new property to preserve compatibility
|
||||
property1: HaxeEnumProperty(
|
||||
'property1',
|
||||
items=[
|
||||
('init', 'Init', 'Assigns an Event listener at runtime'),
|
||||
('update', 'Update', 'Assigns an Event listener continuously'),
|
||||
None,
|
||||
('custom', 'Custom', 'Assigns an Event listener everytime input is detected'),
|
||||
],
|
||||
name='',
|
||||
description='Chosen method for assigning an Event listener',
|
||||
default='init',
|
||||
update=set_mode
|
||||
)
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxStringSocket', 'String In')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
|
||||
self.set_mode(context)
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property1', text='')
|
||||
|
||||
def draw_label(self) -> str:
|
||||
if self.inputs[0].is_linked:
|
||||
return self.bl_label
|
||||
return f'{self.bl_label}: {self.inputs[0].get_default_value()}'
|
||||
|
||||
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
|
||||
if self.lnx_version not in (0, 1):
|
||||
raise LookupError()
|
||||
|
||||
newnode = node_tree.nodes.new('LNOnEventNode')
|
||||
|
||||
try:
|
||||
newnode.inputs[0].default_value_raw = self["property0"]
|
||||
except:
|
||||
pass
|
||||
|
||||
for link in self.outputs[0].links:
|
||||
node_tree.links.new(newnode.outputs[0], link.to_socket)
|
||||
|
||||
return newnode
|
10
leenkx/blender/lnx/logicnode/event/LN_on_init.py
Normal file
10
leenkx/blender/lnx/logicnode/event/LN_on_init.py
Normal file
@ -0,0 +1,10 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class OnInitNode(LnxLogicTreeNode):
|
||||
"""Activates the output on the first frame of execution of the logic tree."""
|
||||
bl_idname = 'LNOnInitNode'
|
||||
bl_label = 'On Init'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
10
leenkx/blender/lnx/logicnode/event/LN_on_remove.py
Normal file
10
leenkx/blender/lnx/logicnode/event/LN_on_remove.py
Normal file
@ -0,0 +1,10 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class OnRemoveNode(LnxLogicTreeNode):
|
||||
"""Activates the output when logic tree is removed"""
|
||||
bl_idname = 'LNOnRemoveNode'
|
||||
bl_label = 'On Remove'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
14
leenkx/blender/lnx/logicnode/event/LN_on_render2d.py
Normal file
14
leenkx/blender/lnx/logicnode/event/LN_on_render2d.py
Normal file
@ -0,0 +1,14 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class OnRender2DNode(LnxLogicTreeNode):
|
||||
"""Registers a 2D rendering callback to activate its output on each
|
||||
frame after the frame has been drawn and other non-2D render callbacks
|
||||
have been executed.
|
||||
"""
|
||||
bl_idname = 'LNOnRender2DNode'
|
||||
bl_label = 'On Render2D'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
16
leenkx/blender/lnx/logicnode/event/LN_on_timer.py
Normal file
16
leenkx/blender/lnx/logicnode/event/LN_on_timer.py
Normal file
@ -0,0 +1,16 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class OnTimerNode(LnxLogicTreeNode):
|
||||
"""Activates the output when a given time elapsed (optionally repeating the timer).
|
||||
|
||||
@input Duration: the time in seconds after which to activate the output
|
||||
@input Repeat: whether to repeat the timer"""
|
||||
bl_idname = 'LNOnTimerNode'
|
||||
bl_label = 'On Timer'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxFloatSocket', 'Duration')
|
||||
self.add_input('LnxBoolSocket', 'Repeat')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
24
leenkx/blender/lnx/logicnode/event/LN_on_update.py
Normal file
24
leenkx/blender/lnx/logicnode/event/LN_on_update.py
Normal file
@ -0,0 +1,24 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class OnUpdateNode(LnxLogicTreeNode):
|
||||
"""Activates the output on every frame.
|
||||
|
||||
@option Update: (default) activates the output every frame.
|
||||
@option Late Update: activates the output after all non-late updates are calculated.
|
||||
@option Physics Pre-Update: activates the output before calculating the physics.
|
||||
Only available when using a physics engine."""
|
||||
bl_idname = 'LNOnUpdateNode'
|
||||
bl_label = 'On Update'
|
||||
lnx_version = 1
|
||||
property0: HaxeEnumProperty(
|
||||
'property0',
|
||||
items = [('Update', 'Update', 'Update'),
|
||||
('Late Update', 'Late Update', 'Late Update'),
|
||||
('Physics Pre-Update', 'Physics Pre-Update', 'Physics Pre-Update')],
|
||||
name='On', default='Update')
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property0')
|
@ -0,0 +1,27 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class SendEventNode(LnxLogicTreeNode):
|
||||
"""Sends a event to the given object.
|
||||
|
||||
@seeNode Send Event
|
||||
@seeNode On Event
|
||||
|
||||
@input Event: the identifier of the event
|
||||
@input Object: the receiving object"""
|
||||
bl_idname = 'LNSendEventNode'
|
||||
bl_label = 'Send Event to Object'
|
||||
lnx_section = 'custom'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxStringSocket', 'Event')
|
||||
self.add_input('LnxNodeSocketObject', 'Object')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
|
||||
def draw_label(self) -> str:
|
||||
if self.inputs[1].is_linked:
|
||||
return self.bl_label
|
||||
return f'{self.bl_label}: {self.inputs[1].get_default_value()}'
|
25
leenkx/blender/lnx/logicnode/event/LN_send_global_event.py
Normal file
25
leenkx/blender/lnx/logicnode/event/LN_send_global_event.py
Normal file
@ -0,0 +1,25 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class SendGlobalEventNode(LnxLogicTreeNode):
|
||||
"""Sends the given event to all objects in the scene.
|
||||
|
||||
@seeNode Send Event to Object
|
||||
@seeNode On Event
|
||||
|
||||
@input Event: the identifier of the event"""
|
||||
bl_idname = 'LNSendGlobalEventNode'
|
||||
bl_label = 'Send Global Event'
|
||||
lnx_version = 1
|
||||
lnx_section = 'custom'
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxStringSocket', 'Event')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
|
||||
def draw_label(self) -> str:
|
||||
if self.inputs[1].is_linked:
|
||||
return self.bl_label
|
||||
return f'{self.bl_label}: {self.inputs[1].get_default_value()}'
|
4
leenkx/blender/lnx/logicnode/event/__init__.py
Normal file
4
leenkx/blender/lnx/logicnode/event/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
from lnx.logicnode.lnx_nodes import add_node_section
|
||||
|
||||
add_node_section(name='default', category='Event')
|
||||
add_node_section(name='custom', category='Event')
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user