Skip to content

Commit

Permalink
Rename unknown, add all_actors method
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanatosGit committed Sep 25, 2023
1 parent 7f10a30 commit 4299e0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/mercury_engine_data_structures/formats/bmsld.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Iterator
from typing import Iterator, Tuple

import construct
from construct import Const, Construct, Container, Flag, Float32l, Hex, Int32ul, Struct, Switch
Expand Down Expand Up @@ -55,10 +55,9 @@
x=Float,
y=Float,
z=Float,
unk05=Hex(Int32ul),
unk06=Hex(Int32ul),
unk07=Hex(Int32ul),

x_rotation=Float32l,
y_rotation=Float32l,
z_rotation=Float32l,
components=make_vector(Struct(
component_type=StrId,
command=StrId,
Expand Down Expand Up @@ -149,6 +148,11 @@ class Bmsld(BaseResource):
def construct_class(cls, target_game: Game) -> Construct:
return BMSLD

def all_actors(self) -> Iterator[Tuple[int, str, construct.Container]]:
for layer in self.raw.actors:
for actor_name, actor in layer.items():
yield layer, actor_name, actor

def all_actor_groups(self) -> Iterator[tuple[str, Container]]:
for sub_area in self.raw.sub_areas:
yield sub_area.name, sub_area
Expand Down
4 changes: 4 additions & 0 deletions tests/formats/test_bmsld.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def test_get_actor_group(surface_bmsld: Bmsld):
with pytest.raises(KeyError):
surface_bmsld.get_actor_group("blabla")

def test_all_actors(surface_bmsld: Bmsld):
all_actors = list(surface_bmsld.all_actors())
assert len(all_actors) == 232

def test_all_actor_group_names_for_actor(surface_bmsld: Bmsld):
groups = surface_bmsld.all_actor_group_names_for_actor("LE_EnergyRecharge")
assert groups == [
Expand Down

0 comments on commit 4299e0b

Please sign in to comment.