Browse Source

Improve logic node actor harvesting.

"Improve" is not quite the correct verbiage here because there were bugs
in the old code. The main issue is that any SceneObject with a
plPythonFileMod attached MUST have a CoordinateInterface attached,
otherwise the object would be invisible in game. Further, there were
some unreported oversights with regard to auto-generated modifiers that
have been fixed.
pull/152/head
Adam Johnson 5 years ago
parent
commit
bb40890a67
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 10
      korman/nodes/node_conditions.py
  2. 6
      korman/nodes/node_core.py
  3. 2
      korman/nodes/node_logic.py
  4. 8
      korman/nodes/node_messages.py
  5. 9
      korman/nodes/node_python.py
  6. 2
      korman/properties/modifiers/logic.py

10
korman/nodes/node_conditions.py

@ -141,9 +141,13 @@ class PlasmaClickableNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bpy.types.N
else:
return (None, parent_so)
def harvest_actors(self):
if self.clickable_object:
return (self.clickable_object.name,)
def harvest_actors(self, bo):
actors = set()
if self.clickable_object is not None:
actors.add(self.clickable_object.name)
else:
actors.add(bo.name)
return actors
@classmethod
def _idprop_mapping(cls):

6
korman/nodes/node_core.py

@ -139,7 +139,7 @@ class PlasmaNodeBase:
if idname == node.bl_idname:
yield i
def harvest_actors(self):
def harvest_actors(self, bo):
return set()
@property
@ -368,12 +368,12 @@ class PlasmaNodeTree(bpy.types.NodeTree):
return node
return None
def harvest_actors(self):
def harvest_actors(self, bo):
actors = set()
for node in self.nodes:
harvest_method = getattr(node, "harvest_actors", None)
if harvest_method is not None:
actors.update(harvest_method())
actors.update(harvest_method(bo))
elif not isinstance(node, PlasmaNodeBase):
raise ExportError("Plasma Node Tree '{}' Node '{}': is not a valid node for this tree".format(self.id_data.name, node.name))
return actors

2
korman/nodes/node_logic.py

@ -84,7 +84,7 @@ class PlasmaExcludeRegionNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bpy.typ
self.raise_error("Region must be set")
return exporter.mgr.find_create_key(plExcludeRegionModifier, bl=self.region_object, name=self.key_name)
def harvest_actors(self):
def harvest_actors(self, bo):
return [i.safepoint.name for i in self.find_input_sockets("safe_points") if i.safepoint is not None]
def export(self, exporter, bo, parent_so):

8
korman/nodes/node_messages.py

@ -560,9 +560,13 @@ class PlasmaOneShotMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacks
else:
return exporter.mgr.find_create_key(plOneShotMod, name=name, so=so)
def harvest_actors(self):
def harvest_actors(self, bo):
actors = set()
if self.pos_object:
return (self.pos_object.name,)
actors.add(self.pos_object.name)
else:
actors.add(bo.name)
return actors
@property
def has_callbacks(self):

9
korman/nodes/node_python.py

@ -306,6 +306,15 @@ class PlasmaPythonFileNode(PlasmaVersionedNode, bpy.types.Node):
if i.attribute_id == idx:
yield i
def harvest_actors(self, bo):
actors = set()
actors.add(bo.name)
so_nodes = (i.links[0].from_node for i in self.inputs
if i.is_linked and i.attribute_type in {"ptAttribSceneobject", "ptAttribSceneobjectList"})
actors.update((i.target_object for i in so_nodes if i.target_object is not None))
return actors
@property
def key_name(self):
# PFM names ***must*** be valid Python identifiers, but Blender likes inserting

2
korman/properties/modifiers/logic.py

@ -81,7 +81,7 @@ class PlasmaAdvancedLogic(PlasmaModifierProperties):
actors = set()
for i in self.logic_groups:
if i.node_tree is not None:
actors.update(i.node_tree.harvest_actors())
actors.update(i.node_tree.harvest_actors(self.id_data))
return actors

Loading…
Cancel
Save