Browse Source

Convert xSitCam.py to regular engine features.

Using standard engine features should make the Ages generated by Korman
more robust. Also, any time we can avoid calling into Python, that's a
performance win.
master
Adam Johnson 3 days ago
parent
commit
3939f6e642
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 25
      korman/properties/modifiers/avatar.py
  2. 31
      korman/properties/modifiers/base.py

25
korman/properties/modifiers/avatar.py

@ -128,15 +128,24 @@ class PlasmaSittingBehavior(idprops.IDPropObjectMixin, PlasmaModifierProperties,
sittingmod = nodes.new("PlasmaSittingBehaviorNode")
sittingmod.approach = self.approach
sittingmod.name = "SittingBeh"
# xSitCam.py PythonFileMod
if self.sitting_camera is not None:
sittingpynode = self._create_python_standard_file_node(tree, "xSitCam.py")
sittingmod.link_output(sittingpynode, "satisfies", "sitAct")
# Camera Object
cameraobj = nodes.new("PlasmaAttribObjectNode")
cameraobj.link_output(sittingpynode, "pfm", "sitCam")
cameraobj.target_object = self.sitting_camera
# Sitting Camera handling
if self.sitting_camera is not None:
sitDownRespNode = self._create_responder_nodes(
tree,
("PlasmaCameraMsgNode", { "camera": self.sitting_camera, "cmd": "push" }),
detect_trigger=True, detect_untrigger=False,
name="SitDown"
)
standUpRespNode = self._create_responder_nodes(
tree,
("PlasmaCameraMsgNode", { "camera": self.sitting_camera, "cmd": "pop" }),
detect_trigger=False, detect_untrigger=True,
name="StandUp"
)
sittingmod.link_output(sitDownRespNode, "satisfies", "condition")
sittingmod.link_output(standUpRespNode, "satisfies", "condition")
# Clickable
clickable = nodes.new("PlasmaClickableNode")

31
korman/properties/modifiers/base.py

@ -24,6 +24,7 @@ from typing import *
if TYPE_CHECKING:
from ...nodes.node_python import *
from ...nodes.node_responder import *
from ... import helpers
from ... import plasma_api
@ -237,6 +238,36 @@ class PlasmaModifierLogicWiz:
setattr(node, i, j)
return node
def _create_responder_nodes(
self, tree: bpy.types.NodeGroup,
*messages: Tuple[str, Dict[str, Any]],
**responder_settings
) -> PlasmaResponderNode:
"""Creates and links together a Responder node tree. Each message sould be specified by a tuple
of string message type and a dict of attributes to set on the message node. Messages will be
created and linked in the order they are specified, including any callback waits if needed.
Attributes on the responder node can be set by passing them in as keyword arguments.
"""
nodes = tree.nodes
respNode = nodes.new("PlasmaResponderNode")
for attr, value in responder_settings.items():
setattr(respNode, attr, value)
respStateNode = nodes.new("PlasmaResponderStateNode")
respNode.link_output(respStateNode, "state_refs", "resp")
linkMsgTo = respStateNode
for msgNodeType, msgNodeAttrs in messages:
msgNode = nodes.new(msgNodeType)
for attr, value in msgNodeAttrs.items():
setattr(msgNode, attr, value)
linkMsgTo.link_output(msgNode, "msgs", "sender")
if msgNode.has_callbacks and msgNode.can_link_callbacks:
linkMsgTo = msgNode
return respNode
@abc.abstractmethod
def logicwiz(self, bo, tree):
pass

Loading…
Cancel
Save