diff --git a/korman/exporter/manager.py b/korman/exporter/manager.py
index 55ffcad..b245750 100644
--- a/korman/exporter/manager.py
+++ b/korman/exporter/manager.py
@@ -13,10 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see .
+from __future__ import annotations
+
import bpy
-from pathlib import Path
from PyHSPlasma import *
-from typing import Iterable
+from typing import *
import weakref
from . import explosions
@@ -214,13 +215,13 @@ class ExportManager:
if isinstance(i, pClass):
yield i
- def find_create_key(self, pClass, bl=None, name=None, so=None):
+ def find_create_key(self, pClass: Type[KeyedT], bl=None, name=None, so=None) -> plKey[KeyedT]:
key = self.find_key(pClass, bl, name, so)
if key is None:
key = self.add_object(pl=pClass, name=name, bl=bl, so=so).key
return key
- def find_key(self, pClass, bl=None, name=None, so=None, loc=None):
+ def find_key(self, pClass: Type[KeyedT], bl=None, name=None, so=None, loc=None) -> Optional[plKey[KeyedT]]:
"""Given a blender Object and a Plasma class, find (or create) an exported plKey"""
if loc is not None:
location = loc
@@ -255,13 +256,16 @@ class ExportManager:
so.addModifier(key)
return key
- def find_create_object(self, pClass, bl=None, name=None, so=None):
+ def find_create_object(
+ self, pClass: Type[KeyedT], bl: bpy.types.Object = None,
+ name: Optional[str] = None, so: Optional[plSceneObject] = None
+ ) -> KeyedT:
key = self.find_key(pClass, bl, name, so)
if key is None:
return self.add_object(pl=pClass, name=name, bl=bl, so=so)
return key.object
- def find_object(self, pClass, bl=None, name=None, so=None):
+ def find_object(self, pClass: Type[KeyedT], bl=None, name=None, so=None) -> Optional[KeyedT]:
key = self.find_key(pClass, bl, name, so)
if key is not None:
return key.object
@@ -306,11 +310,14 @@ class ExportManager:
self._pages[""] = location
return location
- def get_location(self, bl):
+ def get_location(self, bl) -> plLocation:
"""Returns the Page Location of a given Blender Object"""
return self._pages[bl.plasma_object.page]
- def get_scene_node(self, location=None, bl=None):
+ def get_scene_node(
+ self, location: Optional[plLocation] = None,
+ bl: Optional[bpy.types.Object]=None
+ ) -> plSceneNode:
"""Gets a Plasma Page's plSceneNode key"""
assert (location is not None) ^ (bl is not None)
@@ -318,7 +325,7 @@ class ExportManager:
location = self._pages[bl.plasma_object.page]
return self._nodes[location].key
- def get_textures_page(self, key):
+ def get_textures_page(self, key: plKey) -> plLocation:
"""Gets the appropriate page for a texture for a given plLayer"""
# The point of this is to account for per-page textures...
if bpy.context.scene.world.plasma_age.use_texture_page:
diff --git a/korman/nodes/node_core.py b/korman/nodes/node_core.py
index f3958ec..210dc65 100644
--- a/korman/nodes/node_core.py
+++ b/korman/nodes/node_core.py
@@ -13,16 +13,22 @@
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see .
+from __future__ import annotations
+
import abc
import bpy
from bpy.props import *
from PyHSPlasma import *
import time
+from typing import *
from ..exporter import ExportError
+if TYPE_CHECKING:
+ from ..exporter import Exporter
+
class PlasmaNodeBase:
- def generate_notify_msg(self, exporter, so, socket_id, idname=None):
+ def generate_notify_msg(self, exporter: Exporter, so: plSceneObject, socket_id: str, idname: Optional[str] = None) -> plNotifyMsg:
notify = plNotifyMsg()
notify.BCastFlags = (plMessage.kNetPropagate | plMessage.kLocalPropagate)
for i in self.find_outputs(socket_id, idname):
@@ -36,7 +42,7 @@ class PlasmaNodeBase:
notify.addReceiver(key)
return notify
- def get_key(self, exporter, so):
+ def get_key(self, exporter: Exporter, so: plSceneObject):
return None
def get_key_name(self, single, suffix=None, bl=None, so=None):
@@ -59,7 +65,7 @@ class PlasmaNodeBase:
return str(getattr(self, self.pl_label_attrib, self.bl_label))
return self.bl_label
- def export(self, exporter, bo, so):
+ def export(self, exporter: Exporter, bo: bpy.types.Object, so: plSceneObject):
pass
@property
@@ -67,7 +73,7 @@ class PlasmaNodeBase:
"""This node can only be exported once because it is a targeted plSingleModifier"""
return False
- def _find_create_object(self, pClass, exporter, **kwargs):
+ def _find_create_object(self, pClass: Type[KeyedT], exporter: Exporter, **kwargs) -> KeyedT:
"""Finds or creates an hsKeyedObject specific to this node."""
assert "name" not in kwargs
kwargs["name"] = self.get_key_name(issubclass(pClass, (plObjInterface, plSingleModifier)),
@@ -75,7 +81,7 @@ class PlasmaNodeBase:
kwargs.get("so"))
return exporter.mgr.find_create_object(pClass, **kwargs)
- def _find_create_key(self, pClass, exporter, **kwargs):
+ def _find_create_key(self, pClass: Type[KeyedT], exporter: Exporter, **kwargs) -> plKey[KeyedT]:
"""Finds or creates a plKey specific to this node."""
assert "name" not in kwargs
kwargs["name"] = self.get_key_name(issubclass(pClass, (plObjInterface, plSingleModifier)),
@@ -83,7 +89,7 @@ class PlasmaNodeBase:
kwargs.get("so"))
return exporter.mgr.find_create_key(pClass, **kwargs)
- def _find_key(self, pClass, exporter, **kwargs):
+ def _find_key(self, pClass: Type[KeyedT], exporter: Exporter, **kwargs) -> Optional[plKey[KeyedT]]:
"""Finds a plKey specific to this node."""
assert "name" not in kwargs
kwargs["name"] = self.get_key_name(issubclass(pClass, (plObjInterface, plSingleModifier)),
@@ -276,15 +282,15 @@ class PlasmaNodeBase:
link = self.id_data.links.new(in_socket, out_socket)
@property
- def node_path(self):
+ def node_path(self) -> str:
"""Returns an absolute path to this Node. Needed because repr() uses an elipsis..."""
return "{}.{}".format(repr(self.id_data), self.path_from_id())
- def previously_exported(self, exporter):
+ def previously_exported(self, exporter) -> bool:
return self.name in exporter.exported_nodes[self.id_data.name]
@classmethod
- def poll(cls, context):
+ def poll(cls, context) -> bool:
return (context.bl_idname == "PlasmaNodeTree")
def raise_error(self, message):
@@ -292,7 +298,7 @@ class PlasmaNodeBase:
raise ExportError(final)
@property
- def requires_actor(self):
+ def requires_actor(self) -> bool:
return False
@property
diff --git a/korman/nodes/node_responder.py b/korman/nodes/node_responder.py
index 7b90fd1..1e8ffe7 100644
--- a/korman/nodes/node_responder.py
+++ b/korman/nodes/node_responder.py
@@ -13,6 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see .
+from __future__ import annotations
+
import bpy
from bpy.props import *
from collections import OrderedDict
@@ -82,7 +84,7 @@ class PlasmaResponderNode(PlasmaVersionedNode, bpy.types.Node):
layout.prop(self, "detect_untrigger")
layout.prop(self, "no_ff_sounds")
- def get_key(self, exporter, so):
+ def get_key(self, exporter, so) -> plKey[plResponderModifier]:
return self._find_create_key(plResponderModifier, exporter, so=so)
def get_key_name(self, single, suffix=None, bl=None, so=None) -> str: