From 9a29e4c48391a7c0efe7c3180ece9b799f498cbe Mon Sep 17 00:00:00 2001 From: Mayberry Date: Mon, 24 Mar 2025 14:14:59 -0400 Subject: [PATCH] Update code for new MEDS --- .../misc_patches/sprite_patches.py | 7 ++-- src/open_dread_rando/pickups/map_icons.py | 36 ++++++++++--------- src/open_dread_rando/pickups/pickup.py | 7 ++-- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/open_dread_rando/misc_patches/sprite_patches.py b/src/open_dread_rando/misc_patches/sprite_patches.py index 9c3a563a2..a3c819fa6 100644 --- a/src/open_dread_rando/misc_patches/sprite_patches.py +++ b/src/open_dread_rando/misc_patches/sprite_patches.py @@ -1,4 +1,5 @@ -from construct import Container, ListContainer +from construct import Container +from mercury_engine_data_structures.common_types import Vec2 from mercury_engine_data_structures.formats import Bmsss from open_dread_rando.patcher_editor import PatcherEditor @@ -15,8 +16,8 @@ def patch_sprites(editor: PatcherEditor): cont = Container( sID="DISCONNECT", oTexUVs=Container( - v2Offset=ListContainer([446 / 512, 6 / 512]), - v2Scale=ListContainer([59 / 512, 59 / 512]) + v2Offset=Vec2(446 / 512, 6 / 512), + v2Scale=Vec2(59 / 512, 59 / 512), ) ) hud_bmsss.raw.Root.mapSpriteSheets.HUD_TILESET.vecItems.append(cont) diff --git a/src/open_dread_rando/pickups/map_icons.py b/src/open_dread_rando/pickups/map_icons.py index 3d58ad1e1..657c5bd78 100644 --- a/src/open_dread_rando/pickups/map_icons.py +++ b/src/open_dread_rando/pickups/map_icons.py @@ -3,6 +3,7 @@ import dataclasses from typing import TYPE_CHECKING +from mercury_engine_data_structures.common_types import Vec2 from mercury_engine_data_structures.formats import Bmmdef from open_dread_rando.constants import ALL_SCENARIOS @@ -18,13 +19,14 @@ class MapIcon: coords: tuple[int, int] label: str disabled_id: str = 'ItemAdquired' - offset: tuple[int, int] = (0, 0) + offset: Vec2 | None = None auto_scale: bool = True is_global: bool = True full_zoom_scale: bool = True string_key: str = dataclasses.field(init=False) def __post_init__(self): + self.offset = self.offset if self.offset else Vec2(0.0, 0.0) object.__setattr__(self, "string_key", f"MAP_ICON_{self.icon_id}") def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): @@ -254,7 +256,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(1,3), disabled_id="BlockageDisabledL", label="ICE MISSILE COVER", - offset=(-0.800000011920929, -0.4000000059604645), + offset=Vec2(-0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageIceR": MapIcon( @@ -262,7 +264,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(1,3), disabled_id="BlockageDisabledR", label="ICE MISSILE COVER", - offset=(0.800000011920929, -0.4000000059604645), + offset=Vec2(0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageDiffusionL": MapIcon( @@ -270,7 +272,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(3,3), disabled_id="BlockageDisabledL", label="DIFFUSION BEAM COVER", - offset=(-0.800000011920929, -0.4000000059604645), + offset=Vec2(-0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageDiffusionR": MapIcon( @@ -278,7 +280,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(3,3), disabled_id="BlockageDisabledR", label="DIFFUSION BEAM COVER", - offset=(0.800000011920929, -0.4000000059604645), + offset=Vec2(0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageStormL": MapIcon( @@ -286,7 +288,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(5,3), disabled_id="BlockageDisabledL", label="STORM MISSILE COVER", - offset=(-0.800000011920929, -0.4000000059604645), + offset=Vec2(-0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageStormR": MapIcon( @@ -294,7 +296,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(5,3), disabled_id="BlockageDisabledR", label="STORM MISSILE COVER", - offset=(0.800000011920929, -0.4000000059604645), + offset=Vec2(0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageScrewL": MapIcon( @@ -302,7 +304,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(5,1), disabled_id="BlockageDisabledL", label="SCREW ATTACK COVER", - offset=(-0.800000011920929, -0.4000000059604645), + offset=Vec2(-0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageScrewR": MapIcon( @@ -310,7 +312,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(5,1), disabled_id="BlockageDisabledR", label="SCREW ATTACK COVER", - offset=(0.800000011920929, -0.4000000059604645), + offset=Vec2(0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageBombL": MapIcon( @@ -318,7 +320,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(7,3), disabled_id="BlockageDisabledL", label="BOMB COVER", - offset=(-0.800000011920929, -0.4000000059604645), + offset=Vec2(-0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageBombR": MapIcon( @@ -326,7 +328,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(7,3), disabled_id="BlockageDisabledR", label="BOMB COVER", - offset=(0.800000011920929, -0.4000000059604645), + offset=Vec2(0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageCrossBombL": MapIcon( @@ -334,7 +336,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(9,3), disabled_id="BlockageDisabledL", label="CROSS BOMB COVER", - offset=(-0.800000011920929, -0.4000000059604645), + offset=Vec2(-0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageCrossBombR": MapIcon( @@ -342,7 +344,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(9,3), disabled_id="BlockageDisabledR", label="CROSS BOMB COVER", - offset=(0.800000011920929, -0.4000000059604645), + offset=Vec2(0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockagePowerBombL": MapIcon( @@ -350,7 +352,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(11,3), disabled_id="BlockageDisabledL", label="POWER BOMB COVER", - offset=(-0.800000011920929, -0.4000000059604645), + offset=Vec2(-0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockagePowerBombR": MapIcon( @@ -358,7 +360,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(11,3), disabled_id="BlockageDisabledR", label="POWER BOMB COVER", - offset=(0.800000011920929, -0.4000000059604645), + offset=Vec2(0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageClosedL": MapIcon( @@ -366,7 +368,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(5,1), disabled_id="BlockageDisabledL", label="ACCESS CLOSED", - offset=(-0.800000011920929, -0.4000000059604645), + offset=Vec2(-0.800000011920929, -0.4000000059604645), auto_scale=False ), "BlockageClosedR": MapIcon( @@ -374,7 +376,7 @@ def add_to_defs(self, bmmdef: Bmmdef, editor: PatcherEditor): coords=(5,1), disabled_id="BlockageDisabledR", label="ACCESS CLOSED", - offset=(0.800000011920929, -0.4000000059604645), + offset=Vec2(0.800000011920929, -0.4000000059604645), auto_scale=False ), } diff --git a/src/open_dread_rando/pickups/pickup.py b/src/open_dread_rando/pickups/pickup.py index 05f28eeef..62659e609 100644 --- a/src/open_dread_rando/pickups/pickup.py +++ b/src/open_dread_rando/pickups/pickup.py @@ -2,6 +2,7 @@ from enum import Enum from construct import Container +from mercury_engine_data_structures.common_types import Vec3 from mercury_engine_data_structures.formats import Bmmap, Bmsad from open_dread_rando.files import templates_path @@ -151,9 +152,9 @@ def patch_model(self, editor: PatcherEditor, model_names: list[str], actor: Cont new_template.components = components if selected_model_data.transform is not None: - model_updater.fields.vInitScale = list(selected_model_data.transform.scale) - model_updater.fields.vInitPosWorldOffset = list(selected_model_data.transform.position) - model_updater.fields.vInitAngWorldOffset = list(selected_model_data.transform.angle) + model_updater.fields.vInitScale = Vec3(*selected_model_data.transform.scale) + model_updater.fields.vInitPosWorldOffset = Vec3(*selected_model_data.transform.position) + model_updater.fields.vInitAngWorldOffset = Vec3(*selected_model_data.transform.angle) # Animation/BMSAS action_set_refs = list(new_template.action_set_refs)