-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #327 from randovania/custom-pickups
Refactor Custom Pickups
- Loading branch information
Showing
1 changed file
with
38 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,48 @@ | ||
import typing | ||
|
||
from construct import Container, ListContainer | ||
from mercury_engine_data_structures.formats import Bmsmsd | ||
from open_samus_returns_rando.patcher_editor import PatcherEditor | ||
|
||
BABY_ICON = Container({ | ||
"actor_name": "LE_Baby_Hatchling", | ||
"clear_condition": "", | ||
"icon": "itemenabled", | ||
"icon_priority": 0, | ||
"coordinates": ListContainer([ | ||
-3400.0, | ||
11225.0, | ||
0.0 | ||
]), | ||
}) | ||
|
||
|
||
def _get_actor(editor: PatcherEditor): | ||
actor_to_copy = { | ||
"scenario": "s000_surface", | ||
"layer": "9", | ||
"actor": "LE_PowerUP_Morphball", | ||
} | ||
reference_actor = editor.resolve_actor_reference(actor_to_copy) | ||
return reference_actor | ||
|
||
|
||
def _create_baby_pickup(editor: PatcherEditor): | ||
name_of_scenario = "s100_area10" | ||
scenario_10 = editor.get_scenario(name_of_scenario) | ||
name_of_pickup = "LE_Baby_Hatchling" | ||
|
||
reference_actor = _get_actor(editor) | ||
|
||
editor.copy_actor( | ||
name_of_scenario, (-3400.0, 11225.0, 0.0), reference_actor, name_of_pickup, 9, | ||
|
||
class NewPickups(typing.NamedTuple): | ||
scenario: str | ||
name: str | ||
position: list[float] | ||
tile_index: int | ||
entity_groups: list[str] | ||
|
||
|
||
new_pickups = [ | ||
NewPickups( | ||
"s100_area10", "LE_Baby_Hatchling", [-3400.0, 11225.0, 0.0], 252, ["collision_camera_022"] | ||
) | ||
] | ||
|
||
|
||
def add_pickups(editor: PatcherEditor, new_pickup: NewPickups): | ||
template_pickup = editor.get_scenario("s000_surface").raw.actors[9]["LE_PowerUP_Morphball"] | ||
|
||
PICKUP_ICON = Container({ | ||
"actor_name": new_pickup.name, | ||
"clear_condition": "", | ||
"icon": "itemenabled", | ||
"icon_priority": 0, | ||
"coordinates": ListContainer(new_pickup.position), | ||
}) | ||
|
||
scenario_name = new_pickup.scenario | ||
scenario_file = editor.get_scenario(scenario_name) | ||
|
||
editor.copy_actor(scenario_name, new_pickup.position, template_pickup, new_pickup.name, 9) | ||
|
||
scenario_10.add_actor_to_entity_groups("collision_camera_022", name_of_pickup) | ||
scenario_map = editor.get_file(f"gui/minimaps/c10_samus/{scenario_name}.bmsmsd", Bmsmsd) | ||
scenario_map.raw["tiles"][new_pickup.tile_index]["icons"] = ListContainer([PICKUP_ICON]) | ||
|
||
area10 = editor.get_file("gui/minimaps/c10_samus/s100_area10.bmsmsd", Bmsmsd) | ||
mapicon = area10.raw["tiles"][252] | ||
mapicon["icons"] = ListContainer([BABY_ICON]) | ||
for entity_group in new_pickup.entity_groups: | ||
scenario_file.add_actor_to_entity_groups(entity_group, new_pickup.name, True) | ||
|
||
|
||
def patch_custom_pickups(editor: PatcherEditor): | ||
_create_baby_pickup(editor) | ||
for new_pickup in new_pickups: | ||
add_pickups(editor, new_pickup) |