mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-15 19:21:49 +00:00
Add Extending of Class's Constructor
This commit is contained in:
parent
431453f1a2
commit
bdd19405cb
@ -483,6 +483,22 @@ export class ModInterface {
|
|||||||
this.extendObject(classHandle.prototype, extender);
|
this.extendObject(classHandle.prototype, extender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new class that extends another class (DOES NOT OVERWRITE)
|
||||||
|
*
|
||||||
|
* @template {constructable} C
|
||||||
|
* @param {C} classHandle
|
||||||
|
* @param {bindThis<(...args: ConstructorParameters<C>) => any, InstanceType<C>>} constructor
|
||||||
|
*/
|
||||||
|
extendConstructor(classHandle, constructor) {
|
||||||
|
return function (...args) {
|
||||||
|
const obj = new classHandle();
|
||||||
|
//@ts-ignore
|
||||||
|
constructor.apply(obj, args);
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user