Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMSLD Updates #258

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft

BMSLD Updates #258

wants to merge 38 commits into from

Conversation

dyceron
Copy link
Contributor

@dyceron dyceron commented Dec 26, 2024

  • Renames fields and updates formatting
  • Moves functions from OSRR to MEDS
  • Add enum for actor layers
  • Add classes for editing position, rotation, and arguments

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 91.26214% with 9 lines in your changes missing coverage. Please review.

Project coverage is 77.82%. Comparing base (5e981a7) to head (2a2cac9).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...rc/mercury_engine_data_structures/formats/bmsld.py 91.26% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #258      +/-   ##
==========================================
+ Coverage   77.58%   77.82%   +0.23%     
==========================================
  Files          78       79       +1     
  Lines        4011     4099      +88     
==========================================
+ Hits         3112     3190      +78     
- Misses        899      909      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dyceron dyceron requested a review from duncathan December 26, 2024 23:20
@dyceron
Copy link
Contributor Author

dyceron commented Dec 26, 2024

Unsure if keeping reference[layer/actor] is worthwhile. It feels very verbose.

scenario.remove_entity({"layer": 9, "actor": "LE_GrappleDest_007"})
vs
scenario.remove_entity(9, "LE_GrappleDest_007")

@ThanatosGit
Copy link
Contributor

Unsure if keeping reference[layer/actor] is worthwhile. It feels very verbose.

scenario.remove_entity({"layer": 9, "actor": "LE_GrappleDest_007"}) vs scenario.remove_entity(9, "LE_GrappleDest_007")

In this case the first variant is just an ugly way of providing two arguments as one argument to the method.

It only makes sense to me because it wouldn't require "unpacking" such things from an input json in the patcher. But as the schema validation guarantees that the keys exists in the dict from the input json, it is definitely better to unpack it in the patcher and use the second variant here because MEDS doesn't know anything about the schema.

@dyceron
Copy link
Contributor Author

dyceron commented Dec 27, 2024

Unsure if keeping reference[layer/actor] is worthwhile. It feels very verbose.
scenario.remove_entity({"layer": 9, "actor": "LE_GrappleDest_007"}) vs scenario.remove_entity(9, "LE_GrappleDest_007")

In this case the first variant is just an ugly way of providing two arguments as one argument to the method.

It only makes sense to me because it wouldn't require "unpacking" such things from an input json in the patcher. But as the schema validation guarantees that the keys exists in the dict from the input json, it is definitely better to unpack it in the patcher and use the second variant here because MEDS doesn't know anything about the schema.

So I should use the less verbose version here then? Or are you saying keep this in OSRR, which probably shouldn't happen?

@ThanatosGit
Copy link
Contributor

So I should use the less verbose version here then?

Yes

src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
@dyceron dyceron requested a review from duncathan December 30, 2024 17:03
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/common_types.py Outdated Show resolved Hide resolved
@dyceron dyceron requested a review from duncathan December 30, 2024 17:54
Copy link
Contributor

@duncathan duncathan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna finish preparing the Vec2/3/4 pr today which should help with this pr too

raise TypeError(f"Invalid argument type: expected {expected_type}, got {type(value)} ({value})")
argument.value = value


class Bmsld(BaseResource):
@classmethod
def construct_class(cls, target_game: Game) -> Construct:
return BMSLD

