From 673f59b168e356347e3b60579534aa9a599fa061 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sat, 11 Jan 2025 20:51:35 -0500 Subject: [PATCH 1/7] Update formatting --- .../formats/bmdefs.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/bmdefs.py b/src/mercury_engine_data_structures/formats/bmdefs.py index 5f13ad57..cc115ff4 100644 --- a/src/mercury_engine_data_structures/formats/bmdefs.py +++ b/src/mercury_engine_data_structures/formats/bmdefs.py @@ -1,7 +1,7 @@ from __future__ import annotations import construct -from construct import ( +from construct.core import ( Const, Construct, Flag, @@ -68,10 +68,10 @@ ) # fmt: skip BMDEFS = Struct( - _magic=Const(b"MDEF"), - version=VersionAdapter("1.5.0"), - unk1=Int32ul, - sounds=make_vector( + "_magic" / Const(b"MDEF"), + "version" / VersionAdapter("1.5.0"), + "unk1" / Int32ul, + "sounds" / make_vector( Struct( "sound_name" / StrId, "unk1" / Int32ul, @@ -87,9 +87,9 @@ "environment_sfx_volume" / Float32l, ) ), # fmt: skip - unk2=Int32ul, - enemies_list=make_vector(EnemyStruct), - rest=construct.GreedyBytes, + "unk2" / Int32ul, + "enemies_list" / make_vector(EnemyStruct), + construct.Terminated, ) From 33ebd0248eb3389c534bb41a212fd5b0dc5256ed Mon Sep 17 00:00:00 2001 From: dyceron Date: Sat, 11 Jan 2025 21:28:29 -0500 Subject: [PATCH 2/7] Minor update --- .../formats/bmdefs.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/bmdefs.py b/src/mercury_engine_data_structures/formats/bmdefs.py index cc115ff4..85cf0efe 100644 --- a/src/mercury_engine_data_structures/formats/bmdefs.py +++ b/src/mercury_engine_data_structures/formats/bmdefs.py @@ -11,7 +11,7 @@ ) from mercury_engine_data_structures.base_resource import BaseResource -from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_vector +from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_dict, make_vector from mercury_engine_data_structures.formats import standard_format from mercury_engine_data_structures.game_check import Game @@ -38,10 +38,7 @@ "unk4" / Int32ul, "unk_bool" / Flag, "environment_sfx_volume" / Float32l, - "inner_states" / make_vector(Struct( - "type" / StrId, - "unk1" / Float32l, - )) + "inner_states" / make_dict(Float32l) ), 'DEATH': Struct( "unk1" / Int32ul, @@ -55,10 +52,7 @@ "unk4" / Int32ul, "unk_bool" / Flag, "environment_sfx_volume" / Float32l, - "inner_states" / make_vector(Struct( - "type" / StrId, - "unk1" / Float32l, - )) + "inner_states" / make_dict(Float32l) ), }, ) @@ -70,7 +64,7 @@ BMDEFS = Struct( "_magic" / Const(b"MDEF"), "version" / VersionAdapter("1.5.0"), - "unk1" / Int32ul, + "number_of_sounds" / Int32ul, "sounds" / make_vector( Struct( "sound_name" / StrId, @@ -87,7 +81,7 @@ "environment_sfx_volume" / Float32l, ) ), # fmt: skip - "unk2" / Int32ul, + "number_of_enemy_groups" / Int32ul, "enemies_list" / make_vector(EnemyStruct), construct.Terminated, ) From db2f9e279f98c148c64020d399817fdfbb07ca85 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sat, 11 Jan 2025 23:44:41 -0500 Subject: [PATCH 3/7] Add classes --- .../formats/bmdefs.py | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/src/mercury_engine_data_structures/formats/bmdefs.py b/src/mercury_engine_data_structures/formats/bmdefs.py index 85cf0efe..6a02975b 100644 --- a/src/mercury_engine_data_structures/formats/bmdefs.py +++ b/src/mercury_engine_data_structures/formats/bmdefs.py @@ -4,6 +4,7 @@ from construct.core import ( Const, Construct, + Container, Flag, Float32l, Int32ul, @@ -87,6 +88,135 @@ ) +class EnemyStates: + def __init__(self, raw: Container): + self._raw = raw + + @property + def state_type(self) -> str: + return self._raw.type + + @state_type.setter + def state_type(self, value: str) -> None: + self._raw.type = value + + def get_sound_properties(self) -> Sounds: + return Sounds(self._raw.properties) + + +class EnemyLayers: + def __init__(self, raw: Container): + self._raw = raw + + @property + def layer_name(self) -> str: + return self._raw.layer_name + + @layer_name.setter + def layer_name(self, value: str) -> None: + self._raw.layer_name = value + + def get_state(self, state_idx: int) -> EnemyStates: + return EnemyStates(self._raw.states[state_idx]) + + +class Areas: + def __init__(self, raw: Container): + self._raw = raw + + @property + def area_name(self) -> str: + return self._raw.area_name + + @area_name.setter + def area_name(self, value: str) -> None: + self._raw.area_name = value + + def get_layer(self, layer_idx: int) -> EnemyLayers: + return EnemyLayers(self._raw.layers[layer_idx]) + + +class EnemiesList: + def __init__(self, raw: Container): + self._raw = raw + + @property + def enemy_name(self) -> str: + return self._raw.enemy_name + + @enemy_name.setter + def enemy_name(self, value: str) -> None: + self._raw.enemy_name = value + + def get_area(self, area_idx: int) -> Areas: + return Areas(self._raw.area_name[area_idx]) + + +class Sounds: + def __init__(self, raw: Container) -> None: + self._raw = raw + + @property + def sound_name(self) -> str: + return self._raw.sound_name + + @sound_name.setter + def sound_name(self, value: str) -> None: + self._raw.sound_name = value + + @property + def file_path(self) -> str: + return self._raw.file_path + + @file_path.setter + def file_path(self, value: str) -> None: + self._raw.file_path = value + + @property + def fade_in(self) -> float: + return self._raw.fade_in + + @fade_in.setter + def fade_in(self, value: float) -> None: + self._raw.fade_in = value + + @property + def fade_out(self) -> float: + return self._raw.fade_out + + @fade_out.setter + def fade_out(self, value: float) -> None: + self._raw.fade_out = value + + @property + def volume(self) -> float: + return self._raw.volume + + @volume.setter + def volume(self, value: float) -> None: + self._raw.volume = value + + @property + def environment_sfx_volume(self) -> float: + return self._raw.environment_sfx_volume + + @environment_sfx_volume.setter + def environment_sfx_volume(self, value: float) -> None: + self._raw.environment_sfx_volume = value + + # inner_states is only used for enemies + @property + def inner_states(self) -> dict[str, float]: + return self._raw.inner_states + + @inner_states.setter + def inner_states(self, relax_value: float, death_value: float) -> None: + self._raw.inner_states = { + "RELAX": relax_value, + "DEATH": death_value + } + + class Bmdefs(BaseResource): @classmethod def construct_class(cls, target_game: Game) -> Construct: @@ -94,3 +224,9 @@ def construct_class(cls, target_game: Game) -> Construct: return BMDEFS else: return standard_format.game_model("sound::CMusicManager", "4.0.2") + + def get_sound(self, sound_idx: int) -> Sounds: + return Sounds(self.raw.sounds[sound_idx]) + + def get_enemy(self, enemy_idx: int) -> EnemiesList: + return EnemiesList(self.raw.enemies_list[enemy_idx]) From 3df51937ed342da33e473212c89ea130417abb7c Mon Sep 17 00:00:00 2001 From: dyceron Date: Sun, 12 Jan 2025 02:34:34 -0500 Subject: [PATCH 4/7] More properties and fixes, also add tests --- .../formats/bmdefs.py | 31 ++++++-- tests/formats/test_bmdefs.py | 77 +++++++++++++++++++ 2 files changed, 100 insertions(+), 8 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/bmdefs.py b/src/mercury_engine_data_structures/formats/bmdefs.py index 6a02975b..db0f1996 100644 --- a/src/mercury_engine_data_structures/formats/bmdefs.py +++ b/src/mercury_engine_data_structures/formats/bmdefs.py @@ -66,7 +66,8 @@ "_magic" / Const(b"MDEF"), "version" / VersionAdapter("1.5.0"), "number_of_sounds" / Int32ul, - "sounds" / make_vector( + "sounds" + / make_vector( Struct( "sound_name" / StrId, "unk1" / Int32ul, @@ -149,7 +150,7 @@ def enemy_name(self, value: str) -> None: self._raw.enemy_name = value def get_area(self, area_idx: int) -> Areas: - return Areas(self._raw.area_name[area_idx]) + return Areas(self._raw.areas[area_idx]) class Sounds: @@ -164,6 +165,14 @@ def sound_name(self) -> str: def sound_name(self, value: str) -> None: self._raw.sound_name = value + @property + def priority(self) -> int: + return self._raw.priority + + @priority.setter + def priority(self, value: str) -> None: + self._raw.priority = value + @property def file_path(self) -> str: return self._raw.file_path @@ -204,17 +213,23 @@ def environment_sfx_volume(self) -> float: def environment_sfx_volume(self, value: float) -> None: self._raw.environment_sfx_volume = value - # inner_states is only used for enemies + # inner_states and start_delay are only used for enemies + @property + def start_delay(self) -> float: + return self._raw.start_delay + + @start_delay.setter + def start_delay(self, value: float) -> None: + self._raw.start_delay = value + @property def inner_states(self) -> dict[str, float]: return self._raw.inner_states @inner_states.setter - def inner_states(self, relax_value: float, death_value: float) -> None: - self._raw.inner_states = { - "RELAX": relax_value, - "DEATH": death_value - } + def inner_states(self, value: dict[str, float]) -> None: + for name, value in value.items(): + self._raw.inner_states[name] = value class Bmdefs(BaseResource): diff --git a/tests/formats/test_bmdefs.py b/tests/formats/test_bmdefs.py index efad0bb1..b882c31d 100644 --- a/tests/formats/test_bmdefs.py +++ b/tests/formats/test_bmdefs.py @@ -1,5 +1,8 @@ from __future__ import annotations +import copy + +import pytest from tests.test_lib import parse_build_compare_editor from mercury_engine_data_structures.formats.bmdefs import Bmdefs @@ -11,3 +14,77 @@ def test_bmdefs_dread(dread_tree_100): def test_bmdefs_sr(samus_returns_tree): parse_build_compare_editor(Bmdefs, samus_returns_tree, "system/snd/scenariomusicdefs.bmdefs") + + +@pytest.fixture() +def bmdefs(samus_returns_tree) -> Bmdefs: + return samus_returns_tree.get_parsed_asset("system/snd/scenariomusicdefs.bmdefs", type_hint=Bmdefs) + + +def test_get_sound(bmdefs: Bmdefs): + sound = bmdefs.get_sound(0) + assert sound.sound_name == "matad_jintojo_32728k" + assert sound.volume == 1.0 + + +def test_set_sound_properties(bmdefs: Bmdefs): + sound = bmdefs.get_sound(3) + assert sound is not None + + original_properties = copy.deepcopy(sound) + + sound.sound_name = "m_new_sound" + sound.priority = 1 + sound.file_path = "a/real/file/path.wav" + sound.fade_in = 0.1 + sound.fade_out = 4.0 + sound.volume = 0.5 + sound.environment_sfx_volume = 0.79 + + assert sound != original_properties + + +def test_get_enemy(bmdefs: Bmdefs): + enemy = bmdefs.get_enemy(0) + assert enemy.enemy_name == "alphanewborn" + + area = enemy.get_area(0) + assert area.area_name == "s000_surface" + + layer = area.get_layer(0) + assert layer.layer_name == "default" + + state = layer.get_state(0) + assert state.state_type == "COMBAT" + + sound_properties = state.get_sound_properties() + assert sound_properties.start_delay == 0.0 + assert sound_properties.inner_states == {"RELAX": 3.0, "DEATH": 5.0} + + +def test_set_enemy_properties(bmdefs: Bmdefs): + enemy = bmdefs.get_enemy(9) + assert enemy is not None + + enemy.enemy_name = "kraid" + assert enemy.enemy_name != "queen" + + area = enemy.get_area(0) + area.area_name = "s050_area5" + assert area != "s100_area10" + + layer = area.get_layer(0) + layer.layer_name = "not_default" + assert layer.layer_name != "default" + + state = layer.get_state(1) + state.state_type = "COMBAT" + assert state.state_type != "DEATH" + + sound_properties = state.get_sound_properties() + sound_properties.fade_out = 10.0 + assert sound_properties.fade_out != 3.0 + sound_properties.start_delay = 0.4 + assert sound_properties.start_delay != 2.0 + sound_properties.inner_states = {"RELAX": 1.0, "DEATH": 45.0} + assert sound_properties.inner_states != {} From a7f8a669308bcf781c61daffc3bb162150266003 Mon Sep 17 00:00:00 2001 From: dyceron Date: Fri, 17 Jan 2025 21:01:19 -0500 Subject: [PATCH 5/7] Address review and update tests --- .../formats/bmdefs.py | 78 +++++++++++++------ tests/formats/test_bmdefs.py | 37 +++++---- 2 files changed, 76 insertions(+), 39 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/bmdefs.py b/src/mercury_engine_data_structures/formats/bmdefs.py index db0f1996..604324d7 100644 --- a/src/mercury_engine_data_structures/formats/bmdefs.py +++ b/src/mercury_engine_data_structures/formats/bmdefs.py @@ -1,5 +1,7 @@ from __future__ import annotations +from enum import Enum + import construct from construct.core import ( Const, @@ -11,11 +13,23 @@ Struct, ) +from mercury_engine_data_structures.adapters.enum_adapter import EnumAdapter from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_dict, make_vector from mercury_engine_data_structures.formats import standard_format from mercury_engine_data_structures.game_check import Game + +class StateType(str, Enum): + COMBAT = "COMBAT" + DEATH = "DEATH" + + +class InnerStateType(str, Enum): + DEATH = "DEATH" + RELAX = "RELAX" + + EnemyStruct = Struct( "enemy_name" / StrId, "areas" / make_vector(Struct( @@ -53,7 +67,7 @@ "unk4" / Int32ul, "unk_bool" / Flag, "environment_sfx_volume" / Float32l, - "inner_states" / make_dict(Float32l) + "inner_states" / make_dict(EnumAdapter(InnerStateType, StrId), Float32l) ), }, ) @@ -65,7 +79,7 @@ BMDEFS = Struct( "_magic" / Const(b"MDEF"), "version" / VersionAdapter("1.5.0"), - "number_of_sounds" / Int32ul, + "_number_of_sounds" / Int32ul, "sounds" / make_vector( Struct( @@ -83,7 +97,7 @@ "environment_sfx_volume" / Float32l, ) ), # fmt: skip - "number_of_enemy_groups" / Int32ul, + "_number_of_enemy_groups" / Int32ul, "enemies_list" / make_vector(EnemyStruct), construct.Terminated, ) @@ -94,13 +108,30 @@ def __init__(self, raw: Container): self._raw = raw @property - def state_type(self) -> str: + def state_type(self) -> StateType: return self._raw.type @state_type.setter - def state_type(self, value: str) -> None: + def state_type(self, value: StateType) -> None: self._raw.type = value + @property + def start_delay(self) -> float: + return self._raw.properties.start_delay + + @start_delay.setter + def start_delay(self, value: float) -> None: + self._raw.properties.start_delay = value + + @property + def inner_states(self) -> dict[InnerStateType, float]: + return self._raw.properties.inner_states + + @inner_states.setter + def inner_states(self, value: dict[InnerStateType, float]) -> None: + for name, value in value.items(): + self._raw.properties.inner_states[name] = value + def get_sound_properties(self) -> Sounds: return Sounds(self._raw.properties) @@ -149,6 +180,23 @@ def enemy_name(self) -> str: def enemy_name(self, value: str) -> None: self._raw.enemy_name = value + @property + def start_delay(self) -> float: + return self._raw.start_delay + + @start_delay.setter + def start_delay(self, value: float) -> None: + self._raw.start_delay = value + + @property + def inner_states(self) -> dict[InnerStateType, float]: + return self._raw.inner_states + + @inner_states.setter + def inner_states(self, value: dict[InnerStateType, float]) -> None: + for name, value in value.items(): + self._raw.inner_states[name] = value + def get_area(self, area_idx: int) -> Areas: return Areas(self._raw.areas[area_idx]) @@ -170,7 +218,7 @@ def priority(self) -> int: return self._raw.priority @priority.setter - def priority(self, value: str) -> None: + def priority(self, value: int) -> None: self._raw.priority = value @property @@ -213,24 +261,6 @@ def environment_sfx_volume(self) -> float: def environment_sfx_volume(self, value: float) -> None: self._raw.environment_sfx_volume = value - # inner_states and start_delay are only used for enemies - @property - def start_delay(self) -> float: - return self._raw.start_delay - - @start_delay.setter - def start_delay(self, value: float) -> None: - self._raw.start_delay = value - - @property - def inner_states(self) -> dict[str, float]: - return self._raw.inner_states - - @inner_states.setter - def inner_states(self, value: dict[str, float]) -> None: - for name, value in value.items(): - self._raw.inner_states[name] = value - class Bmdefs(BaseResource): @classmethod diff --git a/tests/formats/test_bmdefs.py b/tests/formats/test_bmdefs.py index b882c31d..c211ff27 100644 --- a/tests/formats/test_bmdefs.py +++ b/tests/formats/test_bmdefs.py @@ -5,7 +5,7 @@ import pytest from tests.test_lib import parse_build_compare_editor -from mercury_engine_data_structures.formats.bmdefs import Bmdefs +from mercury_engine_data_structures.formats.bmdefs import Bmdefs, InnerStateType, StateType def test_bmdefs_dread(dread_tree_100): @@ -56,35 +56,42 @@ def test_get_enemy(bmdefs: Bmdefs): state = layer.get_state(0) assert state.state_type == "COMBAT" - - sound_properties = state.get_sound_properties() - assert sound_properties.start_delay == 0.0 - assert sound_properties.inner_states == {"RELAX": 3.0, "DEATH": 5.0} + assert state.start_delay == 0.0 + assert state.inner_states == {"RELAX": 3.0, "DEATH": 5.0} def test_set_enemy_properties(bmdefs: Bmdefs): enemy = bmdefs.get_enemy(9) assert enemy is not None + assert enemy.enemy_name == "queen" enemy.enemy_name = "kraid" - assert enemy.enemy_name != "queen" + assert enemy.enemy_name == "kraid" area = enemy.get_area(0) + assert area.area_name == "s100_area10" area.area_name = "s050_area5" - assert area != "s100_area10" + assert area.area_name == "s050_area5" layer = area.get_layer(0) + assert layer.layer_name == "default" layer.layer_name = "not_default" - assert layer.layer_name != "default" + assert layer.layer_name == "not_default" state = layer.get_state(1) - state.state_type = "COMBAT" - assert state.state_type != "DEATH" + assert state.state_type == StateType.DEATH + state.state_type = StateType.COMBAT + assert state.state_type == StateType.COMBAT + + assert state.start_delay == 2.0 + state.start_delay = 0.4 + assert state.start_delay == 0.4 + + assert state.inner_states == {} + state.inner_states = {InnerStateType.RELAX: 1.0, InnerStateType.DEATH: 45.0} + assert state.inner_states == {InnerStateType.RELAX: 1.0, InnerStateType.DEATH: 45.0} sound_properties = state.get_sound_properties() + assert sound_properties.fade_out == 3.0 sound_properties.fade_out = 10.0 - assert sound_properties.fade_out != 3.0 - sound_properties.start_delay = 0.4 - assert sound_properties.start_delay != 2.0 - sound_properties.inner_states = {"RELAX": 1.0, "DEATH": 45.0} - assert sound_properties.inner_states != {} + assert sound_properties.fade_out == 10.0 From 905d5509e6d365d62db518b041f3f5739c1ed322 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sun, 19 Jan 2025 08:28:27 -0500 Subject: [PATCH 6/7] Add inheritance and update tests --- .../formats/bmdefs.py | 43 +++++++++------- tests/formats/test_bmdefs.py | 49 +++++++++++++------ 2 files changed, 57 insertions(+), 35 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/bmdefs.py b/src/mercury_engine_data_structures/formats/bmdefs.py index 604324d7..435f97e8 100644 --- a/src/mercury_engine_data_structures/formats/bmdefs.py +++ b/src/mercury_engine_data_structures/formats/bmdefs.py @@ -115,25 +115,8 @@ def state_type(self) -> StateType: def state_type(self, value: StateType) -> None: self._raw.type = value - @property - def start_delay(self) -> float: - return self._raw.properties.start_delay - - @start_delay.setter - def start_delay(self, value: float) -> None: - self._raw.properties.start_delay = value - - @property - def inner_states(self) -> dict[InnerStateType, float]: - return self._raw.properties.inner_states - - @inner_states.setter - def inner_states(self, value: dict[InnerStateType, float]) -> None: - for name, value in value.items(): - self._raw.properties.inner_states[name] = value - - def get_sound_properties(self) -> Sounds: - return Sounds(self._raw.properties) + def get_sound_properties(self) -> EnemySounds: + return EnemySounds(self._raw.properties) class EnemyLayers: @@ -262,6 +245,28 @@ def environment_sfx_volume(self, value: float) -> None: self._raw.environment_sfx_volume = value +class EnemySounds(Sounds): + def __init__(self, raw: Container): + self._raw = raw + + @property + def start_delay(self) -> float: + return self._raw.start_delay + + @start_delay.setter + def start_delay(self, value: float) -> None: + self._raw.start_delay = value + + @property + def inner_states(self) -> dict[InnerStateType, float]: + return self._raw.inner_states + + @inner_states.setter + def inner_states(self, value: dict[InnerStateType, float]) -> None: + for name, value in value.items(): + self._raw.inner_states[name] = value + + class Bmdefs(BaseResource): @classmethod def construct_class(cls, target_game: Game) -> Construct: diff --git a/tests/formats/test_bmdefs.py b/tests/formats/test_bmdefs.py index c211ff27..14581ee3 100644 --- a/tests/formats/test_bmdefs.py +++ b/tests/formats/test_bmdefs.py @@ -1,7 +1,5 @@ from __future__ import annotations -import copy - import pytest from tests.test_lib import parse_build_compare_editor @@ -31,17 +29,33 @@ def test_set_sound_properties(bmdefs: Bmdefs): sound = bmdefs.get_sound(3) assert sound is not None - original_properties = copy.deepcopy(sound) - + assert sound.sound_name == "m_boss_manic_miner_chase99" sound.sound_name = "m_new_sound" + assert sound.sound_name == "m_new_sound" + + assert sound.priority == 0 sound.priority = 1 + assert sound.priority == 1 + + assert sound.file_path == "streams/music/m_boss_manic_miner_chase99.wav" sound.file_path = "a/real/file/path.wav" + assert sound.file_path == "a/real/file/path.wav" + + assert sound.fade_in == 0.0 sound.fade_in = 0.1 + assert sound.fade_in == 0.1 + + assert sound.fade_out == 0.0 sound.fade_out = 4.0 + assert sound.fade_out == 4.0 + + assert sound.volume == 1.0 sound.volume = 0.5 - sound.environment_sfx_volume = 0.79 + assert sound.volume == 0.5 - assert sound != original_properties + assert sound.environment_sfx_volume == 1.0 + sound.environment_sfx_volume = 0.79 + assert sound.environment_sfx_volume == 0.79 def test_get_enemy(bmdefs: Bmdefs): @@ -56,8 +70,10 @@ def test_get_enemy(bmdefs: Bmdefs): state = layer.get_state(0) assert state.state_type == "COMBAT" - assert state.start_delay == 0.0 - assert state.inner_states == {"RELAX": 3.0, "DEATH": 5.0} + + sound_properties = state.get_sound_properties() + assert sound_properties.start_delay == 0.0 + assert sound_properties.inner_states == {"RELAX": 3.0, "DEATH": 5.0} def test_set_enemy_properties(bmdefs: Bmdefs): @@ -83,15 +99,16 @@ def test_set_enemy_properties(bmdefs: Bmdefs): state.state_type = StateType.COMBAT assert state.state_type == StateType.COMBAT - assert state.start_delay == 2.0 - state.start_delay = 0.4 - assert state.start_delay == 0.4 - - assert state.inner_states == {} - state.inner_states = {InnerStateType.RELAX: 1.0, InnerStateType.DEATH: 45.0} - assert state.inner_states == {InnerStateType.RELAX: 1.0, InnerStateType.DEATH: 45.0} - sound_properties = state.get_sound_properties() + assert sound_properties.fade_out == 3.0 sound_properties.fade_out = 10.0 assert sound_properties.fade_out == 10.0 + + assert sound_properties.start_delay == 2.0 + sound_properties.start_delay = 0.4 + assert sound_properties.start_delay == 0.4 + + assert sound_properties.inner_states == {} + sound_properties.inner_states = {InnerStateType.RELAX: 1.0, InnerStateType.DEATH: 45.0} + assert sound_properties.inner_states == {InnerStateType.RELAX: 1.0, InnerStateType.DEATH: 45.0} From 24b838940e029a845300cfbdb4e1925251654e05 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sun, 19 Jan 2025 10:33:34 -0500 Subject: [PATCH 7/7] Remove extra init --- src/mercury_engine_data_structures/formats/bmdefs.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/bmdefs.py b/src/mercury_engine_data_structures/formats/bmdefs.py index 435f97e8..df79ab87 100644 --- a/src/mercury_engine_data_structures/formats/bmdefs.py +++ b/src/mercury_engine_data_structures/formats/bmdefs.py @@ -246,9 +246,6 @@ def environment_sfx_volume(self, value: float) -> None: class EnemySounds(Sounds): - def __init__(self, raw: Container): - self._raw = raw - @property def start_delay(self) -> float: return self._raw.start_delay