Browse Source

Removed the `OrderedDict`s (#400)

* Removed the `OrderedDict`s

* Changed some stuff from the code review

* Fixed a typo

* Added these imports: `from __future__ import annotations`
and `from typing import *`

* Moved `from __future__ import annotations` to the top.

* Changed type annotation `any`s to `Any`
pull/399/head
1Codealot 11 months ago committed by GitHub
parent
commit
969911b117
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 98
      korman/nodes/node_avatar.py
  2. 77
      korman/nodes/node_conditions.py
  3. 28
      korman/nodes/node_deprecated.py
  4. 24
      korman/nodes/node_logic.py
  5. 50
      korman/nodes/node_messages.py
  6. 58
      korman/nodes/node_responder.py
  7. 72
      korman/nodes/node_softvolume.py

98
korman/nodes/node_avatar.py

@ -13,9 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
import bpy
from bpy.props import *
from collections import OrderedDict
from typing import *
from PyHSPlasma import *
from .node_core import PlasmaNodeBase, PlasmaNodeSocketBase
@ -36,20 +38,20 @@ class PlasmaSittingBehaviorNode(PlasmaNodeBase, bpy.types.Node):
default={"kApproachFront", "kApproachLeft", "kApproachRight"},
options={"ENUM_FLAG"})
input_sockets = OrderedDict([
("condition", {
input_sockets: dict[str, dict[str, str]] = {
"condition": {
"text": "Condition",
"type": "PlasmaConditionSocket",
}),
])
},
}
output_sockets = OrderedDict([
("satisfies", {
output_sockets: dict[str, dict[str, Any]] = {
"satisfies": {
"text": "Satisfies",
"type": "PlasmaConditionSocket",
"valid_link_sockets": {"PlasmaConditionSocket", "PlasmaPythonFileNodeSocket"},
}),
])
},
}
def draw_buttons(self, context, layout):
col = layout.column()
@ -170,31 +172,31 @@ class PlasmaAnimStageSettingsNode(PlasmaNodeBase, bpy.types.Node):
default={"kNotifyEnter"},
options={"ENUM_FLAG"})
input_sockets = OrderedDict([
("advance_to", {
input_sockets: dict[str, dict[str, Any]] = {
"advance_to": {
"text": "Advance to Stage",
"type": "PlasmaAnimStageAdvanceSocketIn",
"valid_link_nodes": "PlasmaAnimStageNode",
"valid_link_sockets": "PlasmaAnimStageOrderSocketOut",
"link_limit": 1,
}),
("regress_to", {
},
"regress_to": {
"text": "Regress to Stage",
"type": "PlasmaAnimStageRegressSocketIn",
"valid_link_nodes": "PlasmaAnimStageNode",
"valid_link_sockets": "PlasmaAnimStageOrderSocketOut",
"link_limit": 1,
}),
])
},
}
output_sockets = OrderedDict([
("stage", {
output_sockets: dict[str, dict[str, str]] = {
"stage": {
"text": "Stage",
"type": "PlasmaAnimStageSettingsSocket",
"valid_link_nodes": "PlasmaAnimStageNode",
"valid_link_sockets": "PlasmaAnimStageSettingsSocket",
}),
])
},
}
def draw_buttons(self, context, layout):
layout.prop(self, "forward")
@ -230,30 +232,30 @@ class PlasmaAnimStageNode(PlasmaNodeBase, bpy.types.Node):
description="Number of times to loop animation",
default=0)
input_sockets = OrderedDict([
("stage_settings", {
input_sockets: dict[str, dict[str, Any]] = {
"stage_settings": {
"text": "Stage Settings",
"type": "PlasmaAnimStageSettingsSocket",
"valid_link_nodes": "PlasmaAnimStageSettingsNode",
"valid_link_sockets": "PlasmaAnimStageSettingsSocket",
"link_limit": 1,
}),
])
},
}
output_sockets = OrderedDict([
("stage", {
output_sockets: dict[str, Any] = {
"stage": {
"text": "Behavior",
"type": "PlasmaAnimStageRefSocket",
"valid_link_nodes": "PlasmaMultiStageBehaviorNode",
"valid_link_sockets": "PlasmaAnimStageRefSocket",
}),
("stage_reference", {
},
"stage_reference": {
"text": "Stage Progression",
"type": "PlasmaAnimStageOrderSocketOut",
"valid_link_nodes": "PlasmaAnimStageSettingsNode",
"valid_link_sockets": {"PlasmaAnimStageAdvanceSocketIn", "PlasmaAnimStageRegressSocketIn"} ,
}),
])
},
}
def draw_buttons(self, context, layout):
layout.prop(self, "anim_name")
@ -293,39 +295,39 @@ class PlasmaMultiStageBehaviorNode(PlasmaNodeBase, bpy.types.Node):
description="Reverse forward/back controls at end",
default=False)
input_sockets = OrderedDict([
("seek_target", {
input_sockets: dict[str, Any] = {
"seek_target": {
"text": "Seek Target",
"type": "PlasmaSeekTargetSocketIn",
"valid_link_sockets": "PlasmaSeekTargetSocketOut",
}),
("stage_refs", {
},
"stage_refs": {
"text": "Stage",
"type": "PlasmaAnimStageRefSocket",
"valid_link_nodes": "PlasmaAnimStageNode",
"valid_link_sockets": "PlasmaAnimStageRefSocket",
"link_limit": 1,
"spawn_empty": True,
}),
("condition", {
},
"condition": {
"text": "Triggered By",
"type": "PlasmaConditionSocket",
"spawn_empty": True,
}),
])
},
}
output_sockets = OrderedDict([
("hosts", {
output_sockets: dict[str, Any] = {
"hosts": {
"text": "Host Script",
"type": "PlasmaBehaviorSocket",
"valid_link_nodes": {"PlasmaPythonFileNode"},
"valid_link_nodes": "PlasmaPythonFileNode",
"spawn_empty": True,
}),
("satisfies", {
},
"satisfies": {
"text": "Trigger",
"type": "PlasmaConditionSocket",
})
])
}
}
def draw_buttons(self, context, layout):
layout.prop(self, "freeze_phys")
@ -463,14 +465,14 @@ class PlasmaSeekTargetNode(PlasmaNodeBase, bpy.types.Node):
description="Object defining the Seek Point's position",
type=bpy.types.Object)
output_sockets = OrderedDict([
("seekers", {
output_sockets: dict[str, Any] = {
"seekers": {
"text": "Seekers",
"type": "PlasmaSeekTargetSocketOut",
"valid_link_nodes": {"PlasmaMultiStageBehaviorNode", "PlasmaOneShotMsgNode"},
"valid_link_sockets": {"PlasmaSeekTargetSocketIn"},
})
])
},
}
def draw_buttons(self, context, layout):
col = layout.column()

77
korman/nodes/node_conditions.py

@ -17,7 +17,6 @@ from __future__ import annotations
import bpy
from bpy.props import *
from collections import OrderedDict
import math
from PyHSPlasma import *
from typing import *
@ -44,29 +43,29 @@ class PlasmaClickableNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bpy.types.N
items=bounds_types,
default="hull")
input_sockets = OrderedDict([
("region", {
input_sockets: dict[str, Any] = {
"region": {
"text": "Avatar Inside Region",
"type": "PlasmaClickableRegionSocket",
}),
("facing", {
},
"facing": {
"text": "Avatar Facing Target",
"type": "PlasmaFacingTargetSocket",
}),
("message", {
},
"message": {
"text": "Message",
"type": "PlasmaEnableMessageSocket",
"spawn_empty": True,
}),
])
},
}
output_sockets = OrderedDict([
("satisfies", {
output_sockets: dict[str, dict[str, Any]] = {
"satisfies": {
"text": "Satisfies",
"type": "PlasmaConditionSocket",
"valid_link_sockets": {"PlasmaConditionSocket", "PlasmaPythonFileNodeSocket"},
}),
])
},
}
def draw_buttons(self, context, layout):
layout.prop(self, "clickable_object", icon="MESH_DATA")
@ -168,12 +167,12 @@ class PlasmaClickableRegionNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bpy.t
items=bounds_types,
default="hull")
output_sockets = OrderedDict([
("satisfies", {
output_sockets = {
"satisfies": {
"text": "Satisfies",
"type": "PlasmaClickableRegionSocket",
}),
])
},
}
def draw_buttons(self, context, layout):
layout.prop(self, "region_object", icon="MESH_DATA")
@ -280,13 +279,13 @@ class PlasmaFacingTargetNode(PlasmaNodeBase, bpy.types.Node):
get=_get_tolerance, set=_set_tolerance,
subtype="ANGLE", options=set())
output_sockets = OrderedDict([
("satisfies", {
output_sockets: dict[str, dict[str, Any]] = {
"satisfies": {
"text": "Satisfies",
"type": "PlasmaFacingTargetSocket",
"link_limit": 1,
}),
])
},
}
def _draw_sub_prop(self, layout, prop_name, *, active=True, sidebar=False, **kwargs):
sub = layout.row() if sidebar else layout.column()
@ -380,13 +379,13 @@ class PlasmaVolumeReportNode(PlasmaNodeBase, bpy.types.Node):
description="How many objects should be in the region for it to trigger",
min=0)
output_sockets = OrderedDict([
("settings", {
output_sockets: dict[str, dict[str, Any]] = {
"settings": {
"text": "Trigger Settings",
"type": "PlasmaVolumeSettingsSocketOut",
"valid_link_sockets": {"PlasmaVolumeSettingsSocketIn"},
}),
])
},
}
def draw_buttons(self, context, layout):
layout.prop(self, "report_when")
@ -433,35 +432,35 @@ class PlasmaVolumeSensorNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bpy.type
default={"kGroupAvatar"},
update=_update_report_on)
input_sockets = OrderedDict([
("facing", {
input_sockets: dict[str, dict[str, Any]] = {
"facing": {
"text": "Avatar Facing Target",
"type": "PlasmaFacingTargetSocket",
}),
("enter", {
},
"enter": {
"text": "Trigger on Enter",
"type": "PlasmaVolumeSettingsSocketIn",
"valid_link_sockets": {"PlasmaVolumeSettingsSocketOut"},
}),
("exit", {
},
"exit": {
"text": "Trigger on Exit",
"type": "PlasmaVolumeSettingsSocketIn",
"valid_link_sockets": {"PlasmaVolumeSettingsSocketOut"},
}),
("message", {
},
"message": {
"text": "Message",
"type": "PlasmaEnableMessageSocket",
"spawn_empty": True,
}),
])
},
}
output_sockets = OrderedDict([
("satisfies", {
output_sockets: dict[str, dict[str, Any]] = {
"satisfies": {
"text": "Satisfies",
"type": "PlasmaConditionSocket",
"valid_link_sockets": {"PlasmaConditionSocket", "PlasmaPythonFileNodeSocket"},
}),
])
},
}
def init(self, context):
# The default value for the facing socket is a bit silly for this node type.

