Skip to content

Commit

Permalink
feat(assets): Icons proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
marioparaschiv committed Nov 12, 2022
1 parent 68187e2 commit f798d73
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/api/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const assets: Assets = {};

try {
Patcher.after('enmity-assets', Assets, 'registerAsset', (_, [asset]: [Asset], id: number) => {
assets[asset.name] = { ...asset, id };
assets[asset.name] = Object.assign(asset, { id });
});

// Capture all assets that loaded before our patch
Expand All @@ -19,7 +19,7 @@ try {
if (!asset) break;
if (assets[asset.name]) continue;

assets[asset.name] = { ...asset, id };
assets[asset.name] = Object.assign(asset, { id });
}
} catch { }

Expand All @@ -39,4 +39,10 @@ export function getIDByName(name: string): number | null {
return assets[name]?.id;
}

export const Icons = new Proxy({}, {
get: (_, name: string) => {
return getIDByName(name);
}
})

export default { assets, getByName, getByID, getIDByName };

0 comments on commit f798d73

Please sign in to comment.