Skip to content

Commit

Permalink
Removed the OrderedDicts (H-uru#400)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
1Codealot committed Jan 20, 2024
1 parent dfa3bc9 commit 969911b
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 200 deletions.
98 changes: 50 additions & 48 deletions korman/nodes/node_avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down
77 changes: 38 additions & 39 deletions korman/nodes/node_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import bpy
from bpy.props import *
from collections import OrderedDict
import math
from PyHSPlasma import *
from typing import *
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -280,13 +279,13 @@ def _set_tolerance(self, value: float) -> None:
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()
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -433,35 +432,35 @@ def _update_report_on(self, context):
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.
Expand Down
Loading

0 comments on commit 969911b

Please sign in to comment.