28
korman/nodes/node_deprecated.py

@ -13,10 +13,12 @@
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
import abc
import bpy
from typing import *
from bpy.props import *
from collections import OrderedDict
from .node_core import *
@ -53,28 +55,28 @@ class PlasmaResponderCommandNode(PlasmaDeprecatedNode, bpy.types.Node):
bl_idname = "PlasmaResponderCommandNode"
bl_label = "Responder Command"
input_sockets = OrderedDict([
("whodoneit", {
input_sockets: dict[str, dict[str, str]] = {
"whodoneit": {
"text": "Condition",
"type": "PlasmaRespCommandSocket",
}),
])
},
}
output_sockets = OrderedDict([
("msg", {
output_sockets: dict[str, Any] = {
"msg": {
"link_limit": 1,
"text": "Message",
"type": "PlasmaMessageSocket",
}),
("trigger", {
},
"trigger": {
"text": "Trigger",
"type": "PlasmaRespCommandSocket",
}),
("reenable", {
},
"reenable": {
"text": "Local Reenable",
"type": "PlasmaEnableMessageSocket",
}),
])
},
}
def _find_message_sender_node(self, parentCmdNode=None):
if parentCmdNode is None:

24
korman/nodes/node_logic.py

@ -13,9 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
import bpy
from bpy.props import *
from collections import OrderedDict
from typing import *
from PyHSPlasma import *
from .node_core import *
@ -51,28 +53,28 @@ class PlasmaExcludeRegionNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bpy.typ
block_cameras = BoolProperty(name="Block Cameras",
description="The region blocks cameras when it has been cleared")
input_sockets = OrderedDict([
("safe_point", {
input_sockets:dict[str, dict[str, Any]] = {
"safe_point": {
"type": "PlasmaExcludeSafePointSocket",
"text": "Safe Point",
"spawn_empty": True,
# This never links to anything...
"valid_link_sockets": frozenset(),
}),
("msg", {
},
"msg": {
"type": "PlasmaExcludeMessageSocket",
"text": "Message",
"spawn_empty": True,
}),
])
},
}
output_sockets = OrderedDict([
("keyref", {
output_sockets: dict[str, dict[str, Any]] = {
"keyref": {
"text": "References",
"type": "PlasmaPythonReferenceNodeSocket",
"valid_link_nodes": {"PlasmaPythonFileNode"},
}),
])
},
}
def draw_buttons(self, context, layout):
layout.prop(self, "region_object", icon="MESH_DATA")