def all_actors(self) -> Iterator[tuple[int, str, construct.Container]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should now return Iterator[tuple[ActorLayer, str, BmsldActor]] (you'll have to modify the function slightly to make it truth these)

src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
name=StrId,
names=make_vector(StrId),
"name" / StrId,
"objects" / make_vector(StrId),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be more accurate to call this actors or entities, and the whole struct should be actor_groups if it matches up with bmssa data. Though I'm not sure of the form of objects, is it like "actor_sname" without referencing the layer? Or a link like how dread does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be called actors but was changed to be more descriptive. I don't think I'd want to change it to actor_groups because that is associated with actors existing in groups (ie adding a new actor to a group (a collision camera group)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

given that brfld is basically an iterated structure, i'm pretty sure that this is the analog to dctActorGroup and bmsld.actor_layers is analog to dctSublayers.

Copy link
Contributor

@steven11sjf steven11sjf Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way, this structure is directly analogous to the dctActorGroup structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably could rename it to actor groups and be fine anyway

)
),
rest=construct.GreedyBytes,
# only used in s000_mainmenu, s010_cockpit, s020_credits
"extra_data" / construct.Optional(make_vector(ExtraActors)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off topic but could you check if there's any tie between those actors and the bmssa data in that draft pr? I feel like it could be related since cockpit and credits also have some unique actor values.

Copy link
Contributor Author

@dyceron dyceron Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat but I don't think fully related

Cockpit

Bmsld

    actor_layers = ListContainer: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
            LE_Samus = Container: 
                type = u'menu_samus' (total 10)
                position = Vec3(0.0, 0.0, 0.0)
                rotation = Vec3(0.0, 0.0, 0.0)
                component_functions = ListContainer: 
                    Container: 
                        component_type = u'MODELUPDATER' (total 12)
                        command = u'SetScenarioParams' (total 17)
                        arguments = ListContainer: 
                            Container: 
                                type = u'i' (total 1)
                                value = 4294967295
            LE_Baby = Container: 
                type = u'menu_baby' (total 9)
                position = Vec3(0.0, 0.0, 0.0)
                rotation = Vec3(0.0, 0.0, 0.0)
                component_functions = ListContainer: 
                    Container: 
                        component_type = u'MODELUPDATER' (total 12)
                        command = u'SetScenarioParams' (total 17)
                        arguments = ListContainer: 
                            Container: 
                                type = u'i' (total 1)
                                value = 4294967295
            LE_Ship = Container: 
                type = u'menu_shipinterior' (total 17)
                position = Vec3(0.0, 0.0, 0.0)
                rotation = Vec3(0.0, 0.0, 0.0)
                component_functions = ListContainer: 
                    Container: 
                        component_type = u'MODELUPDATER' (total 12)
                        command = u'SetScenarioParams' (total 17)
                        arguments = ListContainer: 
                            Container: 
                                type = u'i' (total 1)
                                value = 4294967295
            LE_Planet = Container: 
                type = u'menu_planet' (total 11)
                position = Vec3(0.0, 0.0, 0.0)
                rotation = Vec3(0.0, 0.0, 0.0)
                component_functions = ListContainer: 
                    Container: 
                        component_type = u'MODELUPDATER' (total 12)
                        command = u'SetScenarioParams' (total 17)
                        arguments = ListContainer: 
                            Container: 
                                type = u'i' (total 1)
                                value = 4294967295
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
        Container: 
    sub_areas = Container: 
    extra_data = Container: 
        eg_SubArea_collision_camera_000 = ListContainer: 
            LE_Baby
            LE_Samus
            LE_Planet
            LE_Ship

Bmssa

Container: 
    version = u'1.22.0' (total 6)
    cameras = Container: 
        collision_camera_000 = Container: 
            setups = Container: 
                Default = Container: 
                    environment_preset = u'interior' (total 8)
                    sound = u'default' (total 7)
                    unk2 = u'lg_collision_camera_000' (total 23)
                    entity_group = u'eg_SubArea_collision_camera_000' (total 31)
                    block_group = u'' (total 0)
                    cc_names = ListContainer: 
                        collision_camera_000
                    actors_in_scenario = ListContainer: 
                        menu_samus
                        menu_baby
                        samusshipinterior
                    cutscenes = ListContainer: 
                    collision_layer = u'collision' (total 9)
                    unk9 = False

@dyceron dyceron requested a review from duncathan January 7, 2025 02:58
Copy link
Contributor

@duncathan duncathan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's improve some typing problems. start off like this:

ActorName: TypeAlias = str
ActorGroupName: TypeAlias = str

then adjust the signatures of your API functions to use these types instead of just str as appropriate. a lot of the functions currently have incorrect signatures, so double check all of them

src/mercury_engine_data_structures/formats/bmsld.py Outdated Show resolved Hide resolved
@dyceron dyceron requested a review from duncathan January 15, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants