[Assets] Properly assign asset id

This commit is contained in:
Beef 2022-10-22 23:43:51 +01:00
parent 62b843f9f6
commit 3b21f8f345

View file

@ -10,7 +10,7 @@ export default function patchAssets() {
try { try {
after("registerAsset", assetsModule, (args: Asset[], id: number) => { after("registerAsset", assetsModule, (args: Asset[], id: number) => {
const asset = args[0]; const asset = args[0];
all[asset.name] = { ...asset, id }; all[asset.name] = { ...asset, id: id };
}); });
for (let id = 1; ; id++) { for (let id = 1; ; id++) {
@ -24,4 +24,4 @@ export default function patchAssets() {
export const find = (filter: (a: any) => void): Asset | null | undefined => Object.values(all).find(filter); export const find = (filter: (a: any) => void): Asset | null | undefined => Object.values(all).find(filter);
export const getAssetByName = (name: string): Asset => all[name]; export const getAssetByName = (name: string): Asset => all[name];
export const getAssetByID = (name: string): Asset => assetsModule.getAssetByID(name); export const getAssetByID = (name: string): Asset => assetsModule.getAssetByID(name);
export const getAssetIDByName = (name: string) => all[name].id; export const getAssetIDByName = (name: string) => all[name]?.id;