Skip to content

Commit

Permalink
Merge pull request #73 from randovania/feature/suit-cosmetics
Browse files Browse the repository at this point in the history
suit cosmetics
  • Loading branch information
duncathan authored Aug 2, 2023
2 parents b5cb0bb + 4958435 commit dad566d
Show file tree
Hide file tree
Showing 226 changed files with 176 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import dataclasses
import functools
from pathlib import Path

from retro_data_structures.asset_manager import AssetManager
from retro_data_structures.formats import Ancs, Cmdl


@functools.cache
def custom_asset_path() -> Path:
return Path(__file__).parent


@dataclasses.dataclass
class TranslatorAssets:
name: str
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions src/open_prime_rando/echoes/dock_lock_rando/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from pathlib import Path

from construct import Container
from retro_data_structures.base_resource import AssetId, RawResource
from retro_data_structures.formats.cmdl import Cmdl
from retro_data_structures.game_check import Game

from open_prime_rando.echoes.custom_assets import custom_asset_path
from open_prime_rando.echoes.dock_lock_rando import dock_type
from open_prime_rando.echoes.dock_lock_rando.dock_type_database import DOCK_TYPES
from open_prime_rando.patcher_editor import PatcherEditor


def add_custom_models(editor: PatcherEditor):
assets = Path(__file__).parent.parent.joinpath("custom_assets", "doors")
assets = custom_asset_path().joinpath("doors")
def get_txtr(n: str, must_exist: bool = True) -> AssetId:
f = assets.joinpath(n)
if not must_exist and not f.exists():
Expand Down
38 changes: 37 additions & 1 deletion src/open_prime_rando/echoes/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,36 @@
"type": "boolean",
"description": "Set elevators to be activated on room load",
"default": false
},
"cosmetics": {
"type": "object",
"properties": {
"suits": {
"type": "object",
"properties": {
"varia": {
"$ref": "#/$defs/suit_skin"
},
"dark": {
"$ref": "#/$defs/suit_skin"
},
"light": {
"$ref": "#/$defs/suit_skin"
}
},
"additionalProperties": false,
"$comment": "Choose from a number of custom suit textures"
}
},
"additionalProperties": false,
"required": [
"suits"
]
}
},
"required": [
"small_randomizations"
"small_randomizations",
"cosmetics"
],
"additionalProperties": false,
"$defs": {
Expand Down Expand Up @@ -219,6 +245,16 @@
"type": "integer"
}
}
},
"suit_skin": {
"type": "string",
"enum": [
"player1",
"player2",
"player3",
"player4"
],
"default": "player1"
}
}
}
4 changes: 2 additions & 2 deletions src/open_prime_rando/echoes/small_randomizations/rubiks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import random
from dataclasses import dataclass
from pathlib import Path

from retro_data_structures.base_resource import RawResource
from retro_data_structures.enums.echoes import Message, State
Expand All @@ -13,6 +12,7 @@

from open_prime_rando.echoes.asset_ids.sanctuary_fortress import MAIN_GYRO_CHAMBER_MREA
from open_prime_rando.echoes.asset_ids.world import SANCTUARY_FORTRESS_MLVL
from open_prime_rando.echoes.custom_assets import custom_asset_path
from open_prime_rando.patcher_editor import PatcherEditor

