Implement Bubble controller, sprite and VR01 body behavior

This commit is contained in:
UnixNight committed 2026-11-02 16:57:54 -05:00
1 parent 9ea578492d
commit 1ae5f4251c
51 files changed
+2811 -54

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
#!/usr/bin/env python3
"""Export the original C3DBubble Canv1 unchanged into a generated directory.
Archive/id binding is recovered in docs/gameplay/bubble.md. This utility reads
assets only; it neither executes original code nor bakes pulse, tint or scaling.
"""
from __future__ import annotations
import argparse
import hashlib
import json
from pathlib import Path
from entities import resolve_asset
from omt import Database, FormatError, read_canvas, write_png
ARCHIVE_SHA256 = 'b584ffa4a38f4bc809b3ea8f4321e0c08f2719e22df41a3fb4cd143ed89b3bef'
PAYLOAD_SHA256 = '9b6cdce95bd408fa1dc806d30520df65971f25d1663ab8da4ca6bf41380805ec'
RGBA_SHA256 = 'a3a678c47c1ce94946b1136560a84f3ef86c6884b981256a9fbff62fe8a988e4'
def digest(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()
def export_bubble(original: Path, output: Path) -> dict:
original, output = original.resolve(), output.resolve()
if output.is_relative_to(original) or original.is_relative_to(output):
raise ValueError('Output must be separate from the original installation')
# Guard output aliases before any write, including existing child symlinks.
files = {name: output/name for name in ('canvas_1.rgba', 'canvas_1.png', 'bubble.json')}
if any(path.resolve() != path for path in files.values()):
raise ValueError('Generated Bubble files must not be symlinks')
database = Database(resolve_asset(original, 'omt/RetainedSprites.omt'))
if digest(database.data) != ARCHIVE_SHA256:
raise FormatError('Unexpected original Bubble archive identity')
matches = [e for e in database.entries if e.type == 'Canv' and e.id == 1]
if len(matches) != 1:
raise FormatError('Expected one original Bubble Canv1')
entry = matches[0]
if (entry.name, entry.offset, entry.size) != ('orangebubble', 0x17FCE, 66322):
raise FormatError('Unexpected original Bubble canvas metadata')
payload = database.payload(entry)
if digest(payload) != PAYLOAD_SHA256:
raise FormatError('Unexpected original Bubble payload identity')
canvas = read_canvas(payload)
rgba = canvas['rgba']
if (canvas['width'], canvas['height'], len(rgba)) != (146, 146, 146*146*4):
raise FormatError('Unexpected original Bubble canvas dimensions')
if digest(rgba) != RGBA_SHA256:
raise FormatError('Unexpected original Bubble decoded pixels')
manifest = dict(schema=1, source=database.path.name, sourceSha256=ARCHIVE_SHA256,
textures=[dict(id=1, name=entry.name, width=146, height=146,
path='canvas_1.rgba', png='canvas_1.png', sourceOffset=entry.offset,
sourceBytes=entry.size, sourceSha256=PAYLOAD_SHA256, rgbaSha256=RGBA_SHA256)])
output.mkdir(parents=True, exist_ok=True)
files['canvas_1.rgba'].write_bytes(rgba)
write_png(files['canvas_1.png'], 146, 146, rgba)
files['bubble.json'].write_text(json.dumps(manifest, indent=2)+'\n', encoding='utf-8')
return manifest
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('original', type=Path)
parser.add_argument('--output', type=Path, required=True, help='Generated texture directory')
args = parser.parse_args()
export_bubble(args.original, args.output)
print(f'Original Bubble Canv1 exported: {args.output}/bubble.json')
if __name__ == '__main__':
main()