Browse Source

The Enable/Disable node now addresses nodes

Benefit: you can now toggle the state of your conditions. OneShot logic
stuff has been updated as well so it all makes sense
pull/11/head
Adam Johnson 9 years ago
parent
commit
9dfab7e660
  1. 11
      korman/nodes/node_conditions.py
  2. 9
      korman/nodes/node_core.py
  3. 57
      korman/nodes/node_messages.py
  4. 17
      korman/nodes/node_responder.py

11
korman/nodes/node_conditions.py

@ -47,9 +47,9 @@ class PlasmaClickableNode(PlasmaNodeBase, bpy.types.Node):
"text": "Avatar Facing Target", "text": "Avatar Facing Target",
"type": "PlasmaFacingTargetSocket", "type": "PlasmaFacingTargetSocket",
}), }),
("enable_callback", { ("message", {
"text": "Local Reenable", "text": "Message",
"type": "PlasmaRespCommandSocket", "type": "PlasmaEnableMessageSocket",
"spawn_empty": True, "spawn_empty": True,
}), }),
]) ])
@ -348,6 +348,11 @@ class PlasmaVolumeSensorNode(PlasmaNodeBase, bpy.types.Node):
"type": "PlasmaVolumeSettingsSocketIn", "type": "PlasmaVolumeSettingsSocketIn",
"valid_link_sockets": {"PlasmaVolumeSettingsSocketOut"}, "valid_link_sockets": {"PlasmaVolumeSettingsSocketOut"},
}), }),
("message", {
"text": "Message",
"type": "PlasmaEnableMessageSocket",
"spawn_empty": True,
}),
]) ])
output_sockets = OrderedDict([ output_sockets = OrderedDict([

9
korman/nodes/node_core.py

@ -240,6 +240,15 @@ class PlasmaNodeSocketBase:
return bool(self.links) return bool(self.links)
class PlasmaNodeSocketInputGeneral(PlasmaNodeSocketBase, bpy.types.NodeSocket):
"""A general input socket that will steal the output's color"""
def draw_color(self, context, node):
if self.is_linked:
return self.links[0].from_socket.draw_color(context, node)
else:
return (0.0, 0.0, 0.0, 0.0)
class PlasmaNodeTree(bpy.types.NodeTree): class PlasmaNodeTree(bpy.types.NodeTree):
bl_idname = "PlasmaNodeTree" bl_idname = "PlasmaNodeTree"
bl_label = "Plasma" bl_label = "Plasma"

57
korman/nodes/node_messages.py

@ -228,13 +228,19 @@ class PlasmaEnableMsgNode(PlasmaMessageNode, bpy.types.Node):
bl_idname = "PlasmaEnableMsgNode" bl_idname = "PlasmaEnableMsgNode"
bl_label = "Enable/Disable" bl_label = "Enable/Disable"
output_sockets = OrderedDict([
("receivers", {
"text": "Send To",
"type": "PlasmaEnableMessageSocket",
"valid_link_sockets": {"PlasmaEnableMessageSocket", "PlasmaNodeSocketInputGeneral"},
}),
])
cmd = EnumProperty(name="Command", cmd = EnumProperty(name="Command",
description="How should we affect the object's state?", description="How should we affect the object's state?",
items=[("kDisable", "Disable", "Deactivate the object"), items=[("kDisable", "Disable", "Deactivate the object"),
("kEnable", "Enable", "Activate the object")], ("kEnable", "Enable", "Activate the object")],
default="kEnable") default="kEnable")
object_name = StringProperty(name="Object",
description="Object whose state we are changing")
settings = EnumProperty(name="Affects", settings = EnumProperty(name="Affects",
description="Which attributes should we change", description="Which attributes should we change",
items=[("kAudible", "Audio", "Sounds played by this object"), items=[("kAudible", "Audio", "Sounds played by this object"),
@ -245,10 +251,13 @@ class PlasmaEnableMsgNode(PlasmaMessageNode, bpy.types.Node):
def convert_message(self, exporter, so): def convert_message(self, exporter, so):
msg = plEnableMsg() msg = plEnableMsg()
target_bo = bpy.data.objects.get(self.object_name, None) for i in self.find_outputs("receivers"):
if target_bo is None: key = i.get_key(exporter, so)
self.raise_error("target object '{}' is invalid".format(self.object_name)) if isinstance(key, tuple):
msg.addReceiver(exporter.mgr.find_create_key(plSceneObject, bl=target_bo)) for j in key:
msg.addReceiver(j)
else:
msg.addReceiver(key)
msg.setCmd(getattr(plEnableMsg, self.cmd), True) msg.setCmd(getattr(plEnableMsg, self.cmd), True)
# If we have a full house, let's send it to all the SO's generic modifiers as by compressing # If we have a full house, let's send it to all the SO's generic modifiers as by compressing
@ -263,11 +272,14 @@ class PlasmaEnableMsgNode(PlasmaMessageNode, bpy.types.Node):
return msg return msg
def draw_buttons(self, context, layout): def draw_buttons(self, context, layout):
layout.prop(self, "cmd") layout.prop(self, "cmd", text="Cmd")
layout.prop_search(self, "object_name", bpy.data, "objects")
layout.prop(self, "settings") layout.prop(self, "settings")
class PlasmaEnableMessageSocket(PlasmaNodeSocketBase, bpy.types.NodeSocket):
bl_color = (0.427, 0.196, 0.0, 1.0)
class PlasmaExcludeRegionMsg(PlasmaMessageNode, bpy.types.Node): class PlasmaExcludeRegionMsg(PlasmaMessageNode, bpy.types.Node):
bl_category = "MSG" bl_category = "MSG"
bl_idname = "PlasmaExcludeRegionMsg" bl_idname = "PlasmaExcludeRegionMsg"
@ -376,6 +388,35 @@ class PlasmaOneShotCallbackSocket(PlasmaMessageSocketBase, bpy.types.NodeSocket)
layout.prop(self, "marker") layout.prop(self, "marker")
class PlasmaSceneObjectMsgRcvrNode(PlasmaNodeBase, bpy.types.Node):
bl_category = "MSG"
bl_idname = "PlasmaSceneObjectMsgRcvrNode"
bl_label = "Send To Object"
bl_width_default = 190
input_sockets = OrderedDict([
("message", {
"text": "Message",
"type": "PlasmaNodeSocketInputGeneral",
"valid_link_sockets": {"PlasmaEnableMessageSocket"},
"spawn_empty": True,
}),
])
object_name = StringProperty(name="Object",
description="Object to send the message to")
def draw_buttons(self, context, layout):
layout.prop_search(self, "object_name", bpy.data, "objects")
def get_key(self, exporter, so):
bo = bpy.data.objects.get(self.object_name, None)
if bo is None:
self.raise_error("invalid object specified: '{}'".format(self.object_name))
ref_so_key = exporter.mgr.find_create_key(plSceneObject, bl=bo)
return ref_so_key
class PlasmaTimerCallbackMsgNode(PlasmaMessageNode, bpy.types.Node): class PlasmaTimerCallbackMsgNode(PlasmaMessageNode, bpy.types.Node):
bl_category = "MSG" bl_category = "MSG"
bl_idname = "PlasmaTimerCallbackMsgNode" bl_idname = "PlasmaTimerCallbackMsgNode"

17
korman/nodes/node_responder.py

@ -210,9 +210,6 @@ class PlasmaResponderCommandNode(PlasmaNodeBase, bpy.types.Node):
("whodoneit", { ("whodoneit", {
"text": "Condition", "text": "Condition",
"type": "PlasmaRespCommandSocket", "type": "PlasmaRespCommandSocket",
# command sockets are on some unrelated outputs...
"valid_link_nodes": {"PlasmaResponderCommandNode", "PlasmaResponderStateNode"},
"valid_link_sockets": {"PlasmaRespCommandSocket"},
}), }),
]) ])
@ -226,6 +223,10 @@ class PlasmaResponderCommandNode(PlasmaNodeBase, bpy.types.Node):
"text": "Trigger", "text": "Trigger",
"type": "PlasmaRespCommandSocket", "type": "PlasmaRespCommandSocket",
}), }),
("reenable", {
"text": "Local Reenable",
"type": "PlasmaEnableMessageSocket",
}),
]) ])
def convert_command(self, exporter, so, responder, commandMgr, waitOn=-1): def convert_command(self, exporter, so, responder, commandMgr, waitOn=-1):
@ -249,12 +250,14 @@ class PlasmaResponderCommandNode(PlasmaNodeBase, bpy.types.Node):
else: else:
childWaitOn = waitOn childWaitOn = waitOn
command.msg = msg command.msg = msg
else:
childWaitOn = waitOn
# If they linked us back to a condition or something that exports a LogicModifier, that # If they linked us back to a condition or something that exports a LogicModifier, that
# means we need to reenable it here... NOTE: we can't filter by the node idname, sadly. # means we need to reenable it here... NOTE: it would be incredibly stupid to do this
# NOTE: would be incredibly stupid to do this if we're not waiting on anything to complete # if we're not waiting on anything to complete
if childWaitOn != -1: if childWaitOn != -1:
for child in self.find_outputs("trigger"): for child in self.find_outputs("reenable"):
key = child.get_key(exporter, so) key = child.get_key(exporter, so)
if key is None: if key is None:
continue continue
@ -271,8 +274,6 @@ class PlasmaResponderCommandNode(PlasmaNodeBase, bpy.types.Node):
enableMsg.setCmd(plEnableMsg.kEnable, True) enableMsg.setCmd(plEnableMsg.kEnable, True)
logicCmdIdx, logicCmd = commandMgr.add_command(self, childWaitOn) logicCmdIdx, logicCmd = commandMgr.add_command(self, childWaitOn)
logicCmd.msg = enableMsg logicCmd.msg = enableMsg
else:
childWaitOn = waitOn
# Export any child commands # Export any child commands
for i in self.find_outputs("trigger", "PlasmaResponderCommandNode"): for i in self.find_outputs("trigger", "PlasmaResponderCommandNode"):

Loading…
Cancel
Save