mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-14 02:31:51 +00:00
Minor adjustments
This commit is contained in:
parent
0dac336670
commit
ce0c2c4977
@ -391,11 +391,11 @@ export class ModInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {typeof Object} classHandle
|
* @param {Object} obj
|
||||||
* @param {({ $super, $old }) => any} extender
|
* @param {({ $super, $old }) => any} extender
|
||||||
*/
|
*/
|
||||||
extendClass(classHandle, extender) {
|
extendObject(obj, extender) {
|
||||||
const prototype = classHandle.prototype;
|
const prototype = obj.prototype;
|
||||||
|
|
||||||
const $super = Object.getPrototypeOf(prototype);
|
const $super = Object.getPrototypeOf(prototype);
|
||||||
const $old = {};
|
const $old = {};
|
||||||
@ -409,4 +409,13 @@ export class ModInterface {
|
|||||||
prototype[propertyName] = extensionMethods[propertyName];
|
prototype[propertyName] = extensionMethods[propertyName];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {typeof Object} classHandle
|
||||||
|
* @param {({ $super, $old }) => any} extender
|
||||||
|
*/
|
||||||
|
extendClass(classHandle, extender) {
|
||||||
|
this.extendObject(classHandle.prototype, extender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,6 +121,9 @@ export class ModLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.$shapez_registerMod = (modClass, meta) => {
|
window.$shapez_registerMod = (modClass, meta) => {
|
||||||
|
if (this.initialized) {
|
||||||
|
throw new Error("Can't register mod after modloader is initialized");
|
||||||
|
}
|
||||||
if (this.modLoadQueue.some(entry => entry.meta.id === meta.id)) {
|
if (this.modLoadQueue.some(entry => entry.meta.id === meta.id)) {
|
||||||
console.warn("Not registering mod", meta, "since a mod with the same id is already loaded");
|
console.warn("Not registering mod", meta, "since a mod with the same id is already loaded");
|
||||||
return;
|
return;
|
||||||
@ -151,8 +154,6 @@ export class ModLoader {
|
|||||||
|
|
||||||
delete window.$shapez_registerMod;
|
delete window.$shapez_registerMod;
|
||||||
|
|
||||||
this.initialized = true;
|
|
||||||
|
|
||||||
for (let i = 0; i < this.modLoadQueue.length; i++) {
|
for (let i = 0; i < this.modLoadQueue.length; i++) {
|
||||||
const { modClass, meta } = this.modLoadQueue[i];
|
const { modClass, meta } = this.modLoadQueue[i];
|
||||||
const modDataFile = "modsettings_" + meta.id + "__" + meta.version + ".json";
|
const modDataFile = "modsettings_" + meta.id + "__" + meta.version + ".json";
|
||||||
@ -190,6 +191,7 @@ export class ModLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.modLoadQueue = [];
|
this.modLoadQueue = [];
|
||||||
|
this.initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user