"""snd.py: sound cues by Rebirth sound id (reference sounds.json's resources).""" import json S = {r['id']: r for r in json.load(open('tools/reference/rebirth/sounds.json'))} def res(i): return S[i]['resource'] def snd(i, on): names = res(i) if isinstance(i, int) else [n for x in i for n in res(x)] return {"sounds": names, "on": on} def anims(path): """{animation: (frames, loop, [(event, frame)])} of a dump anm2.""" import xml.etree.ElementTree as ET D = '/home/anon/sda/Personal/Projects/Binding of Isaac Repentance Mods/shweet-sprites/dump/rep+full/resources/' r = ET.parse(D + path).getroot() ev = {e.get('Id'): e.get('Name') for e in r.iter('Event')} return {a.get('Name'): (int(a.get('FrameNum')), a.get('Loop') == 'true', [(ev[t.get('EventId')], int(t.get('AtFrame'))) for t in a.iter('Trigger')]) for a in r.iter('Animation')}