isaacscript-common 14.1.1 → 14.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +37 -22
- package/dist/isaacscript-common.lua +135 -64
- package/dist/src/callbacks.d.ts +1 -1
- package/dist/src/callbacks.d.ts.map +1 -1
- package/dist/src/callbacks.lua +7 -16
- package/dist/src/classes/ModFeature.d.ts +16 -4
- package/dist/src/classes/ModFeature.d.ts.map +1 -1
- package/dist/src/classes/ModFeature.lua +46 -4
- package/dist/src/classes/ModUpgraded.d.ts +2 -7
- package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
- package/dist/src/classes/ModUpgraded.lua +28 -6
- package/dist/src/classes/private/Feature.d.ts +0 -1
- package/dist/src/classes/private/Feature.d.ts.map +1 -1
- package/dist/src/classes/private/Feature.lua +0 -1
- package/dist/src/core/upgradeMod.d.ts +2 -5
- package/dist/src/core/upgradeMod.d.ts.map +1 -1
- package/dist/src/core/upgradeMod.lua +2 -2
- package/dist/src/decorators.d.ts +2 -1
- package/dist/src/decorators.d.ts.map +1 -1
- package/dist/src/decorators.lua +8 -1
- package/dist/src/functions/decorators.d.ts +7 -6
- package/dist/src/functions/decorators.d.ts.map +1 -1
- package/dist/src/functions/decorators.lua +24 -5
- package/dist/src/functions/logMisc.d.ts +9 -2
- package/dist/src/functions/logMisc.d.ts.map +1 -1
- package/dist/src/functions/logMisc.lua +32 -2
- package/dist/src/functions/tstlClass.d.ts +0 -2
- package/dist/src/functions/tstlClass.d.ts.map +1 -1
- package/dist/src/functions/tstlClass.lua +0 -19
- package/dist/src/interfaces/TSTLClassMetatable.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/callbacks.ts +9 -9
- package/src/classes/ModFeature.ts +66 -6
- package/src/classes/ModUpgraded.ts +51 -12
- package/src/classes/private/Feature.ts +0 -2
- package/src/core/upgradeMod.ts +6 -11
- package/src/decorators.ts +20 -2
- package/src/functions/decorators.ts +61 -12
- package/src/functions/logMisc.ts +28 -2
- package/src/functions/tstlClass.ts +0 -15
- package/src/interfaces/TSTLClassMetatable.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -79,6 +79,10 @@ import { TrapdoorVariant } from 'isaac-typescript-definitions';
|
|
|
79
79
|
import { TrinketType } from 'isaac-typescript-definitions';
|
|
80
80
|
import { UseFlag } from 'isaac-typescript-definitions';
|
|
81
81
|
|
|
82
|
+
export declare const ADD_CALLBACK_ARGS_KEY = "__addCallbackArgs";
|
|
83
|
+
|
|
84
|
+
export declare const ADD_CALLBACK_CUSTOM_ARGS_KEY = "__addCallbackCustomArgs";
|
|
85
|
+
|
|
82
86
|
declare interface AddCallbackParametersCustom {
|
|
83
87
|
[ModCallbackCustom.POST_AMBUSH_FINISHED]: PostAmbushFinishedRegisterParameters;
|
|
84
88
|
[ModCallbackCustom.POST_AMBUSH_STARTED]: PostAmbushStartedRegisterParameters;
|
|
@@ -827,16 +831,18 @@ export declare function calculateStageTypeRepentance(stage: LevelStage): StageTy
|
|
|
827
831
|
/**
|
|
828
832
|
* A decorator function that signifies that the decorated class method should be automatically
|
|
829
833
|
* registered with `Mod.AddCallback`.
|
|
834
|
+
*
|
|
835
|
+
* @ignore
|
|
830
836
|
*/
|
|
831
837
|
export declare function Callback<T extends ModCallback>(modCallback: T, ...optionalArgs: AllButFirst<AddCallbackParameters[T]>): <Class extends ModFeature, Fn extends AddCallbackParameters[T][0]>(target: Class, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void;
|
|
832
838
|
|
|
833
839
|
/**
|
|
834
840
|
* A decorator function that signifies that the decorated class method should be automatically
|
|
835
841
|
* registered with `ModUpgraded.AddCallbackCustom`.
|
|
842
|
+
*
|
|
843
|
+
* @ignore
|
|
836
844
|
*/
|
|
837
|
-
export declare function CallbackCustom<T extends
|
|
838
|
-
mod: ModUpgraded;
|
|
839
|
-
}>(target: Class, propertyKey: string) => void;
|
|
845
|
+
export declare function CallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): <Class extends ModFeature, Fn extends AddCallbackParametersCustom[T][0]>(target: Class, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void;
|
|
840
846
|
|
|
841
847
|
declare type CallbackSignatureGridEntity = ((gridEntity: GridEntity) => void) | ((gridEntity: GridEntity, oldState: int, newState: int) => void);
|
|
842
848
|
|
|
@@ -2651,7 +2657,6 @@ declare class Feature {
|
|
|
2651
2657
|
featuresUsed?: ISCFeature[];
|
|
2652
2658
|
callbacksUsed?: CallbackTuple[];
|
|
2653
2659
|
customCallbacksUsed?: CustomCallbackTuple[];
|
|
2654
|
-
exportedMethods: string[];
|
|
2655
2660
|
}
|
|
2656
2661
|
|
|
2657
2662
|
export declare function fillLevelWithRedRooms(): void;
|
|
@@ -5911,8 +5916,6 @@ export declare function getTrinketTypes(): TrinketType[];
|
|
|
5911
5916
|
*/
|
|
5912
5917
|
export declare function getTSTLClassConstructor(object: unknown): TSTLClassMetatable["constructor"] | undefined;
|
|
5913
5918
|
|
|
5914
|
-
export declare function getTSTLClassMethods(object: unknown): FunctionTuple[];
|
|
5915
|
-
|
|
5916
5919
|
/**
|
|
5917
5920
|
* Helper function to get the name of a TypeScriptToLua class from the instantiated class object.
|
|
5918
5921
|
*
|
|
@@ -7522,8 +7525,6 @@ export declare function kColorEquals(kColor1: KColor, kColor2: KColor): boolean;
|
|
|
7522
7525
|
*/
|
|
7523
7526
|
export declare function keyboardToString(keyboard: Keyboard, uppercase: boolean): string | undefined;
|
|
7524
7527
|
|
|
7525
|
-
declare type KeysToScrubFromModClass = keyof Feature | LowercaseKeys<ModUpgraded>;
|
|
7526
|
-
|
|
7527
7528
|
/**
|
|
7528
7529
|
* For `EntityType.EFFECT` (1000), `EffectVariant.LADDER` (8).
|
|
7529
7530
|
*
|
|
@@ -7713,8 +7714,8 @@ export declare function logSet(set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>): vo
|
|
|
7713
7714
|
export declare function logSounds(): void;
|
|
7714
7715
|
|
|
7715
7716
|
/**
|
|
7716
|
-
* Helper function for logging every key and value of a table. This is a deep log; the function
|
|
7717
|
-
* recursively call itself if it counters a table within a table.
|
|
7717
|
+
* Helper function for logging every key and value of a Lua table. This is a deep log; the function
|
|
7718
|
+
* will recursively call itself if it counters a table within a table.
|
|
7718
7719
|
*
|
|
7719
7720
|
* This function will only work on tables that have string keys (because it logs the keys in order,
|
|
7720
7721
|
* instead of randomly). It will throw a run-time error if it encounters a non-string key.
|
|
@@ -7727,6 +7728,14 @@ export declare function logTable(luaTable: unknown, parentTables?: number): void
|
|
|
7727
7728
|
*/
|
|
7728
7729
|
export declare function logTableDifferences<K extends AnyNotNil, V>(table1: LuaMap<K, V>, table2: LuaMap<K, V>): void;
|
|
7729
7730
|
|
|
7731
|
+
/**
|
|
7732
|
+
* Helper function to log the keys of a Lua table. This is not a deep log; only the keys of the
|
|
7733
|
+
* top-most table will be logged.
|
|
7734
|
+
*
|
|
7735
|
+
* This function is useful for tables that have recursive references.
|
|
7736
|
+
*/
|
|
7737
|
+
export declare function logTableKeys(luaTable: unknown): void;
|
|
7738
|
+
|
|
7730
7739
|
/** Helper function for printing out every tear flag that is turned on. Useful when debugging. */
|
|
7731
7740
|
export declare function logTearFlags(flags: TearFlag | BitFlags<TearFlag>): void;
|
|
7732
7741
|
|
|
@@ -9450,12 +9459,22 @@ declare type ModCallbackCustomPlayer = MatchingCallbackCustom<CallbackSignatureP
|
|
|
9450
9459
|
declare type ModCallbackCustomRevive = MatchingCallbackCustom<CallbackSignatureRevive>;
|
|
9451
9460
|
|
|
9452
9461
|
/**
|
|
9453
|
-
* A helper class for
|
|
9454
|
-
*
|
|
9455
|
-
*
|
|
9462
|
+
* A helper class for mods that wants to represent their individual features as classes. Extend your
|
|
9463
|
+
* mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
|
|
9464
|
+
* that automatically subscribe to callbacks.
|
|
9465
|
+
*
|
|
9466
|
+
* For example:
|
|
9467
|
+
*
|
|
9468
|
+
* ```ts
|
|
9469
|
+
* export class MyFeature extends ModFeature {
|
|
9470
|
+
* @Callback(ModCallback.POST_GAME_STARTED)
|
|
9471
|
+
* postGameStarted(isContinued: boolean): void {
|
|
9472
|
+
* Isaac.DebugString(`Callback fired: POST_GAME_STARTED`);
|
|
9473
|
+
* }
|
|
9474
|
+
* }
|
|
9475
|
+
* ```
|
|
9456
9476
|
*/
|
|
9457
9477
|
export declare class ModFeature {
|
|
9458
|
-
private mod;
|
|
9459
9478
|
constructor(mod: ModUpgraded);
|
|
9460
9479
|
}
|
|
9461
9480
|
|
|
@@ -9519,24 +9538,20 @@ export declare class ModUpgraded implements Mod {
|
|
|
9519
9538
|
* conditions of how you registered the callback, it will be removed.
|
|
9520
9539
|
*/
|
|
9521
9540
|
RemoveCallbackCustom<T extends ModCallbackCustom2>(modCallbackCustom: T, callback: AddCallbackParametersCustom2[T][0]): void;
|
|
9522
|
-
/**
|
|
9523
|
-
* This method should only be used by the `upgradeMod` function. Returns the class methods from
|
|
9524
|
-
* the features that were added.
|
|
9525
|
-
*/
|
|
9526
|
-
initOptionalFeature(feature: ISCFeature): FunctionTuple[];
|
|
9527
9541
|
/** This is used to initialize both custom callbacks and "extra features". */
|
|
9528
9542
|
private initFeature;
|
|
9529
9543
|
private uninitFeature;
|
|
9544
|
+
/** Returns the names of the exported class methods from the features that were added. */
|
|
9545
|
+
private initOptionalFeature;
|
|
9530
9546
|
}
|
|
9531
9547
|
|
|
9532
9548
|
/**
|
|
9533
9549
|
* By specifying one or more optional features, end-users will get a version of `ModUpgraded` that
|
|
9534
9550
|
* has extra methods corresponding to the features.
|
|
9535
9551
|
*
|
|
9536
|
-
* We have to explicitly account for the empty array case, since `never` will
|
|
9537
|
-
* union.
|
|
9552
|
+
* We have to explicitly account for the empty array case, since the `never` will mess up the union.
|
|
9538
9553
|
*/
|
|
9539
|
-
declare type ModUpgradedWithFeatures<T extends ISCFeature> = [T] extends [never] ? ModUpgraded :
|
|
9554
|
+
declare type ModUpgradedWithFeatures<T extends ISCFeature> = [T] extends [never] ? ModUpgraded : ModUpgraded & Omit<UnionToIntersection<ISCFeatureToClass[T]>, keyof Feature>;
|
|
9540
9555
|
|
|
9541
9556
|
/**
|
|
9542
9557
|
* Helper function to move all of the players to where they would normally go when arriving at a new
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 14.1.
|
|
3
|
+
isaacscript-common 14.1.3
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -16939,18 +16939,12 @@ return ____exports
|
|
|
16939
16939
|
end,
|
|
16940
16940
|
["src.interfaces.TSTLClassMetatable"] = function(...)
|
|
16941
16941
|
local ____exports = {}
|
|
16942
|
-
return ____exports
|
|
16943
|
-
end,
|
|
16944
|
-
["src.types.FunctionTuple"] = function(...)
|
|
16945
|
-
local ____exports = {}
|
|
16946
16942
|
return ____exports
|
|
16947
16943
|
end,
|
|
16948
16944
|
["src.functions.tstlClass"] = function(...)
|
|
16949
16945
|
local ____lualib = require("lualib_bundle")
|
|
16950
16946
|
local Set = ____lualib.Set
|
|
16951
16947
|
local __TS__New = ____lualib.__TS__New
|
|
16952
|
-
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
16953
|
-
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
16954
16948
|
local ____exports = {}
|
|
16955
16949
|
local VANILLA_TSTL_CLASSES
|
|
16956
16950
|
local ____types = require("src.functions.types")
|
|
@@ -16982,23 +16976,6 @@ function ____exports.isVanillaTSTLClass(self, object)
|
|
|
16982
16976
|
end
|
|
16983
16977
|
VANILLA_TSTL_CLASSES = __TS__New(Set, {"Map", "Set", "WeakMap", "WeakSet"})
|
|
16984
16978
|
local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
|
|
16985
|
-
function ____exports.getTSTLClassMethods(self, object)
|
|
16986
|
-
local constructor = ____exports.getTSTLClassConstructor(nil, object)
|
|
16987
|
-
if constructor == nil then
|
|
16988
|
-
return {}
|
|
16989
|
-
end
|
|
16990
|
-
local classEntries = __TS__ObjectEntries(constructor.prototype)
|
|
16991
|
-
return __TS__ArrayFilter(
|
|
16992
|
-
classEntries,
|
|
16993
|
-
function(____, ____bindingPattern0)
|
|
16994
|
-
local value
|
|
16995
|
-
local key
|
|
16996
|
-
key = ____bindingPattern0[1]
|
|
16997
|
-
value = ____bindingPattern0[2]
|
|
16998
|
-
return not TSTL_CLASS_METATABLE_KEYS:has(key) and type(value) == "function"
|
|
16999
|
-
end
|
|
17000
|
-
)
|
|
17001
|
-
end
|
|
17002
16979
|
function ____exports.isDefaultMap(self, object)
|
|
17003
16980
|
local className = ____exports.getTSTLClassName(nil, object)
|
|
17004
16981
|
return className == "DefaultMap"
|
|
@@ -24506,6 +24483,32 @@ function ____exports.logTableDifferences(self, table1, table2)
|
|
|
24506
24483
|
end
|
|
24507
24484
|
end
|
|
24508
24485
|
end
|
|
24486
|
+
function ____exports.logTableKeys(self, luaTable)
|
|
24487
|
+
log(nil, "Printing out the keys of a Lua table:")
|
|
24488
|
+
if not isTable(nil, luaTable) then
|
|
24489
|
+
log(
|
|
24490
|
+
nil,
|
|
24491
|
+
(" n/a (encountered a variable of type \"" .. __TS__TypeOf(luaTable)) .. "\" instead of a table)"
|
|
24492
|
+
)
|
|
24493
|
+
return
|
|
24494
|
+
end
|
|
24495
|
+
local numElements = 0
|
|
24496
|
+
iterateTableInOrder(
|
|
24497
|
+
nil,
|
|
24498
|
+
luaTable,
|
|
24499
|
+
function(____, key)
|
|
24500
|
+
log(
|
|
24501
|
+
nil,
|
|
24502
|
+
tostring(key)
|
|
24503
|
+
)
|
|
24504
|
+
numElements = numElements + 1
|
|
24505
|
+
end
|
|
24506
|
+
)
|
|
24507
|
+
log(
|
|
24508
|
+
nil,
|
|
24509
|
+
" The size of the table was: " .. tostring(numElements)
|
|
24510
|
+
)
|
|
24511
|
+
end
|
|
24509
24512
|
function ____exports.logTearFlags(self, flags)
|
|
24510
24513
|
____exports.logFlags(nil, flags, TearFlag, "tear")
|
|
24511
24514
|
end
|
|
@@ -27124,7 +27127,6 @@ local Feature = ____exports.Feature
|
|
|
27124
27127
|
Feature.name = "Feature"
|
|
27125
27128
|
function Feature.prototype.____constructor(self)
|
|
27126
27129
|
self.initialized = false
|
|
27127
|
-
self.exportedMethods = {}
|
|
27128
27130
|
end
|
|
27129
27131
|
return ____exports
|
|
27130
27132
|
end,
|
|
@@ -30763,9 +30765,7 @@ return ____exports
|
|
|
30763
30765
|
end,
|
|
30764
30766
|
["src.callbacks"] = function(...)
|
|
30765
30767
|
local ____lualib = require("lualib_bundle")
|
|
30766
|
-
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
30767
30768
|
local __TS__New = ____lualib.__TS__New
|
|
30768
|
-
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
30769
30769
|
local ____exports = {}
|
|
30770
30770
|
local ____PostAmbushFinished = require("src.classes.callbacks.PostAmbushFinished")
|
|
30771
30771
|
local PostAmbushFinished = ____PostAmbushFinished.PostAmbushFinished
|
|
@@ -30867,6 +30867,8 @@ local ____PreCustomRevive = require("src.classes.callbacks.PreCustomRevive")
|
|
|
30867
30867
|
local PreCustomRevive = ____PreCustomRevive.PreCustomRevive
|
|
30868
30868
|
local ____ModCallbackCustom2 = require("src.enums.ModCallbackCustom2")
|
|
30869
30869
|
local ModCallbackCustom2 = ____ModCallbackCustom2.ModCallbackCustom2
|
|
30870
|
+
local ____enums = require("src.functions.enums")
|
|
30871
|
+
local getEnumValues = ____enums.getEnumValues
|
|
30870
30872
|
local ____utils = require("src.functions.utils")
|
|
30871
30873
|
local newObjectWithEnumKeys = ____utils.newObjectWithEnumKeys
|
|
30872
30874
|
local MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(nil, ModCallbackCustom2, {
|
|
@@ -30921,28 +30923,26 @@ local MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(nil, ModCallbackCusto
|
|
|
30921
30923
|
[ModCallbackCustom2.PRE_CUSTOM_REVIVE] = PreCustomRevive
|
|
30922
30924
|
})
|
|
30923
30925
|
function ____exports.getCallbacks(self)
|
|
30924
|
-
local
|
|
30925
|
-
|
|
30926
|
-
|
|
30927
|
-
|
|
30928
|
-
|
|
30929
|
-
local modCallbackCustom
|
|
30930
|
-
modCallbackCustom = ____bindingPattern0[1]
|
|
30931
|
-
constructor = ____bindingPattern0[2]
|
|
30932
|
-
return {
|
|
30933
|
-
modCallbackCustom,
|
|
30934
|
-
__TS__New(constructor)
|
|
30935
|
-
}
|
|
30936
|
-
end
|
|
30937
|
-
)
|
|
30926
|
+
local instantiatedClasses = {}
|
|
30927
|
+
for ____, modCallbackCustom in ipairs(getEnumValues(nil, ModCallbackCustom2)) do
|
|
30928
|
+
local constructor = MOD_CALLBACK_CUSTOM_TO_CLASS[modCallbackCustom]
|
|
30929
|
+
instantiatedClasses[modCallbackCustom] = __TS__New(constructor)
|
|
30930
|
+
end
|
|
30938
30931
|
return instantiatedClasses
|
|
30939
30932
|
end
|
|
30940
30933
|
return ____exports
|
|
30941
30934
|
end,
|
|
30942
30935
|
["src.decorators"] = function(...)
|
|
30943
30936
|
local ____exports = {}
|
|
30937
|
+
____exports.EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames"
|
|
30944
30938
|
function ____exports.Exported(self)
|
|
30945
|
-
return function(____,
|
|
30939
|
+
return function(____, target, propertyKey)
|
|
30940
|
+
local constructor = target.constructor
|
|
30941
|
+
if not (constructor[____exports.EXPORTED_METHOD_NAMES_KEY] ~= nil) then
|
|
30942
|
+
constructor[____exports.EXPORTED_METHOD_NAMES_KEY] = {}
|
|
30943
|
+
end
|
|
30944
|
+
local exportedMethodNames = constructor[____exports.EXPORTED_METHOD_NAMES_KEY]
|
|
30945
|
+
exportedMethodNames[#exportedMethodNames + 1] = propertyKey
|
|
30946
30946
|
end
|
|
30947
30947
|
end
|
|
30948
30948
|
return ____exports
|
|
@@ -34847,17 +34847,25 @@ ____exports.CALLBACK_REGISTER_FUNCTIONS = {
|
|
|
34847
34847
|
[ModCallbackCustom.PRE_ITEM_PICKUP] = preItemPickupRegister,
|
|
34848
34848
|
[ModCallbackCustom.PRE_NEW_LEVEL] = preNewLevelRegister
|
|
34849
34849
|
}
|
|
34850
|
+
return ____exports
|
|
34851
|
+
end,
|
|
34852
|
+
["src.types.FunctionTuple"] = function(...)
|
|
34853
|
+
local ____exports = {}
|
|
34850
34854
|
return ____exports
|
|
34851
34855
|
end,
|
|
34852
34856
|
["src.classes.ModUpgraded"] = function(...)
|
|
34853
34857
|
local ____lualib = require("lualib_bundle")
|
|
34854
34858
|
local __TS__Class = ____lualib.__TS__Class
|
|
34855
34859
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
34860
|
+
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
34856
34861
|
local ____exports = {}
|
|
34862
|
+
local getExportedMethodsFromFeature
|
|
34857
34863
|
local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
|
|
34858
34864
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
34859
34865
|
local ____callbacks = require("src.callbacks")
|
|
34860
34866
|
local getCallbacks = ____callbacks.getCallbacks
|
|
34867
|
+
local ____decorators = require("src.decorators")
|
|
34868
|
+
local EXPORTED_METHOD_NAMES_KEY = ____decorators.EXPORTED_METHOD_NAMES_KEY
|
|
34861
34869
|
local ____features = require("src.features")
|
|
34862
34870
|
local getFeatures = ____features.getFeatures
|
|
34863
34871
|
local ____exports = require("src.features.saveDataManager.exports")
|
|
@@ -34868,10 +34876,28 @@ local getTime = ____debugFunctions.getTime
|
|
|
34868
34876
|
local ____log = require("src.functions.log")
|
|
34869
34877
|
local getParentFunctionDescription = ____log.getParentFunctionDescription
|
|
34870
34878
|
local ____tstlClass = require("src.functions.tstlClass")
|
|
34871
|
-
local
|
|
34879
|
+
local getTSTLClassConstructor = ____tstlClass.getTSTLClassConstructor
|
|
34872
34880
|
local getTSTLClassName = ____tstlClass.getTSTLClassName
|
|
34873
34881
|
local ____callbackRegisterFunctions = require("src.objects.callbackRegisterFunctions")
|
|
34874
34882
|
local CALLBACK_REGISTER_FUNCTIONS = ____callbackRegisterFunctions.CALLBACK_REGISTER_FUNCTIONS
|
|
34883
|
+
function getExportedMethodsFromFeature(self, featureClass)
|
|
34884
|
+
local constructor = getTSTLClassConstructor(nil, featureClass)
|
|
34885
|
+
local exportedMethodNames = constructor[EXPORTED_METHOD_NAMES_KEY]
|
|
34886
|
+
return __TS__ArrayMap(
|
|
34887
|
+
exportedMethodNames,
|
|
34888
|
+
function(____, name)
|
|
34889
|
+
local featureClassRecord = featureClass
|
|
34890
|
+
local method = featureClassRecord[name]
|
|
34891
|
+
if method == nil then
|
|
34892
|
+
error("Failed to find a decorated exported method: " .. name)
|
|
34893
|
+
end
|
|
34894
|
+
local function wrappedMethod(____, ...)
|
|
34895
|
+
return featureClassRecord[name](featureClassRecord, ...)
|
|
34896
|
+
end
|
|
34897
|
+
return {name, wrappedMethod}
|
|
34898
|
+
end
|
|
34899
|
+
)
|
|
34900
|
+
end
|
|
34875
34901
|
____exports.ModUpgraded = __TS__Class()
|
|
34876
34902
|
local ModUpgraded = ____exports.ModUpgraded
|
|
34877
34903
|
ModUpgraded.name = "ModUpgraded"
|
|
@@ -34947,11 +34973,6 @@ function ModUpgraded.prototype.RemoveCallbackCustom(self, modCallbackCustom, cal
|
|
|
34947
34973
|
self:uninitFeature(callbackClass)
|
|
34948
34974
|
end
|
|
34949
34975
|
end
|
|
34950
|
-
function ModUpgraded.prototype.initOptionalFeature(self, feature)
|
|
34951
|
-
local featureClass = self.features[feature]
|
|
34952
|
-
self:initFeature(featureClass)
|
|
34953
|
-
return getTSTLClassMethods(nil, featureClass)
|
|
34954
|
-
end
|
|
34955
34976
|
function ModUpgraded.prototype.initFeature(self, feature)
|
|
34956
34977
|
if feature.initialized then
|
|
34957
34978
|
return
|
|
@@ -35022,17 +35043,52 @@ function ModUpgraded.prototype.uninitFeature(self, feature)
|
|
|
35022
35043
|
saveDataManagerRemove(nil, className)
|
|
35023
35044
|
end
|
|
35024
35045
|
end
|
|
35046
|
+
function ModUpgraded.prototype.initOptionalFeature(self, feature)
|
|
35047
|
+
local featureClass = self.features[feature]
|
|
35048
|
+
self:initFeature(featureClass)
|
|
35049
|
+
return getExportedMethodsFromFeature(nil, featureClass)
|
|
35050
|
+
end
|
|
35025
35051
|
return ____exports
|
|
35026
35052
|
end,
|
|
35027
35053
|
["src.classes.ModFeature"] = function(...)
|
|
35028
35054
|
local ____lualib = require("lualib_bundle")
|
|
35029
35055
|
local __TS__Class = ____lualib.__TS__Class
|
|
35056
|
+
local __TS__Spread = ____lualib.__TS__Spread
|
|
35030
35057
|
local ____exports = {}
|
|
35058
|
+
local addDecoratedCallbacks, addDecoratedCallbacksCustom
|
|
35059
|
+
local ____tstlClass = require("src.functions.tstlClass")
|
|
35060
|
+
local getTSTLClassConstructor = ____tstlClass.getTSTLClassConstructor
|
|
35061
|
+
function addDecoratedCallbacks(self, mod, modFeatureConstructor)
|
|
35062
|
+
local addCallbackArgs = modFeatureConstructor[____exports.ADD_CALLBACK_ARGS_KEY]
|
|
35063
|
+
if addCallbackArgs == nil then
|
|
35064
|
+
return
|
|
35065
|
+
end
|
|
35066
|
+
for ____, args in ipairs(addCallbackArgs) do
|
|
35067
|
+
mod:AddCallback(__TS__Spread(args))
|
|
35068
|
+
end
|
|
35069
|
+
end
|
|
35070
|
+
function addDecoratedCallbacksCustom(self, mod, modFeatureConstructor)
|
|
35071
|
+
local addCallbackCustomArgs = modFeatureConstructor[____exports.ADD_CALLBACK_CUSTOM_ARGS_KEY]
|
|
35072
|
+
if addCallbackCustomArgs == nil then
|
|
35073
|
+
return
|
|
35074
|
+
end
|
|
35075
|
+
for ____, args in ipairs(addCallbackCustomArgs) do
|
|
35076
|
+
mod:AddCallbackCustom(__TS__Spread(args))
|
|
35077
|
+
end
|
|
35078
|
+
end
|
|
35079
|
+
____exports.ADD_CALLBACK_ARGS_KEY = "__addCallbackArgs"
|
|
35080
|
+
____exports.ADD_CALLBACK_CUSTOM_ARGS_KEY = "__addCallbackCustomArgs"
|
|
35031
35081
|
____exports.ModFeature = __TS__Class()
|
|
35032
35082
|
local ModFeature = ____exports.ModFeature
|
|
35033
35083
|
ModFeature.name = "ModFeature"
|
|
35034
35084
|
function ModFeature.prototype.____constructor(self, mod)
|
|
35035
|
-
|
|
35085
|
+
local constructor = getTSTLClassConstructor(nil, self)
|
|
35086
|
+
if constructor == nil then
|
|
35087
|
+
error("Failed to get the TSTL class constructor for a mod feature.")
|
|
35088
|
+
end
|
|
35089
|
+
local modFeatureConstructor = constructor
|
|
35090
|
+
addDecoratedCallbacks(nil, mod, modFeatureConstructor)
|
|
35091
|
+
addDecoratedCallbacksCustom(nil, mod, modFeatureConstructor)
|
|
35036
35092
|
end
|
|
35037
35093
|
return ____exports
|
|
35038
35094
|
end,
|
|
@@ -46641,14 +46697,6 @@ end
|
|
|
46641
46697
|
function ____exports.loadShaderCrashFix(self, mod)
|
|
46642
46698
|
mod:AddCallback(ModCallback.POST_PLAYER_INIT, postPlayerInit)
|
|
46643
46699
|
end
|
|
46644
|
-
return ____exports
|
|
46645
|
-
end,
|
|
46646
|
-
["src.types.StartsWithLowercase"] = function(...)
|
|
46647
|
-
local ____exports = {}
|
|
46648
|
-
return ____exports
|
|
46649
|
-
end,
|
|
46650
|
-
["src.types.LowercaseKeys"] = function(...)
|
|
46651
|
-
local ____exports = {}
|
|
46652
46700
|
return ____exports
|
|
46653
46701
|
end,
|
|
46654
46702
|
["src.types.UnionToIntersection"] = function(...)
|
|
@@ -46715,9 +46763,9 @@ function ____exports.upgradeMod(self, modVanilla, features, ____debug, timeThres
|
|
|
46715
46763
|
loadShaderCrashFix(nil, modVanilla)
|
|
46716
46764
|
legacyInit(nil, mod)
|
|
46717
46765
|
for ____, feature in ipairs(features) do
|
|
46718
|
-
local
|
|
46766
|
+
local exportedMethodTuples = mod:initOptionalFeature(feature)
|
|
46719
46767
|
local modRecord = mod
|
|
46720
|
-
for ____, ____value in ipairs(
|
|
46768
|
+
for ____, ____value in ipairs(exportedMethodTuples) do
|
|
46721
46769
|
local funcName = ____value[1]
|
|
46722
46770
|
local func = ____value[2]
|
|
46723
46771
|
modRecord[funcName] = func
|
|
@@ -51839,28 +51887,43 @@ return ____exports
|
|
|
51839
51887
|
local ____lualib = require("lualib_bundle")
|
|
51840
51888
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
51841
51889
|
local ____exports = {}
|
|
51890
|
+
local ____ModFeature = require("src.classes.ModFeature")
|
|
51891
|
+
local ADD_CALLBACK_ARGS_KEY = ____ModFeature.ADD_CALLBACK_ARGS_KEY
|
|
51892
|
+
local ADD_CALLBACK_CUSTOM_ARGS_KEY = ____ModFeature.ADD_CALLBACK_CUSTOM_ARGS_KEY
|
|
51842
51893
|
function ____exports.Callback(self, modCallback, ...)
|
|
51843
51894
|
local optionalArgs = {...}
|
|
51844
51895
|
return function(____, target, propertyKey, _descriptor)
|
|
51845
51896
|
local methodName = propertyKey
|
|
51846
51897
|
local method = target[methodName]
|
|
51847
|
-
|
|
51898
|
+
local addCallbackArgs = {
|
|
51848
51899
|
modCallback,
|
|
51849
51900
|
method,
|
|
51850
51901
|
__TS__Spread(optionalArgs)
|
|
51851
|
-
|
|
51902
|
+
}
|
|
51903
|
+
local constructor = target.constructor
|
|
51904
|
+
if not (constructor[ADD_CALLBACK_ARGS_KEY] ~= nil) then
|
|
51905
|
+
constructor[ADD_CALLBACK_ARGS_KEY] = {}
|
|
51906
|
+
end
|
|
51907
|
+
local callbackTuples = constructor[ADD_CALLBACK_ARGS_KEY]
|
|
51908
|
+
callbackTuples[#callbackTuples + 1] = addCallbackArgs
|
|
51852
51909
|
end
|
|
51853
51910
|
end
|
|
51854
51911
|
function ____exports.CallbackCustom(self, modCallbackCustom, ...)
|
|
51855
51912
|
local optionalArgs = {...}
|
|
51856
|
-
return function(____, target, propertyKey)
|
|
51913
|
+
return function(____, target, propertyKey, _descriptor)
|
|
51857
51914
|
local methodName = propertyKey
|
|
51858
51915
|
local method = target[methodName]
|
|
51859
|
-
|
|
51916
|
+
local addCallbackArgs = {
|
|
51860
51917
|
modCallbackCustom,
|
|
51861
51918
|
method,
|
|
51862
51919
|
__TS__Spread(optionalArgs)
|
|
51863
|
-
|
|
51920
|
+
}
|
|
51921
|
+
local constructor = target.constructor
|
|
51922
|
+
if not (constructor[ADD_CALLBACK_CUSTOM_ARGS_KEY] ~= nil) then
|
|
51923
|
+
constructor[ADD_CALLBACK_CUSTOM_ARGS_KEY] = {}
|
|
51924
|
+
end
|
|
51925
|
+
local callbackTuples = constructor[ADD_CALLBACK_CUSTOM_ARGS_KEY]
|
|
51926
|
+
callbackTuples[#callbackTuples + 1] = addCallbackArgs
|
|
51864
51927
|
end
|
|
51865
51928
|
end
|
|
51866
51929
|
return ____exports
|
|
@@ -53583,6 +53646,14 @@ return ____exports
|
|
|
53583
53646
|
end,
|
|
53584
53647
|
["src.types.HasAllEnumKeys"] = function(...)
|
|
53585
53648
|
local ____exports = {}
|
|
53649
|
+
return ____exports
|
|
53650
|
+
end,
|
|
53651
|
+
["src.types.StartsWithLowercase"] = function(...)
|
|
53652
|
+
local ____exports = {}
|
|
53653
|
+
return ____exports
|
|
53654
|
+
end,
|
|
53655
|
+
["src.types.LowercaseKeys"] = function(...)
|
|
53656
|
+
local ____exports = {}
|
|
53586
53657
|
return ____exports
|
|
53587
53658
|
end,
|
|
53588
53659
|
["src.types.StartsWithUppercase"] = function(...)
|
package/dist/src/callbacks.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ declare const MOD_CALLBACK_CUSTOM_TO_CLASS: {
|
|
|
99
99
|
readonly 48: typeof PreCustomRevive;
|
|
100
100
|
};
|
|
101
101
|
export declare type ModCallbackCustomToClass = {
|
|
102
|
-
[
|
|
102
|
+
readonly [key in keyof typeof MOD_CALLBACK_CUSTOM_TO_CLASS]: InstanceType<typeof MOD_CALLBACK_CUSTOM_TO_CLASS[key]>;
|
|
103
103
|
};
|
|
104
104
|
export declare function getCallbacks(): ModCallbackCustomToClass;
|
|
105
105
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../../src/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AAC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AAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAKtE,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DvB,CAAC;AAEZ,oBAAY,wBAAwB,GAAG;IACrC,QAAQ,EAAE,GAAG,IAAI,MAAM,OAAO,4BAA4B,GAAG,YAAY,CACvE,OAAO,4BAA4B,CAAC,GAAG,CAAC,CACzC;CACF,CAAC;AAEF,wBAAgB,YAAY,IAAI,wBAAwB,CASvD"}
|
package/dist/src/callbacks.lua
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
3
2
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
-
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
5
3
|
local ____exports = {}
|
|
6
4
|
local ____PostAmbushFinished = require("src.classes.callbacks.PostAmbushFinished")
|
|
7
5
|
local PostAmbushFinished = ____PostAmbushFinished.PostAmbushFinished
|
|
@@ -103,6 +101,8 @@ local ____PreCustomRevive = require("src.classes.callbacks.PreCustomRevive")
|
|
|
103
101
|
local PreCustomRevive = ____PreCustomRevive.PreCustomRevive
|
|
104
102
|
local ____ModCallbackCustom2 = require("src.enums.ModCallbackCustom2")
|
|
105
103
|
local ModCallbackCustom2 = ____ModCallbackCustom2.ModCallbackCustom2
|
|
104
|
+
local ____enums = require("src.functions.enums")
|
|
105
|
+
local getEnumValues = ____enums.getEnumValues
|
|
106
106
|
local ____utils = require("src.functions.utils")
|
|
107
107
|
local newObjectWithEnumKeys = ____utils.newObjectWithEnumKeys
|
|
108
108
|
local MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(nil, ModCallbackCustom2, {
|
|
@@ -157,20 +157,11 @@ local MOD_CALLBACK_CUSTOM_TO_CLASS = newObjectWithEnumKeys(nil, ModCallbackCusto
|
|
|
157
157
|
[ModCallbackCustom2.PRE_CUSTOM_REVIVE] = PreCustomRevive
|
|
158
158
|
})
|
|
159
159
|
function ____exports.getCallbacks(self)
|
|
160
|
-
local
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
local modCallbackCustom
|
|
166
|
-
modCallbackCustom = ____bindingPattern0[1]
|
|
167
|
-
constructor = ____bindingPattern0[2]
|
|
168
|
-
return {
|
|
169
|
-
modCallbackCustom,
|
|
170
|
-
__TS__New(constructor)
|
|
171
|
-
}
|
|
172
|
-
end
|
|
173
|
-
)
|
|
160
|
+
local instantiatedClasses = {}
|
|
161
|
+
for ____, modCallbackCustom in ipairs(getEnumValues(nil, ModCallbackCustom2)) do
|
|
162
|
+
local constructor = MOD_CALLBACK_CUSTOM_TO_CLASS[modCallbackCustom]
|
|
163
|
+
instantiatedClasses[modCallbackCustom] = __TS__New(constructor)
|
|
164
|
+
end
|
|
174
165
|
return instantiatedClasses
|
|
175
166
|
end
|
|
176
167
|
return ____exports
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { ModUpgraded } from "./ModUpgraded";
|
|
2
|
+
export declare const ADD_CALLBACK_ARGS_KEY = "__addCallbackArgs";
|
|
3
|
+
export declare const ADD_CALLBACK_CUSTOM_ARGS_KEY = "__addCallbackCustomArgs";
|
|
2
4
|
/**
|
|
3
|
-
* A helper class for
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* A helper class for mods that wants to represent their individual features as classes. Extend your
|
|
6
|
+
* mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
|
|
7
|
+
* that automatically subscribe to callbacks.
|
|
8
|
+
*
|
|
9
|
+
* For example:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* export class MyFeature extends ModFeature {
|
|
13
|
+
* @Callback(ModCallback.POST_GAME_STARTED)
|
|
14
|
+
* postGameStarted(isContinued: boolean): void {
|
|
15
|
+
* Isaac.DebugString(`Callback fired: POST_GAME_STARTED`);
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
6
19
|
*/
|
|
7
20
|
export declare class ModFeature {
|
|
8
|
-
private mod;
|
|
9
21
|
constructor(mod: ModUpgraded);
|
|
10
22
|
}
|
|
11
23
|
//# sourceMappingURL=ModFeature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,4BAA4B,4BAA4B,CAAC;AAOtE;;;;;;;;;;;;;;;GAeG;AAEH,qBAAa,UAAU;gBACT,GAAG,EAAE,WAAW;CAU7B"}
|
|
@@ -1,13 +1,55 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__Spread = ____lualib.__TS__Spread
|
|
3
4
|
local ____exports = {}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
local addDecoratedCallbacks, addDecoratedCallbacksCustom
|
|
6
|
+
local ____tstlClass = require("src.functions.tstlClass")
|
|
7
|
+
local getTSTLClassConstructor = ____tstlClass.getTSTLClassConstructor
|
|
8
|
+
function addDecoratedCallbacks(self, mod, modFeatureConstructor)
|
|
9
|
+
local addCallbackArgs = modFeatureConstructor[____exports.ADD_CALLBACK_ARGS_KEY]
|
|
10
|
+
if addCallbackArgs == nil then
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
for ____, args in ipairs(addCallbackArgs) do
|
|
14
|
+
mod:AddCallback(__TS__Spread(args))
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
function addDecoratedCallbacksCustom(self, mod, modFeatureConstructor)
|
|
18
|
+
local addCallbackCustomArgs = modFeatureConstructor[____exports.ADD_CALLBACK_CUSTOM_ARGS_KEY]
|
|
19
|
+
if addCallbackCustomArgs == nil then
|
|
20
|
+
return
|
|
21
|
+
end
|
|
22
|
+
for ____, args in ipairs(addCallbackCustomArgs) do
|
|
23
|
+
mod:AddCallbackCustom(__TS__Spread(args))
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
____exports.ADD_CALLBACK_ARGS_KEY = "__addCallbackArgs"
|
|
27
|
+
____exports.ADD_CALLBACK_CUSTOM_ARGS_KEY = "__addCallbackCustomArgs"
|
|
28
|
+
--- A helper class for mods that wants to represent their individual features as classes. Extend your
|
|
29
|
+
-- mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
|
|
30
|
+
-- that automatically subscribe to callbacks.
|
|
31
|
+
--
|
|
32
|
+
-- For example:
|
|
33
|
+
--
|
|
34
|
+
-- ```ts
|
|
35
|
+
-- export class MyFeature extends ModFeature {
|
|
36
|
+
--
|
|
37
|
+
-- @Callback (ModCallback.POST_GAME_STARTED)
|
|
38
|
+
-- postGameStarted(isContinued: boolean): void {
|
|
39
|
+
-- Isaac.DebugString(`Callback fired: POST_GAME_STARTED`);
|
|
40
|
+
-- }
|
|
41
|
+
-- }
|
|
42
|
+
-- ```
|
|
7
43
|
____exports.ModFeature = __TS__Class()
|
|
8
44
|
local ModFeature = ____exports.ModFeature
|
|
9
45
|
ModFeature.name = "ModFeature"
|
|
10
46
|
function ModFeature.prototype.____constructor(self, mod)
|
|
11
|
-
|
|
47
|
+
local constructor = getTSTLClassConstructor(nil, self)
|
|
48
|
+
if constructor == nil then
|
|
49
|
+
error("Failed to get the TSTL class constructor for a mod feature.")
|
|
50
|
+
end
|
|
51
|
+
local modFeatureConstructor = constructor
|
|
52
|
+
addDecoratedCallbacks(nil, mod, modFeatureConstructor)
|
|
53
|
+
addDecoratedCallbacksCustom(nil, mod, modFeatureConstructor)
|
|
12
54
|
end
|
|
13
55
|
return ____exports
|