Skip to content

Commit

Permalink
Copy door and shield from s000_surface to s110_surfaceb (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanatosGit authored May 19, 2024
1 parent b117654 commit c1e04e3
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/open_samus_returns_rando/specific_patches/door_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,53 @@ def _create_shield(
new_actor["type"] = new_type
return new_actor

def _fix_surfaceb_door012(
self,
door_actor: Container,
left_shield_name: str, left_shield_actor: Container,
right_shield_name: str, right_shield_actor: Container,
new_door: DoorType
) -> None:
scenario_name = "s110_surfaceb"
scenario = self.editor.get_scenario(scenario_name)

# remove door and shield
scenario.raw.actors[15].pop("Door012")
self.editor.remove_entity({
"scenario": scenario_name, "layer": 9, "actor": "LE_SpazerShield_Door_012"
})

# copy door
self.editor.copy_actor(
scenario_name, door_actor.position,
door_actor, "Door012", 15
)

# if shield exists
if left_shield_actor is not None and right_shield_actor is not None:
# copy left
self.editor.copy_actor(
scenario_name, left_shield_actor.position,
left_shield_actor, left_shield_name, 9
)
# copy right
self.editor.copy_actor(
scenario_name, right_shield_actor.position,
right_shield_actor, right_shield_name, 9
)

# add to entity groups
entity_groups = [group for group_name, group in scenario.all_actor_groups()
if group_name in list(scenario.all_actor_group_names_for_actor("Door012"))]
for group in entity_groups:
scenario.insert_into_entity_group(group, left_shield_name)
scenario.insert_into_entity_group(group, right_shield_name)

# ensure required files
for folder in new_door.required_asset_folders:
for asset in self.editor.get_asset_names_in_folder(folder):
self.editor.ensure_present_in_scenario(scenario_name, asset)

def patch_door(self, editor: PatcherEditor, actor_ref: dict, door_type_str: str) -> None:
scenario_name = actor_ref["scenario"]
actor_name = actor_ref["actor"]
Expand All @@ -335,6 +382,13 @@ def patch_door(self, editor: PatcherEditor, actor_ref: dict, door_type_str: str)
self.patch_actor(
new_door, scenario_name, actor_name, scenario, door_actor, index, left_shield_name, right_shield_name
)
if scenario_name == "s000_surface" and actor_name == "Door012":
left_shield_actor = scenario.raw.actors[9].get(left_shield_name, None)
right_shield_actor = scenario.raw.actors[9].get(right_shield_name, None)
self._fix_surfaceb_door012(
door_actor, left_shield_name, left_shield_actor, right_shield_name, right_shield_actor, new_door
)

self.patch_minimap(editor, scenario_name, actor_name, left_shield_name, right_shield_name, new_door)

def patch_minimap(
Expand Down

0 comments on commit c1e04e3

Please sign in to comment.