mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-30 14:38:43 +01:00
33 lines
614 B
TypeScript
33 lines
614 B
TypeScript
let manifest: object;
|
|
|
|
export default class CacheBustedLoaderPlugin extends Phaser.Loader.LoaderPlugin {
|
|
constructor(scene: Phaser.Scene) {
|
|
super(scene);
|
|
}
|
|
|
|
get manifest() {
|
|
return manifest;
|
|
}
|
|
|
|
set manifest(manifestObj: object) {
|
|
manifest = manifestObj;
|
|
}
|
|
|
|
addFile(file): void {
|
|
if (!Array.isArray(file)) {
|
|
file = [ file ];
|
|
}
|
|
|
|
file.forEach(item => {
|
|
if (manifest) {
|
|
const timestamp = manifest[`/${item.url.replace(/\/\//g, "/")}`];
|
|
if (timestamp) {
|
|
item.url += `?t=${timestamp}`;
|
|
}
|
|
}
|
|
});
|
|
|
|
super.addFile(file);
|
|
}
|
|
}
|