RUBIKS_CUBES = {
Expand Down Expand Up @@ -44,7 +44,7 @@ def txtr_name(self) -> str:
def txtr(self) -> RawResource:
return RawResource(
type="TXTR",
data=Path(__file__).parent.parent.joinpath("custom_assets", "rubiks", self.txtr_name).read_bytes()
data=custom_asset_path().joinpath("rubiks", self.txtr_name).read_bytes(),
)


Expand Down
23 changes: 23 additions & 0 deletions src/open_prime_rando/echoes/suit_cosmetics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from retro_data_structures.base_resource import RawResource

from open_prime_rando.echoes.custom_assets import custom_asset_path
from open_prime_rando.echoes.suit_cosmetics.asset_map import SUIT_ASSETS
from open_prime_rando.patcher_editor import PatcherEditor


def apply_custom_suits(editor: PatcherEditor, configuration: dict):
for suit, assets in SUIT_ASSETS.items():
skin = configuration[suit]
if skin == "player1":
continue
custom_suit_assets = custom_asset_path().joinpath("suits", skin, suit)
for asset_id, filename in assets.items():
asset = custom_suit_assets.joinpath(filename)
if not asset.exists():
continue # some skins leave a few assets vanilla

res = RawResource(
type="TXTR",
data=asset.read_bytes(),
)
editor.replace_asset(asset_id, res)
84 changes: 84 additions & 0 deletions src/open_prime_rando/echoes/suit_cosmetics/asset_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from retro_data_structures.base_resource import AssetId

SUIT_ASSETS: dict[str, dict[AssetId, str]] = {
"varia": {
0x788432DA: "samus_varia_visor.TXTR",
0xC2DE6C2A: "samus_varia_visor_emissive.TXTR",
0x86FF8630: "samus_varia_visor_polish.TXTR",
0x12B6539F: "samus_varia_banding.TXTR",
0x42DFBEBF: "samus_varia_banding_2.TXTR",
0x604D4DC5: "samus_varia_flex.TXTR",
0xE3001044: "samus_varia_flex_polish.TXTR",
0xE8AF7174: "samus_varia_armor.TXTR",
0xFFD9D212: "samus_varia_armor_polish.TXTR",
0x8FF8E517: "samus_varia_trim.TXTR",
0x2883811B: "samus_varia_trim_polish.TXTR",
0x355E4212: "samus_varia_metallic.TXTR",
0x0EF3BA76: "samus_varia_morph_shell.TXTR",
0x0CC73555: "samus_varia_morph_emissive.TXTR",
0x3C214DF7: "samus_varia_morph_banding.TXTR",
0xAAEC3745: "samus_varia_morph_metallic.TXTR",
0x1E5621F5: "samus_varia_low_res_armor.TXTR",
0x97FEE0A8: "samus_varia_low_res_armor_polish.TXTR",
0x23B19B14: "samus_varia_low_res_emissive.TXTR",
0xDD1473FC: "samus_varia_low_res_metallic.TXTR",
0x2777D332: "samus_varia_morph_2_shell.TXTR",
0xEB669581: "samus_varia_morph_2_shell_polish.TXTR",
0xA29AEF93: "samus_varia_morph_3_shell.TXTR",
0x9643B175: "samus_varia_morph_3_shell_polish.TXTR",
0x2F566CEC: "samus_morph_2_3_metallic.TXTR",
0x9BD4E4B3: "samus_varia_armor_polish_2.TXTR",
0xB29C1225: "samus_varia_left_arm_metallic.TXTR",
},
"dark": {
0x022045C3: "samus_dark_visor.TXTR",
0xA3BB66A5: "samus_dark_visor_emissive.TXTR",
0x27805BC6: "samus_dark_visor_scanlines.TXTR",
0xB29C1225: "samus_dark_visor_metallic.TXTR",
0x9FCF0D60: "samus_dark_spot_accent.TXTR",
0xB95FE642: "samus_dark_armor.TXTR",
0x3B843F46: "samus_dark_armor_metallic.TXTR",
0xA283E265: "samus_dark_backpack.TXTR",
0x9255BD83: "samus_dark_morph.TXTR",
0x33CE9EE5: "samus_dark_morph_emissive.TXTR",
0x52E13615: "samus_dark_morph_polish.TXTR",
0x719F387E: "samus_dark_morph_trim.TXTR",
0xD0041B18: "samus_dark_morph_trim_2.TXTR",
0x59C822A0: "samus_dark_spider.TXTR",
0xF85301C6: "samus_dark_spider_emissive.TXTR",
0x8CF8043C: "samus_dark_spider_polish.TXTR",
0x21722E06: "samus_dark_spider_glass.TXTR",
0x459769C7: "samus_dark_spider_glass_polish.TXTR",
0x7F5781D8: "samus_dark_low_res_armor.TXTR",
0xFF45E6C4: "samus_dark_low_res_armor_emissive.TXTR",
0x091ACC33: "samus_dark_low_res_backpack.TXTR",
0xDD1473FC: "samus_dark_low_res_armor_metallic.TXTR",
0x2F566CEC: "samus_morph_2_3_metallic.TXTR",
0x80A7CF0D: "samus_dark_left_arm_reflective.TXTR",
0xD31B3FB2: "samus_dark_left_arm_trim.TXTR",
0xB6728B45: "samus_dark_left_arm_trim_2.TXTR",
0xB34CE6A0: "samus_dark_mini_emissive.TXTR",
0x587282CC: "samus_grapple_gear.TXTR",
0x1BA9033F: "samus_grapple_gear_metallic.TXTR",
},
"light": {
0xCB737809: "samus_light_visor_core_on.TXTR",
0xF5E3D9FF: "samus_light_visor_core_off.TXTR",
0x0B7D7395: "samus_light_visor_core_emissive.TXTR",
0x8048F092: "samus_light_visor_streaks.TXTR",
0xADA9C079: "samus_light_core_beam.TXTR",
0xC2B83ED1: "samus_light_core_beam_pattern.TXTR",
0x5B3271CA: "samus_light_armor.TXTR",
0xC35540DE: "samus_light_armor_metallic.TXTR",
0x091A32D6: "samus_light_morph_shell.TXTR",
0xC6A37961: "samus_light_morph_emissive.TXTR",
0x0662A1C7: "samus_light_morph_metallic.TXTR",
0x8A598DD2: "samus_light_low_res_armor.TXTR",
0x95E79836: "samus_light_low_res_armor_emissive.TXTR",
0x0C32C6DA: "samus_light_left_arm.TXTR",
0xC9B164A1: "samus_light_left_arm_trim.TXTR",
0x087D0789: "samus_light_left_arm_trim_2.TXTR",
0xA240A5D3: "samus_light_mini_core_off.TXTR",
0xAA2D0CCF: "samus_light_mini_emissive.TXTR",
},
}
3 changes: 3 additions & 0 deletions src/open_prime_rando/echoes_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from open_prime_rando.echoes.elevators.elevator_rando import patch_elevator
from open_prime_rando.echoes.inverted import apply_inverted
from open_prime_rando.echoes.small_randomizations import apply_small_randomizations
from open_prime_rando.echoes.suit_cosmetics import apply_custom_suits
from open_prime_rando.patcher_editor import PatcherEditor
from open_prime_rando.validator_with_default import DefaultValidatingDraft7Validator

Expand Down Expand Up @@ -149,6 +150,8 @@ def patch_paks(file_provider: FileProvider,
if configuration["inverted"]:
apply_inverted(editor)

apply_custom_suits(editor, configuration["cosmetics"]["suits"])

# Save our changes
editor.flush_modified_assets()

Expand Down
4 changes: 2 additions & 2 deletions tests/echoes/test_full_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_ntsc_paks(prime2_iso_provider, tmp_path, test_files_dir):
output_path=output_path,
configuration=configuration,
)
assert len(list(output_path.rglob("*.pak"))) == 7
assert len(list(output_path.rglob("*.pak"))) == 11


def test_pal_paks(pal_prime2_iso_provider, tmp_path, test_files_dir):
Expand All @@ -22,4 +22,4 @@ def test_pal_paks(pal_prime2_iso_provider, tmp_path, test_files_dir):
output_path=output_path,
configuration=configuration,
)
assert len(list(output_path.rglob("*.pak"))) == 7
assert len(list(output_path.rglob("*.pak"))) == 11
9 changes: 8 additions & 1 deletion tests/test_files/echoes/door_lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3319,5 +3319,12 @@
"minigyro_chamber": true,
"rubiks": true
},
"inverted": false
"inverted": false,
"cosmetics": {
"suits": {
"varia": "player1",
"dark": "player2",
"light": "player3"
}
}
}
9 changes: 8 additions & 1 deletion tests/test_files/echoes/portal_rando.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,12 @@
"minigyro_chamber": true,
"rubiks": true
},
"inverted": false
"inverted": false,
"cosmetics": {
"suits": {
"varia": "player2",
"dark": "player3",
"light": "player4"
}
}
}

0 comments on commit dad566d

Please sign in to comment.