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

Use class for adding new spawn points #320

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 29 additions & 47 deletions src/open_samus_returns_rando/misc_patches/spawn_points.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,43 @@
from open_samus_returns_rando.patcher_editor import PatcherEditor


def _get_spawnpoint(editor: PatcherEditor):
actor_to_copy = {
"scenario": "s000_surface",
"layer": "5",
"actor": "ST_SG_Alpha_001",
}
spawnpoint = editor.resolve_actor_reference(actor_to_copy)
return spawnpoint


def _surface_east_connector(editor: PatcherEditor):
name_of_scenario = "s000_surface"
scenario_surface = editor.get_scenario(name_of_scenario)
name_of_spawnpoint = "ST_Surface_Connector"

spawnpoint = _get_spawnpoint(editor)

editor.copy_actor(
name_of_scenario, (-22800.0, 4450.0, 0.0), spawnpoint, name_of_spawnpoint, 5,
)

scenario_surface.add_actor_to_entity_groups("collision_camera_000", name_of_spawnpoint)
import typing

from open_samus_returns_rando.patcher_editor import PatcherEditor

def _surface_west_connector(editor: PatcherEditor):
name_of_scenario = "s110_surfaceb"
scenario_surfaceb = editor.get_scenario(name_of_scenario)
name_of_spawnpoint = "ST_SurfaceB_Connector"

spawnpoint = _get_spawnpoint(editor)
class NewSpawnPoint(typing.NamedTuple):
scenario: str
name: str
position: list[float]
rotation: int
entity_groups: list[str]

spawnpoint_actor = editor.copy_actor(
name_of_scenario, (-23179.0, 4500.0, 0.0), spawnpoint, name_of_spawnpoint, 5,
)

scenario_surfaceb.add_actor_to_entity_groups("collision_camera_017", name_of_spawnpoint)
new_spawnpoints = [
NewSpawnPoint(
"s000_surface", "ST_Surface_Connector", [-22800.0, 4450.0, 0.0], 90, ["collision_camera_000"]
),
NewSpawnPoint(
"s050_area5", "ST_Diggernaut_Chase_Respawn", [-2100.0, -4800.0, 0.0], 90, ["collision_camera_AfterChase_001"]
),
NewSpawnPoint(
"s110_surfaceb", "ST_SurfaceB_Connector", [-23179.0, 4500.0, 0.0], -90, ["collision_camera_017"]
),
]

spawnpoint_actor["rotation"][1] = -90

def add_spawnpoints(editor: PatcherEditor, new_spawnpoint: NewSpawnPoint):
template_sp = editor.get_scenario("s000_surface").raw.actors[5]["ST_SG_Alpha_001"]

def _diggernaut_chase_respawn(editor: PatcherEditor):
name_of_scenario = "s050_area5"
scenario_area5 = editor.get_scenario(name_of_scenario)
name_of_spawnpoint = "ST_Diggernaut_Chase_Respawn"
scenario_name = new_spawnpoint.scenario
scenario_file = editor.get_scenario(scenario_name)

spawnpoint = _get_spawnpoint(editor)
editor.copy_actor(scenario_name, new_spawnpoint.position, template_sp, new_spawnpoint.name, 5)

editor.copy_actor(
name_of_scenario, (-2100.0, -4800.0, 0.0), spawnpoint, name_of_spawnpoint, 5,
)
scenario_file.raw.actors[5][new_spawnpoint.name]["rotation"][1] = new_spawnpoint.rotation

scenario_area5.add_actor_to_entity_groups("collision_camera_AfterChase_001", name_of_spawnpoint)
for entity_group in new_spawnpoint.entity_groups:
scenario_file.add_actor_to_entity_groups(entity_group, new_spawnpoint.name, True)


def patch_custom_spawn_points(editor: PatcherEditor):
_surface_east_connector(editor)
_surface_west_connector(editor)
_diggernaut_chase_respawn(editor)
for new_spawnpoint in new_spawnpoints:
add_spawnpoints(editor, new_spawnpoint)