mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-15 19:21:49 +00:00
Allow overwrite by default
Also changed syntax to be more like the other methods
This commit is contained in:
parent
18c112ec47
commit
66f6aeced1
@ -31,6 +31,11 @@ import { BaseHUDPart } from "../game/hud/base_hud_part";
|
|||||||
* @typedef {{new(...args: any[]): any, prototype: any}} constructable
|
* @typedef {{new(...args: any[]): any, prototype: any}} constructable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template O, T
|
||||||
|
* @typedef {{[P in keyof O as O[P] extends T ? P : never]: O[P] }} withOnlyType
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template {(...args: any) => any} F The function
|
* @template {(...args: any) => any} F The function
|
||||||
* @template {object} T The value of this
|
* @template {object} T The value of this
|
||||||
@ -484,19 +489,24 @@ export class ModInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new class that extends another class (DOES NOT OVERWRITE)
|
* @template {any} S Scope
|
||||||
|
* @template {withOnlyType<S, constructable>} T
|
||||||
|
* @template {keyof T} C Original constructor name
|
||||||
|
* @template {Extract<T[C], constructable>} M the method
|
||||||
*
|
*
|
||||||
* @template {constructable} C
|
|
||||||
* @param {C} classHandle
|
* @param {C} classHandle
|
||||||
* @param {bindThis<(...args: ConstructorParameters<C>) => any, InstanceType<C>>} constructor
|
* @param {bindThis<extendsPrams<(...args: ConstructorParameters<M>) => any>, InstanceType<M>>} constructor
|
||||||
* @returns {C}
|
* @param {S} scope
|
||||||
*/
|
*/
|
||||||
extendConstructor(classHandle, constructor) {
|
extendConstructor(scope, classHandle, constructor) {
|
||||||
//@ts-ignore
|
//@ts-ignore Holy crap guys so get this TSC IS A DUMBASS LMAO
|
||||||
return function (...args) {
|
const old = scope[classHandle];
|
||||||
const obj = new classHandle();
|
//@ts-ignore lmao (2)
|
||||||
//@ts-ignore
|
scope[classHandle] = function () {
|
||||||
constructor.apply(obj, args);
|
const obj = new old(...arguments);
|
||||||
|
//@ts-ignore lmao (3)
|
||||||
|
constructor.apply(obj, arguments);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user