Browse Source

Allow message nodes to export multiple messages

This shim is needed in some cases for plSoundMsg
pull/35/head
Adam Johnson 9 years ago
parent
commit
8e262f815c
  1. 26
      korman/nodes/node_responder.py

26
korman/nodes/node_responder.py

@ -16,6 +16,7 @@
import bpy import bpy
from bpy.props import * from bpy.props import *
from collections import OrderedDict from collections import OrderedDict
import inspect
from PyHSPlasma import * from PyHSPlasma import *
import uuid import uuid
@ -230,16 +231,28 @@ class PlasmaResponderCommandNode(PlasmaNodeBase, bpy.types.Node):
]) ])
def convert_command(self, exporter, so, responder, commandMgr, waitOn=-1): def convert_command(self, exporter, so, responder, commandMgr, waitOn=-1):
# If this command has no message, there is no need to export it... def prepare_message(exporter, so, responder, commandMgr, waitOn, msg):
msgNode = self.find_output("msg")
if msgNode is not None:
idx, command = commandMgr.add_command(self, waitOn) idx, command = commandMgr.add_command(self, waitOn)
# Finally, convert our message...
msg = msgNode.convert_message(exporter, so)
if msg.sender is None: if msg.sender is None:
msg.sender = responder.key msg.sender = responder.key
msg.BCastFlags |= plMessage.kLocalPropagate msg.BCastFlags |= plMessage.kLocalPropagate
command.msg = msg
return (idx, command)
# If this command has no message, there is no need to export it...
msgNode = self.find_output("msg")
if msgNode is not None:
# HACK: Some message nodes may need to sneakily send multiple messages. So, convert_message
# is therefore now a generator. We will ASSume that the first message generated is the
# primary msg that we should use for callbacks, if applicable
if inspect.isgeneratorfunction(msgNode.convert_message):
messages = tuple(msgNode.convert_message(exporter, so))
msg = messages[0]
for i in messages[1:]:
prepare_message(exporter, so, responder, commandMgr, waitOn, i)
else:
msg = msgNode.convert_message(exporter, so)
idx, command = prepare_message(exporter, so, responder, commandMgr, waitOn, msg)
# If we have child commands, we need to make sure that we support chaining this message as a callback # If we have child commands, we need to make sure that we support chaining this message as a callback
# If not, we'll export our children and tell them to not actually wait on us. # If not, we'll export our children and tell them to not actually wait on us.
@ -249,7 +262,6 @@ class PlasmaResponderCommandNode(PlasmaNodeBase, bpy.types.Node):
msgNode.convert_callback_message(exporter, so, msg, responder.key, childWaitOn) msgNode.convert_callback_message(exporter, so, msg, responder.key, childWaitOn)
else: else:
childWaitOn = waitOn childWaitOn = waitOn
command.msg = msg
else: else:
childWaitOn = waitOn childWaitOn = waitOn

Loading…
Cancel
Save