50
korman/nodes/node_messages.py

@ -19,7 +19,6 @@ import bpy
from bpy.props import *
from PyHSPlasma import *
from collections import OrderedDict
from typing import *
from .node_core import *
@ -38,14 +37,15 @@ class PlasmaMessageSocket(PlasmaMessageSocketBase, bpy.types.NodeSocket):
class PlasmaMessageNode(PlasmaNodeBase):
input_sockets = OrderedDict([
("sender", {
input_sockets: dict[str, dict[str, Any]] = {
"sender": {
"text": "Sender",
"type": "PlasmaMessageSocket",
"valid_link_sockets": "PlasmaMessageSocket",
"spawn_empty": True,
}),
])
},
}
@property
def has_callbacks(self):
@ -54,14 +54,14 @@ class PlasmaMessageNode(PlasmaNodeBase):
class PlasmaMessageWithCallbacksNode(PlasmaMessageNode):
output_sockets = OrderedDict([
("msgs", {
soutput_sockets: dict[str, dict[str, str]] = {
"msgs": {
"can_link": "can_link_callback",
"text": "Send On Completion",
"type": "PlasmaMessageSocket",
"valid_link_sockets": "PlasmaMessageSocket",
}),
])
},
}
@property
def can_link_callback(self):
@ -404,13 +404,13 @@ class PlasmaEnableMsgNode(PlasmaMessageNode, bpy.types.Node):
bl_idname = "PlasmaEnableMsgNode"
bl_label = "Enable/Disable"
output_sockets = OrderedDict([
("receivers", {
output_sockets: dict[str, dict[str, Any]] = {
"receivers": {
"text": "Send To",
"type": "PlasmaEnableMessageSocket",
"valid_link_sockets": {"PlasmaEnableMessageSocket", "PlasmaNodeSocketInputGeneral"},
}),
])
},
}
cmd = EnumProperty(name="Command",
description="How should we affect the object's state?",
@ -499,12 +499,12 @@ class PlasmaExcludeRegionMsg(PlasmaMessageNode, bpy.types.Node):
bl_idname = "PlasmaExcludeRegionMsg"
bl_label = "Exclude Region"
output_sockets = OrderedDict([
("region", {
output_sockets: dict[str, dict[str, str]] = {
"region": {
"text": "Region",
"type": "PlasmaExcludeMessageSocket"
}),
])
},
}
cmd = EnumProperty(name="Command",
description="Exclude Region State",
@ -703,14 +703,14 @@ class PlasmaSceneObjectMsgRcvrNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bp
bl_label = "Send To Object"
bl_width_default = 190
input_sockets = OrderedDict([
("message", {
input_sockets: dict[str, dict[str, Any]]= {
"message": {
"text": "Message",
"type": "PlasmaNodeSocketInputGeneral",
"valid_link_sockets": {"PlasmaEnableMessageSocket"},
"spawn_empty": True,
}),
])
},
}
target_object = PointerProperty(name="Object",
description="Object to send the message to",
@ -1030,15 +1030,15 @@ class PlasmaTriggerMultiStageMsgNode(PlasmaMessageNode, bpy.types.Node):
bl_idname = "PlasmaTriggerMultiStageMsgNode"
bl_label = "Trigger MultiStage"
output_sockets = OrderedDict([
("satisfies", {
output_sockets: dict[str, dict[str, Any]] = {
"satisfies": {
"text": "Trigger",
"type": "PlasmaConditionSocket",
"valid_link_nodes": "PlasmaMultiStageBehaviorNode",
"valid_link_sockets": "PlasmaConditionSocket",
"link_limit": 1,
})
])
}
}
def convert_message(self, exporter, so):
# Yeah, this is not a REAL Plasma message, but the Korman way is to try to hide these little

58
korman/nodes/node_responder.py

@ -17,7 +17,7 @@ from __future__ import annotations
import bpy
from bpy.props import *
from collections import OrderedDict
from typing import *
import inspect
from PyHSPlasma import *
import uuid
@ -46,38 +46,38 @@ class PlasmaResponderNode(PlasmaVersionedNode, bpy.types.Node):
default_state = IntProperty(name="Default State Index",
options=set())
input_sockets = OrderedDict([
("condition", {
input_sockets: dict[str, dict[str, Any]] = {
"condition": {
"text": "Condition",
"type": "PlasmaConditionSocket",
"spawn_empty": True,
}),
])
},
}
output_sockets = OrderedDict([
("keyref", {
output_sockets: dict[str, dict[str, Any]] = {
"keyref": {
"text": "References",
"type": "PlasmaPythonReferenceNodeSocket",
"valid_link_nodes": {"PlasmaPythonFileNode"},
}),
("state_refs", {
},
"state_refs": {
"text": "State",
"type": "PlasmaRespStateRefSocket",
"valid_link_nodes": "PlasmaResponderStateNode",
"valid_link_sockets": "PlasmaRespStateRefSocket",
"link_limit": 1,
"spawn_empty": True,
}),
},
# This version of the states socket has been deprecated.
# We need to be able to track 1 socket -> 1 state to manage
# responder state IDs
("states", {
"states": {
"text": "States",
"type": "PlasmaRespStateSocket",
"hidden": True,
}),
])
}
}
def draw_buttons(self, context, layout):
layout.prop(self, "detect_trigger")
@ -227,40 +227,40 @@ class PlasmaResponderStateNode(PlasmaNodeBase, bpy.types.Node):
set=_set_default_state,
options=set())
input_sockets = OrderedDict([
("condition", {
input_sockets: dict[str, Any] = {
"condition": {
"text": "Triggers State",
"type": "PlasmaRespStateSocket",
"spawn_empty": True,
}),
("resp", {
},
"resp": {
"text": "Responder",
"type": "PlasmaRespStateRefSocket",
"valid_link_nodes": "PlasmaResponderNode",
"valid_link_sockets": "PlasmaRespStateRefSocket",
}),
])
},
}
output_sockets = OrderedDict([
output_sockets = {
# This socket has been deprecated.
("cmds", {
# While this is deprecated I might as well also convert it.
"cmds": {
"text": "Commands",
"type": "PlasmaRespCommandSocket",
"hidden": True,
}),
# These sockets are valid.
("msgs", {
},
# These ones are valid.
"msgs": {
"text": "Send Message",
"type": "PlasmaMessageSocket",
"valid_link_sockets": "PlasmaMessageSocket",
}),
("gotostate", {
},
"gotostate": {
"link_limit": 1,
"text": "Triggers State",
"type": "PlasmaRespStateSocket",
}),
])
},
}
def draw_buttons(self, context, layout):
layout.active = self.find_input("resp") is not None

72
korman/nodes/node_softvolume.py

@ -13,9 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
import bpy
from bpy.props import *
from collections import OrderedDict
from typing import *
from PyHSPlasma import *
from .node_core import PlasmaNodeBase, PlasmaNodeSocketBase, PlasmaTreeOutputNodeBase
@ -26,12 +28,12 @@ class PlasmaSoftVolumeOutputNode(PlasmaTreeOutputNodeBase, bpy.types.Node):
bl_idname = "PlasmaSoftVolumeOutputNode"
bl_label = "Soft Volume Output"
input_sockets = OrderedDict([
("input", {
input_sockets: dict[str, dict[str, str]] = {
"input": {
"text": "Final Volume",
"type": "PlasmaSoftVolumeNodeSocket",
}),
])
},
}
def get_key(self, exporter, so):
svNode = self.find_input("input")
@ -51,12 +53,12 @@ class PlasmaSoftVolumePropertiesNode(PlasmaNodeBase, bpy.types.Node):
bl_idname = "PlasmaSoftVolumePropertiesNode"
bl_label = "Soft Volume Properties"
output_sockets = OrderedDict([
("target", {
output_sockets: dict[str, dict[str, str]] = {
"target": {
"text": "Volume",
"type": "PlasmaSoftVolumePropertiesNodeSocket"
}),
])
},
}
inside_strength = IntProperty(name="Inside", description="Strength inside the region",
subtype="PERCENTAGE", default=100, min=0, max=100)
@ -78,12 +80,12 @@ class PlasmaSoftVolumeReferenceNode(idprops.IDPropObjectMixin, PlasmaNodeBase, b
bl_label = "Soft Region"
bl_width_default = 150
output_sockets = OrderedDict([
("output", {
output_sockets: dict[str, dict[str, str]] = {
"output": {
"text": "Volume",
"type": "PlasmaSoftVolumeNodeSocket"
}),
])
},
}
soft_volume = PointerProperty(name="Soft Volume",
description="Object whose Soft Volume modifier we should use",
@ -111,23 +113,23 @@ class PlasmaSoftVolumeInvertNode(PlasmaNodeBase, bpy.types.Node):
bl_label = "Soft Volume Invert"
# The only difference between this and PlasmaSoftVolumeLinkNode is this can only have ONE input
input_sockets = OrderedDict([
("properties", {
input_sockets: dict[str, dict[str, str]] = {
"properties": {
"text": "Properties",
"type": "PlasmaSoftVolumePropertiesNodeSocket",
}),
("input", {
},
"input": {
"text": "Input Volume",
"type": "PlasmaSoftVolumeNodeSocket",
}),
])
},
}
output_sockets = OrderedDict([
("output", {
"text": "Output Volume",
output_sockets: dict[str, dict[str, str]] = {
"output": {
"text": "Volume",
"type": "PlasmaSoftVolumeNodeSocket"
}),
])
},
}
def get_key(self, exporter, so):
return self._find_create_key(plSoftVolumeInvert, exporter, so=so)
@ -153,24 +155,24 @@ class PlasmaSoftVolumeInvertNode(PlasmaNodeBase, bpy.types.Node):
class PlasmaSoftVolumeLinkNode(PlasmaNodeBase):
input_sockets = OrderedDict([
("properties", {
input_sockets: dict[str, Any] = {
"properties": {
"text": "Properties",
"type": "PlasmaSoftVolumePropertiesNodeSocket",
}),
("input", {
},
"input": {
"text": "Input Volume",
"type": "PlasmaSoftVolumeNodeSocket",
"spawn_empty": True,
}),
])
},
}
output_sockets = OrderedDict([
("output", {
"text": "Output Volume",
output_sockets: dict[str, dict[str, str]] = {
"output": {
"text": "Volume",
"type": "PlasmaSoftVolumeNodeSocket"
}),
])
},
}
def export(self, exporter, bo, so):
sv = self.get_key(exporter, so).object

Loading…
Cancel
Save