isaacscript-common 15.6.2 → 16.0.0

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 CHANGED
@@ -1501,8 +1501,8 @@ declare abstract class CustomCallback<T extends ModCallbackCustom> extends Featu
1501
1501
 
1502
1502
  declare class CustomGridEntities extends Feature {
1503
1503
  private runInNFrames;
1504
- private postNewRoom;
1505
1504
  private preUseItemWeNeedToGoDeeper;
1505
+ private postNewRoomReordered;
1506
1506
  /**
1507
1507
  * Helper function to spawn a custom grid entity. Custom grid entities are persistent in that they
1508
1508
  * will reappear if the player leaves and re-enters the room. (It will be manually respawned in
@@ -1804,7 +1804,7 @@ declare class CustomRevive extends Feature {
1804
1804
  private postRender;
1805
1805
  private postPEffectUpdate;
1806
1806
  private checkWaitingForItemAnimation;
1807
- private postNewRoom;
1807
+ private postNewRoomReordered;
1808
1808
  private postPlayerFatalDamage;
1809
1809
  private preBerserkDeath;
1810
1810
  /**
@@ -6613,7 +6613,7 @@ declare class GridEntityUpdateDetection extends Feature {
6613
6613
  private checkGridEntityStateChanged;
6614
6614
  private checkNewGridEntity;
6615
6615
  private updateTupleInMap;
6616
- private postNewRoom;
6616
+ private postNewRoomReordered;
6617
6617
  }
6618
6618
 
6619
6619
  /**
@@ -10974,6 +10974,11 @@ export declare class ModUpgradedBase implements Mod {
10974
10974
  * don't have access to it..
10975
10975
  */
10976
10976
  private initOptionalFeature;
10977
+ /**
10978
+ * This is mostly the same as the `AddCustomCallback` method, but we initialize the custom
10979
+ * callback without actually registering a subscription.
10980
+ */
10981
+ private initCustomCallbackEarly;
10977
10982
  }
10978
10983
 
10979
10984
  export declare const MOVEMENT_ACTIONS_SET: ReadonlySet<ButtonAction>;
@@ -14434,6 +14439,14 @@ export declare type UnionToIntersection<U> = (U extends U ? (u: U) => 0 : never)
14434
14439
  * @param modVanilla The mod object returned by the `RegisterMod` function.
14435
14440
  * @param features Optional. An array containing the optional standard library features that you
14436
14441
  * want to enable, if any. Default is an empty array.
14442
+ * @param customCallbacksUsed Optional. An array containing the custom callbacks that you will be
14443
+ * subscribing to after you upgrade your mod. Specifying this will
14444
+ * immediately initialize the callbacks (as opposed to lazy-initializing
14445
+ * them when you first subscribe to the callback). This is only necessary
14446
+ * if you the order of callback firing is important for your mod. (For
14447
+ * example, you may want the `POST_NEW_ROOM` part of the
14448
+ * `POST_GRID_ENTITY_INIT` callback to fire before your own
14449
+ * `POST_NEW_ROOM` callbacks.)
14437
14450
  * @param debug Optional. Whether to log additional output when a callback is fired. Default is
14438
14451
  * false.
14439
14452
  * @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
@@ -14441,7 +14454,7 @@ export declare type UnionToIntersection<U> = (U extends U ? (u: U) => 0 : never)
14441
14454
  * or milliseconds (if the "--luadebug" launch flag is turned off).
14442
14455
  * @returns The upgraded mod object.
14443
14456
  */
14444
- export declare function upgradeMod<T extends readonly ISCFeature[] = never[]>(modVanilla: Mod, features?: ISCFeatureTuple<T>, debug?: boolean, timeThreshold?: float): ModUpgraded<T>;
14457
+ export declare function upgradeMod<T extends readonly ISCFeature[] = never[]>(modVanilla: Mod, features?: ISCFeatureTuple<T>, customCallbacksUsed?: ModCallbackCustom[] | readonly ModCallbackCustom[], debug?: boolean, timeThreshold?: float): ModUpgraded<T>;
14445
14458
 
14446
14459
  /** Helper type to match all of the uppercase keys of an object. */
14447
14460
  export declare type UppercaseKeys<T> = StartsWithUppercase<keyof T>;
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 15.6.2
3
+ isaacscript-common 16.0.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -1031,8 +1031,7 @@ do
1031
1031
  if not rawget(metatable, "_descriptors") then
1032
1032
  metatable._descriptors = {}
1033
1033
  end
1034
- local descriptor = __TS__CloneDescriptor(desc)
1035
- metatable._descriptors[key] = descriptor
1034
+ metatable._descriptors[key] = __TS__CloneDescriptor(desc)
1036
1035
  metatable.__index = descriptorIndex
1037
1036
  metatable.__newindex = descriptorNewIndex
1038
1037
  end
@@ -1668,22 +1667,6 @@ local function __TS__ParseFloat(numberString)
1668
1667
  return ____number_1
1669
1668
  end
1670
1669
 
1671
- local function __TS__StringSubstr(self, from, length)
1672
- if from ~= from then
1673
- from = 0
1674
- end
1675
- if length ~= nil then
1676
- if length ~= length or length <= 0 then
1677
- return ""
1678
- end
1679
- length = length + from
1680
- end
1681
- if from >= 0 then
1682
- from = from + 1
1683
- end
1684
- return string.sub(self, from, length)
1685
- end
1686
-
1687
1670
  local function __TS__StringSubstring(self, start, ____end)
1688
1671
  if ____end ~= ____end then
1689
1672
  ____end = 0
@@ -1713,9 +1696,9 @@ do
1713
1696
  base = 16
1714
1697
  local ____TS__Match_result__0_0
1715
1698
  if __TS__Match(hexMatch, "-") then
1716
- ____TS__Match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1699
+ ____TS__Match_result__0_0 = "-" .. __TS__StringSubstring(numberString, #hexMatch)
1717
1700
  else
1718
- ____TS__Match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1701
+ ____TS__Match_result__0_0 = __TS__StringSubstring(numberString, #hexMatch)
1719
1702
  end
1720
1703
  numberString = ____TS__Match_result__0_0
1721
1704
  end
@@ -1727,7 +1710,7 @@ do
1727
1710
  if base <= 10 then
1728
1711
  ____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, base)
1729
1712
  else
1730
- ____temp_1 = __TS__StringSubstr(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1713
+ ____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1731
1714
  end
1732
1715
  local allowedDigits = ____temp_1
1733
1716
  local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
@@ -2437,6 +2420,22 @@ local function __TS__StringStartsWith(self, searchString, position)
2437
2420
  return string.sub(self, position + 1, #searchString + position) == searchString
2438
2421
  end
2439
2422
 
2423
+ local function __TS__StringSubstr(self, from, length)
2424
+ if from ~= from then
2425
+ from = 0
2426
+ end
2427
+ if length ~= nil then
2428
+ if length ~= length or length <= 0 then
2429
+ return ""
2430
+ end
2431
+ length = length + from
2432
+ end
2433
+ if from >= 0 then
2434
+ from = from + 1
2435
+ end
2436
+ return string.sub(self, from, length)
2437
+ end
2438
+
2440
2439
  local function __TS__StringTrim(self)
2441
2440
  local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
2442
2441
  return result
@@ -31008,6 +31007,8 @@ local ____decorators = require("src.decorators")
31008
31007
  local Exported = ____decorators.Exported
31009
31008
  local ____ISCFeature = require("src.enums.ISCFeature")
31010
31009
  local ISCFeature = ____ISCFeature.ISCFeature
31010
+ local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
31011
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
31011
31012
  local ____gridEntities = require("src.functions.gridEntities")
31012
31013
  local removeGridEntity = ____gridEntities.removeGridEntity
31013
31014
  local spawnGridEntityWithVariant = ____gridEntities.spawnGridEntityWithVariant
@@ -31039,32 +31040,6 @@ function CustomGridEntities.prototype.____constructor(self, runInNFrames)
31039
31040
  manuallyUsingShovel = false
31040
31041
  }
31041
31042
  }
31042
- self.postNewRoom = function()
31043
- local roomListIndex = getRoomListIndex(nil)
31044
- local roomCustomGridEntities = self.v.level.customGridEntities:get(roomListIndex)
31045
- if roomCustomGridEntities == nil then
31046
- return
31047
- end
31048
- local room = game:GetRoom()
31049
- for ____, ____value in __TS__Iterator(roomCustomGridEntities:entries()) do
31050
- local gridIndex = ____value[1]
31051
- local data = ____value[2]
31052
- do
31053
- local decoration = room:GetGridEntity(gridIndex)
31054
- if decoration == nil then
31055
- roomCustomGridEntities:delete(gridIndex)
31056
- goto __continue6
31057
- end
31058
- if data.anm2Path ~= nil then
31059
- local sprite = decoration:GetSprite()
31060
- sprite:Load(data.anm2Path, true)
31061
- local animationToPlay = data.defaultAnimation == nil and sprite:GetDefaultAnimation() or data.defaultAnimation
31062
- sprite:Play(animationToPlay, true)
31063
- end
31064
- end
31065
- ::__continue6::
31066
- end
31067
- end
31068
31043
  self.preUseItemWeNeedToGoDeeper = function(____, _collectibleType, _rng, player, _useFlags, _activeSlot, _customVarData)
31069
31044
  local room = game:GetRoom()
31070
31045
  local roomListIndex = getRoomListIndex(nil)
@@ -31093,8 +31068,35 @@ function CustomGridEntities.prototype.____constructor(self, runInNFrames)
31093
31068
  end)
31094
31069
  return true
31095
31070
  end
31071
+ self.postNewRoomReordered = function()
31072
+ local roomListIndex = getRoomListIndex(nil)
31073
+ local roomCustomGridEntities = self.v.level.customGridEntities:get(roomListIndex)
31074
+ if roomCustomGridEntities == nil then
31075
+ return
31076
+ end
31077
+ local room = game:GetRoom()
31078
+ for ____, ____value in __TS__Iterator(roomCustomGridEntities:entries()) do
31079
+ local gridIndex = ____value[1]
31080
+ local data = ____value[2]
31081
+ do
31082
+ local decoration = room:GetGridEntity(gridIndex)
31083
+ if decoration == nil then
31084
+ roomCustomGridEntities:delete(gridIndex)
31085
+ goto __continue12
31086
+ end
31087
+ if data.anm2Path ~= nil then
31088
+ local sprite = decoration:GetSprite()
31089
+ sprite:Load(data.anm2Path, true)
31090
+ local animationToPlay = data.defaultAnimation == nil and sprite:GetDefaultAnimation() or data.defaultAnimation
31091
+ sprite:Play(animationToPlay, true)
31092
+ end
31093
+ end
31094
+ ::__continue12::
31095
+ end
31096
+ end
31096
31097
  self.featuresUsed = {ISCFeature.RUN_IN_N_FRAMES}
31097
- self.callbacksUsed = {{ModCallback.POST_NEW_ROOM, {self.postNewRoom}}, {ModCallback.PRE_USE_ITEM, {self.preUseItemWeNeedToGoDeeper, CollectibleType.WE_NEED_TO_GO_DEEPER}}}
31098
+ self.callbacksUsed = {{ModCallback.PRE_USE_ITEM, {self.preUseItemWeNeedToGoDeeper, CollectibleType.WE_NEED_TO_GO_DEEPER}}}
31099
+ self.customCallbacksUsed = {{ModCallbackCustom.POST_NEW_ROOM_REORDERED, {self.postNewRoomReordered}}}
31098
31100
  self.runInNFrames = runInNFrames
31099
31101
  end
31100
31102
  function CustomGridEntities.prototype.spawnCustomGridEntity(self, gridEntityTypeCustom, gridIndexOrPosition, gridCollisionClass, anm2Path, defaultAnimation, baseGridEntityType, baseGridEntityVariant)
@@ -31270,7 +31272,7 @@ function CustomRevive.prototype.____constructor(self, preCustomRevive, postCusto
31270
31272
  self.postPEffectUpdate = function(____, player)
31271
31273
  self:checkWaitingForItemAnimation(player)
31272
31274
  end
31273
- self.postNewRoom = function()
31275
+ self.postNewRoomReordered = function()
31274
31276
  if self.v.run.state ~= CustomReviveState.WAITING_FOR_ROOM_TRANSITION then
31275
31277
  return
31276
31278
  end
@@ -31285,8 +31287,8 @@ function CustomRevive.prototype.____constructor(self, preCustomRevive, postCusto
31285
31287
  self:playerIsAboutToDie(player)
31286
31288
  end
31287
31289
  self.featuresUsed = {ISCFeature.RUN_IN_N_FRAMES}
31288
- self.callbacksUsed = {{ModCallback.POST_RENDER, {self.postRender}}, {ModCallback.POST_PEFFECT_UPDATE, {self.postPEffectUpdate}}, {ModCallback.POST_NEW_ROOM, {self.postNewRoom}}}
31289
- self.customCallbacksUsed = {{ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE, {self.postPlayerFatalDamage}}, {ModCallbackCustom.PRE_BERSERK_DEATH, {self.preBerserkDeath}}}
31290
+ self.callbacksUsed = {{ModCallback.POST_RENDER, {self.postRender}}, {ModCallback.POST_PEFFECT_UPDATE, {self.postPEffectUpdate}}}
31291
+ self.customCallbacksUsed = {{ModCallbackCustom.POST_NEW_ROOM_REORDERED, {self.postNewRoomReordered}}, {ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE, {self.postPlayerFatalDamage}}, {ModCallbackCustom.PRE_BERSERK_DEATH, {self.preBerserkDeath}}}
31290
31292
  self.preCustomRevive = preCustomRevive
31291
31293
  self.postCustomRevive = postCustomRevive
31292
31294
  self.runInNFrames = runInNFrames
@@ -31682,6 +31684,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescri
31682
31684
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
31683
31685
  local ____ISCFeature = require("src.enums.ISCFeature")
31684
31686
  local ISCFeature = ____ISCFeature.ISCFeature
31687
+ local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
31688
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
31685
31689
  local ____gridEntities = require("src.functions.gridEntities")
31686
31690
  local getGridEntitiesMap = ____gridEntities.getGridEntitiesMap
31687
31691
  local isGridEntityBroken = ____gridEntities.isGridEntityBroken
@@ -31710,7 +31714,7 @@ function GridEntityUpdateDetection.prototype.____constructor(self, postGridEntit
31710
31714
  end
31711
31715
  end
31712
31716
  end
31713
- self.postNewRoom = function()
31717
+ self.postNewRoomReordered = function()
31714
31718
  local gridEntitiesMap = getGridEntitiesMap(nil)
31715
31719
  for ____, ____value in __TS__Iterator(gridEntitiesMap:entries()) do
31716
31720
  local gridIndex = ____value[1]
@@ -31719,7 +31723,8 @@ function GridEntityUpdateDetection.prototype.____constructor(self, postGridEntit
31719
31723
  end
31720
31724
  end
31721
31725
  self.featuresUsed = {ISCFeature.RUN_IN_N_FRAMES}
31722
- self.callbacksUsed = {{ModCallback.POST_UPDATE, {self.postUpdate}}, {ModCallback.POST_NEW_ROOM, {self.postNewRoom}}}
31726
+ self.callbacksUsed = {{ModCallback.POST_UPDATE, {self.postUpdate}}}
31727
+ self.customCallbacksUsed = {{ModCallbackCustom.POST_NEW_ROOM_REORDERED, {self.postNewRoomReordered}}}
31723
31728
  self.postGridEntityInit = postGridEntityInit
31724
31729
  self.postGridEntityCustomInit = postGridEntityCustomInit
31725
31730
  self.postGridEntityUpdate = postGridEntityUpdate
@@ -48942,6 +48947,10 @@ function ModUpgradedBase.prototype.initOptionalFeature(self, feature)
48942
48947
  self:initFeature(featureClass)
48943
48948
  return getExportedMethodsFromFeature(nil, featureClass)
48944
48949
  end
48950
+ function ModUpgradedBase.prototype.initCustomCallbackEarly(self, modCallbackCustom)
48951
+ local callbackClass = self.callbacks[modCallbackCustom]
48952
+ self:initFeature(callbackClass)
48953
+ end
48945
48954
  return ____exports
48946
48955
  end,
48947
48956
  ["src.classes.ModFeature"] = function(...)
@@ -49232,7 +49241,7 @@ return ____exports
49232
49241
  local ____lualib = require("lualib_bundle")
49233
49242
  local __TS__New = ____lualib.__TS__New
49234
49243
  local ____exports = {}
49235
- local initOptionalFeatures
49244
+ local initOptionalFeatures, initCallbacksEarly
49236
49245
  local ____ModUpgradedBase = require("src.classes.ModUpgradedBase")
49237
49246
  local ModUpgradedBase = ____ModUpgradedBase.ModUpgradedBase
49238
49247
  local ____patchErrorFunctions = require("src.patchErrorFunctions")
@@ -49250,10 +49259,18 @@ function initOptionalFeatures(self, mod, features)
49250
49259
  end
49251
49260
  end
49252
49261
  end
49253
- function ____exports.upgradeMod(self, modVanilla, features, ____debug, timeThreshold)
49262
+ function initCallbacksEarly(self, mod, callbacks)
49263
+ for ____, modCallbackCustom in ipairs(callbacks) do
49264
+ mod.initCustomCallbackEarly(mod, modCallbackCustom)
49265
+ end
49266
+ end
49267
+ function ____exports.upgradeMod(self, modVanilla, features, customCallbacksUsed, ____debug, timeThreshold)
49254
49268
  if features == nil then
49255
49269
  features = {}
49256
49270
  end
49271
+ if customCallbacksUsed == nil then
49272
+ customCallbacksUsed = {}
49273
+ end
49257
49274
  if ____debug == nil then
49258
49275
  ____debug = false
49259
49276
  end
@@ -49261,6 +49278,7 @@ function ____exports.upgradeMod(self, modVanilla, features, ____debug, timeThres
49261
49278
  local mod = __TS__New(ModUpgradedBase, modVanilla, ____debug, timeThreshold)
49262
49279
  applyShaderCrashFix(nil, mod)
49263
49280
  initOptionalFeatures(nil, mod, features)
49281
+ initCallbacksEarly(nil, mod, customCallbacksUsed)
49264
49282
  return mod
49265
49283
  end
49266
49284
  return ____exports
@@ -972,8 +972,7 @@ do
972
972
  if not rawget(metatable, "_descriptors") then
973
973
  metatable._descriptors = {}
974
974
  end
975
- local descriptor = __TS__CloneDescriptor(desc)
976
- metatable._descriptors[key] = descriptor
975
+ metatable._descriptors[key] = __TS__CloneDescriptor(desc)
977
976
  metatable.__index = descriptorIndex
978
977
  metatable.__newindex = descriptorNewIndex
979
978
  end
@@ -1609,22 +1608,6 @@ local function __TS__ParseFloat(numberString)
1609
1608
  return ____number_1
1610
1609
  end
1611
1610
 
1612
- local function __TS__StringSubstr(self, from, length)
1613
- if from ~= from then
1614
- from = 0
1615
- end
1616
- if length ~= nil then
1617
- if length ~= length or length <= 0 then
1618
- return ""
1619
- end
1620
- length = length + from
1621
- end
1622
- if from >= 0 then
1623
- from = from + 1
1624
- end
1625
- return string.sub(self, from, length)
1626
- end
1627
-
1628
1611
  local function __TS__StringSubstring(self, start, ____end)
1629
1612
  if ____end ~= ____end then
1630
1613
  ____end = 0
@@ -1654,9 +1637,9 @@ do
1654
1637
  base = 16
1655
1638
  local ____TS__Match_result__0_0
1656
1639
  if __TS__Match(hexMatch, "-") then
1657
- ____TS__Match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1640
+ ____TS__Match_result__0_0 = "-" .. __TS__StringSubstring(numberString, #hexMatch)
1658
1641
  else
1659
- ____TS__Match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1642
+ ____TS__Match_result__0_0 = __TS__StringSubstring(numberString, #hexMatch)
1660
1643
  end
1661
1644
  numberString = ____TS__Match_result__0_0
1662
1645
  end
@@ -1668,7 +1651,7 @@ do
1668
1651
  if base <= 10 then
1669
1652
  ____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, base)
1670
1653
  else
1671
- ____temp_1 = __TS__StringSubstr(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1654
+ ____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1672
1655
  end
1673
1656
  local allowedDigits = ____temp_1
1674
1657
  local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
@@ -2378,6 +2361,22 @@ local function __TS__StringStartsWith(self, searchString, position)
2378
2361
  return string.sub(self, position + 1, #searchString + position) == searchString
2379
2362
  end
2380
2363
 
2364
+ local function __TS__StringSubstr(self, from, length)
2365
+ if from ~= from then
2366
+ from = 0
2367
+ end
2368
+ if length ~= nil then
2369
+ if length ~= length or length <= 0 then
2370
+ return ""
2371
+ end
2372
+ length = length + from
2373
+ end
2374
+ if from >= 0 then
2375
+ from = from + 1
2376
+ end
2377
+ return string.sub(self, from, length)
2378
+ end
2379
+
2381
2380
  local function __TS__StringTrim(self)
2382
2381
  local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
2383
2382
  return result
@@ -82,5 +82,10 @@ export declare class ModUpgradedBase implements Mod {
82
82
  * don't have access to it..
83
83
  */
84
84
  private initOptionalFeature;
85
+ /**
86
+ * This is mostly the same as the `AddCustomCallback` method, but we initialize the custom
87
+ * callback without actually registering a subscription.
88
+ */
89
+ private initCustomCallbackEarly;
85
90
  }
86
91
  //# sourceMappingURL=ModUpgradedBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModUpgradedBase.d.ts","sourceRoot":"","sources":["../../../src/classes/ModUpgradedBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAQ/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAMhG;;;;;;;;;GASG;AACH,qBAAa,eAAgB,YAAW,GAAG;IAKlC,IAAI,EAAE,MAAM,CAAC;IAMpB,4FAA4F;IAC5F,OAAO,CAAC,GAAG,CAAM;IAEjB,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,aAAa,CAAoB;IAEzC,OAAO,CAAC,SAAS,CAAC;IAGlB,OAAO,CAAC,QAAQ,CAAC;gBAML,GAAG,EAAE,GAAG,EAAE,KAAK,E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aAAa;IAwDrB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;CAIhC"}
@@ -259,4 +259,8 @@ function ModUpgradedBase.prototype.initOptionalFeature(self, feature)
259
259
  self:initFeature(featureClass)
260
260
  return getExportedMethodsFromFeature(nil, featureClass)
261
261
  end
262
+ function ModUpgradedBase.prototype.initCustomCallbackEarly(self, modCallbackCustom)
263
+ local callbackClass = self.callbacks[modCallbackCustom]
264
+ self:initFeature(callbackClass)
265
+ end
262
266
  return ____exports
@@ -3,8 +3,8 @@ import { GridEntityCustomData } from "../../../interfaces/GridEntityCustomData";
3
3
  import { Feature } from "../../private/Feature";
4
4
  export declare class CustomGridEntities extends Feature {
5
5
  private runInNFrames;
6
- private postNewRoom;
7
6
  private preUseItemWeNeedToGoDeeper;
7
+ private postNewRoomReordered;
8
8
  /**
9
9
  * Helper function to spawn a custom grid entity. Custom grid entities are persistent in that they
10
10
  * will reappear if the player leaves and re-enters the room. (It will be manually respawned in
@@ -1 +1 @@
1
- {"version":3,"file":"CustomGridEntities.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/callbackLogic/CustomGridEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,cAAc,EAGf,MAAM,8BAA8B,CAAC;AAYtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGhD,qBAAa,kBAAmB,SAAQ,OAAO;IAgB7C,OAAO,CAAC,YAAY,CAAe;IAoBnC,OAAO,CAAC,WAAW,CA4BjB;IAIF,OAAO,CAAC,0BAA0B,CA+ChC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+EG;IAEI,qBAAqB,CAC1B,oBAAoB,EAAE,cAAc,EACpC,mBAAmB,EAAE,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kBAAkB,CAAC,EAAE,kBAAkB,EACvC,QAAQ,CAAC,EAAE,MAAM,EACjB,gBAAgB,CAAC,EAAE,MAAM,EACzB,kBAAkB,iBAA4B,EAC9C,qBAAqB,SAAI,GACxB,UAAU;IA8Cb;;;;;;;;;;;;;;;;;OAiBG;IAEI,sBAAsB,CAC3B,+BAA+B,EAAE,GAAG,GAAG,MAAM,GAAG,UAAU,EAC1D,UAAU,UAAO,GAChB,UAAU,GAAG,SAAS;IAuCzB;;;;;;OAMG;IAEI,qBAAqB,IAAI,KAAK,CACnC;QAAC,UAAU,EAAE,UAAU;QAAE,IAAI,EAAE,oBAAoB;KAAC,CACrD;IAoBD;;;;;;;OAOG;IAEI,uBAAuB,CAC5B,qBAAqB,EAAE,UAAU,GAAG,GAAG,GACtC,cAAc,GAAG,SAAS;IAyB7B;;;;;;OAMG;IAEI,kBAAkB,CAAC,qBAAqB,EAAE,UAAU,GAAG,GAAG,GAAG,OAAO;CAM5E"}
@@ -18,6 +18,8 @@ local ____decorators = require("src.decorators")
18
18
  local Exported = ____decorators.Exported
19
19
  local ____ISCFeature = require("src.enums.ISCFeature")
20
20
  local ISCFeature = ____ISCFeature.ISCFeature
21
+ local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
22
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
21
23
  local ____gridEntities = require("src.functions.gridEntities")
22
24
  local removeGridEntity = ____gridEntities.removeGridEntity
23
25
  local spawnGridEntityWithVariant = ____gridEntities.spawnGridEntityWithVariant
@@ -49,32 +51,6 @@ function CustomGridEntities.prototype.____constructor(self, runInNFrames)
49
51
  manuallyUsingShovel = false
50
52
  }
51
53
  }
52
- self.postNewRoom = function()
53
- local roomListIndex = getRoomListIndex(nil)
54
- local roomCustomGridEntities = self.v.level.customGridEntities:get(roomListIndex)
55
- if roomCustomGridEntities == nil then
56
- return
57
- end
58
- local room = game:GetRoom()
59
- for ____, ____value in __TS__Iterator(roomCustomGridEntities:entries()) do
60
- local gridIndex = ____value[1]
61
- local data = ____value[2]
62
- do
63
- local decoration = room:GetGridEntity(gridIndex)
64
- if decoration == nil then
65
- roomCustomGridEntities:delete(gridIndex)
66
- goto __continue6
67
- end
68
- if data.anm2Path ~= nil then
69
- local sprite = decoration:GetSprite()
70
- sprite:Load(data.anm2Path, true)
71
- local animationToPlay = data.defaultAnimation == nil and sprite:GetDefaultAnimation() or data.defaultAnimation
72
- sprite:Play(animationToPlay, true)
73
- end
74
- end
75
- ::__continue6::
76
- end
77
- end
78
54
  self.preUseItemWeNeedToGoDeeper = function(____, _collectibleType, _rng, player, _useFlags, _activeSlot, _customVarData)
79
55
  local room = game:GetRoom()
80
56
  local roomListIndex = getRoomListIndex(nil)
@@ -103,8 +79,35 @@ function CustomGridEntities.prototype.____constructor(self, runInNFrames)
103
79
  end)
104
80
  return true
105
81
  end
82
+ self.postNewRoomReordered = function()
83
+ local roomListIndex = getRoomListIndex(nil)
84
+ local roomCustomGridEntities = self.v.level.customGridEntities:get(roomListIndex)
85
+ if roomCustomGridEntities == nil then
86
+ return
87
+ end
88
+ local room = game:GetRoom()
89
+ for ____, ____value in __TS__Iterator(roomCustomGridEntities:entries()) do
90
+ local gridIndex = ____value[1]
91
+ local data = ____value[2]
92
+ do
93
+ local decoration = room:GetGridEntity(gridIndex)
94
+ if decoration == nil then
95
+ roomCustomGridEntities:delete(gridIndex)
96
+ goto __continue12
97
+ end
98
+ if data.anm2Path ~= nil then
99
+ local sprite = decoration:GetSprite()
100
+ sprite:Load(data.anm2Path, true)
101
+ local animationToPlay = data.defaultAnimation == nil and sprite:GetDefaultAnimation() or data.defaultAnimation
102
+ sprite:Play(animationToPlay, true)
103
+ end
104
+ end
105
+ ::__continue12::
106
+ end
107
+ end
106
108
  self.featuresUsed = {ISCFeature.RUN_IN_N_FRAMES}
107
- self.callbacksUsed = {{ModCallback.POST_NEW_ROOM, {self.postNewRoom}}, {ModCallback.PRE_USE_ITEM, {self.preUseItemWeNeedToGoDeeper, CollectibleType.WE_NEED_TO_GO_DEEPER}}}
109
+ self.callbacksUsed = {{ModCallback.PRE_USE_ITEM, {self.preUseItemWeNeedToGoDeeper, CollectibleType.WE_NEED_TO_GO_DEEPER}}}
110
+ self.customCallbacksUsed = {{ModCallbackCustom.POST_NEW_ROOM_REORDERED, {self.postNewRoomReordered}}}
108
111
  self.runInNFrames = runInNFrames
109
112
  end
110
113
  function CustomGridEntities.prototype.spawnCustomGridEntity(self, gridEntityTypeCustom, gridIndexOrPosition, gridCollisionClass, anm2Path, defaultAnimation, baseGridEntityType, baseGridEntityVariant)
@@ -27,7 +27,7 @@ export declare class CustomRevive extends Feature {
27
27
  private postRender;
28
28
  private postPEffectUpdate;
29
29
  private checkWaitingForItemAnimation;
30
- private postNewRoom;
30
+ private postNewRoomReordered;
31
31
  private postPlayerFatalDamage;
32
32
  private preBerserkDeath;
33
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CustomRevive.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/callbackLogic/CustomRevive.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD,aAAK,iBAAiB;IACpB,QAAQ,IAAA;IAER;;;OAGG;IACH,2BAA2B,IAAA;IAE3B,0BAA0B,IAAA;CAC3B;AAED,qBAAa,YAAa,SAAQ,OAAO;IACvB,CAAC;;;;;;MAMf;IAEF,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAe;gBAGjC,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAA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-53,7 +53,7 @@ function CustomRevive.prototype.____constructor(self, preCustomRevive, postCusto
53
53
  self.postPEffectUpdate = function(____, player)
54
54
  self:checkWaitingForItemAnimation(player)
55
55
  end
56
- self.postNewRoom = function()
56
+ self.postNewRoomReordered = function()
57
57
  if self.v.run.state ~= CustomReviveState.WAITING_FOR_ROOM_TRANSITION then
58
58
  return
59
59
  end
@@ -68,8 +68,8 @@ function CustomRevive.prototype.____constructor(self, preCustomRevive, postCusto
68
68
  self:playerIsAboutToDie(player)
69
69
  end
70
70
  self.featuresUsed = {ISCFeature.RUN_IN_N_FRAMES}
71
- self.callbacksUsed = {{ModCallback.POST_RENDER, {self.postRender}}, {ModCallback.POST_PEFFECT_UPDATE, {self.postPEffectUpdate}}, {ModCallback.POST_NEW_ROOM, {self.postNewRoom}}}
72
- self.customCallbacksUsed = {{ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE, {self.postPlayerFatalDamage}}, {ModCallbackCustom.PRE_BERSERK_DEATH, {self.preBerserkDeath}}}
71
+ self.callbacksUsed = {{ModCallback.POST_RENDER, {self.postRender}}, {ModCallback.POST_PEFFECT_UPDATE, {self.postPEffectUpdate}}}
72
+ self.customCallbacksUsed = {{ModCallbackCustom.POST_NEW_ROOM_REORDERED, {self.postNewRoomReordered}}, {ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE, {self.postPlayerFatalDamage}}, {ModCallbackCustom.PRE_BERSERK_DEATH, {self.preBerserkDeath}}}
73
73
  self.preCustomRevive = preCustomRevive
74
74
  self.postCustomRevive = postCustomRevive
75
75
  self.runInNFrames = runInNFrames
@@ -40,7 +40,7 @@ export declare class GridEntityUpdateDetection extends Feature {
40
40
  private checkGridEntityStateChanged;
41
41
  private checkNewGridEntity;
42
42
  private updateTupleInMap;
43
- private postNewRoom;
43
+ private postNewRoomReordered;
44
44
  }
45
45
  export {};
46
46
  //# sourceMappingURL=GridEntityUpdateDetection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GridEntityUpdate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3E,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,0BAA0B,CAA6B;IAC/D,OAAO,CAAC,kBAAkB,CAAqB;gBAG7C,kBAAkB,EAAE,kBAAkB,EACtC,wBAAwB,EAAE,wBAAwB,EAClD,oBAAoB,EAAE,oBAAoB,EAC1C,0BAA0B,EAAE,0BAA0B,EACtD,oBAAoB,EAAE,oBAAoB,EAC1C,0BAA0B,EAAE,0BAA0B,EACtD,0BAA0B,EAAE,0BAA0B,EACtD,gCAAgC,EAAE,gCAAgC,EAClE,oBAAoB,EAAE,oBAAoB,EAC1C,0BAA0B,EAAE,0BAA0B,EACtD,kBAAkB,EAAE,kBAAkB;IAyBxC,OAAO,CAAC,UAAU,CAmBhB;IAEF,OAAO,CAAC,wBAAwB;IA8BhC,OAAO,CAAC,2BAA2B;IA0CnC,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,WAAW,CAMjB;CACH"}
1
+ {"version":3,"file":"GridEntityUpdateDetection.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/callbackLogic/GridEntityUpdateDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAe,MAAM,8BAA8B,CAAC;AAO3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,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AAoB,CAM1B;CACH"}
@@ -9,6 +9,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
9
9
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
10
10
  local ____ISCFeature = require("src.enums.ISCFeature")
11
11
  local ISCFeature = ____ISCFeature.ISCFeature
12
+ local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
13
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
12
14
  local ____gridEntities = require("src.functions.gridEntities")
13
15
  local getGridEntitiesMap = ____gridEntities.getGridEntitiesMap
14
16
  local isGridEntityBroken = ____gridEntities.isGridEntityBroken
@@ -37,7 +39,7 @@ function GridEntityUpdateDetection.prototype.____constructor(self, postGridEntit
37
39
  end
38
40
  end
39
41
  end
40
- self.postNewRoom = function()
42
+ self.postNewRoomReordered = function()
41
43
  local gridEntitiesMap = getGridEntitiesMap(nil)
42
44
  for ____, ____value in __TS__Iterator(gridEntitiesMap:entries()) do
43
45
  local gridIndex = ____value[1]
@@ -46,7 +48,8 @@ function GridEntityUpdateDetection.prototype.____constructor(self, postGridEntit
46
48
  end
47
49
  end
48
50
  self.featuresUsed = {ISCFeature.RUN_IN_N_FRAMES}
49
- self.callbacksUsed = {{ModCallback.POST_UPDATE, {self.postUpdate}}, {ModCallback.POST_NEW_ROOM, {self.postNewRoom}}}
51
+ self.callbacksUsed = {{ModCallback.POST_UPDATE, {self.postUpdate}}}
52
+ self.customCallbacksUsed = {{ModCallbackCustom.POST_NEW_ROOM_REORDERED, {self.postNewRoomReordered}}}
50
53
  self.postGridEntityInit = postGridEntityInit
51
54
  self.postGridEntityCustomInit = postGridEntityCustomInit
52
55
  self.postGridEntityUpdate = postGridEntityUpdate
@@ -1,6 +1,7 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
3
  import { ISCFeature } from "../enums/ISCFeature";
4
+ import { ModCallbackCustom } from "../enums/ModCallbackCustom";
4
5
  import { ModUpgraded } from "../types/ModUpgraded";
5
6
  type ISCFeatureTuple<T extends readonly ISCFeature[]> = ISCFeature extends T["length"] ? 'The list of features must be a tuple. Use the "as const" assertion when declaring the array.' : T;
6
7
  /**
@@ -23,6 +24,14 @@ type ISCFeatureTuple<T extends readonly ISCFeature[]> = ISCFeature extends T["le
23
24
  * @param modVanilla The mod object returned by the `RegisterMod` function.
24
25
  * @param features Optional. An array containing the optional standard library features that you
25
26
  * want to enable, if any. Default is an empty array.
27
+ * @param customCallbacksUsed Optional. An array containing the custom callbacks that you will be
28
+ * subscribing to after you upgrade your mod. Specifying this will
29
+ * immediately initialize the callbacks (as opposed to lazy-initializing
30
+ * them when you first subscribe to the callback). This is only necessary
31
+ * if you the order of callback firing is important for your mod. (For
32
+ * example, you may want the `POST_NEW_ROOM` part of the
33
+ * `POST_GRID_ENTITY_INIT` callback to fire before your own
34
+ * `POST_NEW_ROOM` callbacks.)
26
35
  * @param debug Optional. Whether to log additional output when a callback is fired. Default is
27
36
  * false.
28
37
  * @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
@@ -30,6 +39,6 @@ type ISCFeatureTuple<T extends readonly ISCFeature[]> = ISCFeature extends T["le
30
39
  * or milliseconds (if the "--luadebug" launch flag is turned off).
31
40
  * @returns The upgraded mod object.
32
41
  */
33
- export declare function upgradeMod<T extends readonly ISCFeature[] = never[]>(modVanilla: Mod, features?: ISCFeatureTuple<T>, debug?: boolean, timeThreshold?: float): ModUpgraded<T>;
42
+ export declare function upgradeMod<T extends readonly ISCFeature[] = never[]>(modVanilla: Mod, features?: ISCFeatureTuple<T>, customCallbacksUsed?: ModCallbackCustom[] | readonly ModCallbackCustom[], debug?: boolean, timeThreshold?: float): ModUpgraded<T>;
34
43
  export {};
35
44
  //# sourceMappingURL=upgradeMod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upgradeMod.d.ts","sourceRoot":"","sources":["../../../src/core/upgradeMod.ts"],"names":[],"mappings":";;AACA,OAA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
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__New = ____lualib.__TS__New
3
3
  local ____exports = {}
4
- local initOptionalFeatures
4
+ local initOptionalFeatures, initCallbacksEarly
5
5
  local ____ModUpgradedBase = require("src.classes.ModUpgradedBase")
6
6
  local ModUpgradedBase = ____ModUpgradedBase.ModUpgradedBase
7
7
  local ____patchErrorFunctions = require("src.patchErrorFunctions")
@@ -19,6 +19,11 @@ function initOptionalFeatures(self, mod, features)
19
19
  end
20
20
  end
21
21
  end
22
+ function initCallbacksEarly(self, mod, callbacks)
23
+ for ____, modCallbackCustom in ipairs(callbacks) do
24
+ mod.initCustomCallbackEarly(mod, modCallbackCustom)
25
+ end
26
+ end
22
27
  --- Use this function to enable the custom callbacks and other optional features provided by
23
28
  -- `isaacscript-common`.
24
29
  --
@@ -38,16 +43,27 @@ end
38
43
  -- @param modVanilla The mod object returned by the `RegisterMod` function.
39
44
  -- @param features Optional. An array containing the optional standard library features that you
40
45
  -- want to enable, if any. Default is an empty array.
46
+ -- @param customCallbacksUsed Optional. An array containing the custom callbacks that you will be
47
+ -- subscribing to after you upgrade your mod. Specifying this will
48
+ -- immediately initialize the callbacks (as opposed to lazy-initializing
49
+ -- them when you first subscribe to the callback). This is only necessary
50
+ -- if you the order of callback firing is important for your mod. (For
51
+ -- example, you may want the `POST_NEW_ROOM` part of the
52
+ -- `POST_GRID_ENTITY_INIT` callback to fire before your own
53
+ -- `POST_NEW_ROOM` callbacks.)
41
54
  -- @param debug Optional. Whether to log additional output when a callback is fired. Default is
42
55
  -- false.
43
56
  -- @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
44
57
  -- specified number of seconds (if the "--luadebug" launch flag is turned on)
45
58
  -- or milliseconds (if the "--luadebug" launch flag is turned off).
46
59
  -- @returns The upgraded mod object.
47
- function ____exports.upgradeMod(self, modVanilla, features, ____debug, timeThreshold)
60
+ function ____exports.upgradeMod(self, modVanilla, features, customCallbacksUsed, ____debug, timeThreshold)
48
61
  if features == nil then
49
62
  features = {}
50
63
  end
64
+ if customCallbacksUsed == nil then
65
+ customCallbacksUsed = {}
66
+ end
51
67
  if ____debug == nil then
52
68
  ____debug = false
53
69
  end
@@ -55,6 +71,7 @@ function ____exports.upgradeMod(self, modVanilla, features, ____debug, timeThres
55
71
  local mod = __TS__New(ModUpgradedBase, modVanilla, ____debug, timeThreshold)
56
72
  applyShaderCrashFix(nil, mod)
57
73
  initOptionalFeatures(nil, mod, features)
74
+ initCallbacksEarly(nil, mod, customCallbacksUsed)
58
75
  return mod
59
76
  end
60
77
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "15.6.2",
3
+ "version": "16.0.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -375,6 +375,15 @@ export class ModUpgradedBase implements Mod {
375
375
 
376
376
  return getExportedMethodsFromFeature(featureClass);
377
377
  }
378
+
379
+ /**
380
+ * This is mostly the same as the `AddCustomCallback` method, but we initialize the custom
381
+ * callback without actually registering a subscription.
382
+ */
383
+ private initCustomCallbackEarly(modCallbackCustom: ModCallbackCustom) {
384
+ const callbackClass = this.callbacks[modCallbackCustom];
385
+ this.initFeature(callbackClass);
386
+ }
378
387
  }
379
388
 
380
389
  /**
@@ -9,6 +9,7 @@ import {
9
9
  import { game } from "../../../core/cachedClasses";
10
10
  import { Exported } from "../../../decorators";
11
11
  import { ISCFeature } from "../../../enums/ISCFeature";
12
+ import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
12
13
  import {
13
14
  removeGridEntity,
14
15
  spawnGridEntityWithVariant,
@@ -47,47 +48,19 @@ export class CustomGridEntities extends Feature {
47
48
  this.featuresUsed = [ISCFeature.RUN_IN_N_FRAMES];
48
49
 
49
50
  this.callbacksUsed = [
50
- [ModCallback.POST_NEW_ROOM, [this.postNewRoom]], // 19
51
51
  [
52
52
  ModCallback.PRE_USE_ITEM,
53
53
  [this.preUseItemWeNeedToGoDeeper, CollectibleType.WE_NEED_TO_GO_DEEPER],
54
54
  ], // 23
55
55
  ];
56
56
 
57
+ this.customCallbacksUsed = [
58
+ [ModCallbackCustom.POST_NEW_ROOM_REORDERED, [this.postNewRoomReordered]],
59
+ ];
60
+
57
61
  this.runInNFrames = runInNFrames;
58
62
  }
59
63
 
60
- // ModCallback.POST_NEW_ROOM (19)
61
- private postNewRoom = (): void => {
62
- // When we re-enter a room, the graphics for any custom entities will be reverted back to that
63
- // of a normal decoration. Thus, we must re-apply the anm2.
64
- const roomListIndex = getRoomListIndex();
65
- const roomCustomGridEntities =
66
- this.v.level.customGridEntities.get(roomListIndex);
67
- if (roomCustomGridEntities === undefined) {
68
- return;
69
- }
70
-
71
- const room = game.GetRoom();
72
- for (const [gridIndex, data] of roomCustomGridEntities.entries()) {
73
- const decoration = room.GetGridEntity(gridIndex);
74
- if (decoration === undefined) {
75
- roomCustomGridEntities.delete(gridIndex);
76
- continue;
77
- }
78
-
79
- if (data.anm2Path !== undefined) {
80
- const sprite = decoration.GetSprite();
81
- sprite.Load(data.anm2Path, true);
82
- const animationToPlay =
83
- data.defaultAnimation === undefined
84
- ? sprite.GetDefaultAnimation()
85
- : data.defaultAnimation;
86
- sprite.Play(animationToPlay, true);
87
- }
88
- }
89
- };
90
-
91
64
  // ModCallback.PRE_USE_ITEM (23)
92
65
  // CollectibleType.WE_NEED_TO_GO_DEEPER (84)
93
66
  private preUseItemWeNeedToGoDeeper = (
@@ -139,6 +112,37 @@ export class CustomGridEntities extends Feature {
139
112
  return true;
140
113
  };
141
114
 
115
+ // ModCallbackCustom.POST_NEW_ROOM_REORDERED
116
+ private postNewRoomReordered = (): void => {
117
+ // When we re-enter a room, the graphics for any custom entities will be reverted back to that
118
+ // of a normal decoration. Thus, we must re-apply the anm2.
119
+ const roomListIndex = getRoomListIndex();
120
+ const roomCustomGridEntities =
121
+ this.v.level.customGridEntities.get(roomListIndex);
122
+ if (roomCustomGridEntities === undefined) {
123
+ return;
124
+ }
125
+
126
+ const room = game.GetRoom();
127
+ for (const [gridIndex, data] of roomCustomGridEntities.entries()) {
128
+ const decoration = room.GetGridEntity(gridIndex);
129
+ if (decoration === undefined) {
130
+ roomCustomGridEntities.delete(gridIndex);
131
+ continue;
132
+ }
133
+
134
+ if (data.anm2Path !== undefined) {
135
+ const sprite = decoration.GetSprite();
136
+ sprite.Load(data.anm2Path, true);
137
+ const animationToPlay =
138
+ data.defaultAnimation === undefined
139
+ ? sprite.GetDefaultAnimation()
140
+ : data.defaultAnimation;
141
+ sprite.Play(animationToPlay, true);
142
+ }
143
+ }
144
+ };
145
+
142
146
  /**
143
147
  * Helper function to spawn a custom grid entity. Custom grid entities are persistent in that they
144
148
  * will reappear if the player leaves and re-enters the room. (It will be manually respawned in
@@ -62,10 +62,10 @@ export class CustomRevive extends Feature {
62
62
  this.callbacksUsed = [
63
63
  [ModCallback.POST_RENDER, [this.postRender]], // 2
64
64
  [ModCallback.POST_PEFFECT_UPDATE, [this.postPEffectUpdate]], // 4
65
- [ModCallback.POST_NEW_ROOM, [this.postNewRoom]], // 19
66
65
  ];
67
66
 
68
67
  this.customCallbacksUsed = [
68
+ [ModCallbackCustom.POST_NEW_ROOM_REORDERED, [this.postNewRoomReordered]],
69
69
  [
70
70
  ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE,
71
71
  [this.postPlayerFatalDamage],
@@ -138,8 +138,8 @@ export class CustomRevive extends Feature {
138
138
  this.logStateChanged();
139
139
  }
140
140
 
141
- // ModCallback.POST_NEW_ROOM (19)
142
- private postNewRoom = (): void => {
141
+ // ModCallbackCustom.POST_NEW_ROOM_REORDERED
142
+ private postNewRoomReordered = (): void => {
143
143
  if (this.v.run.state !== CustomReviveState.WAITING_FOR_ROOM_TRANSITION) {
144
144
  return;
145
145
  }
@@ -1,5 +1,6 @@
1
1
  import { GridEntityType, ModCallback } from "isaac-typescript-definitions";
2
2
  import { ISCFeature } from "../../../enums/ISCFeature";
3
+ import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
3
4
  import {
4
5
  getGridEntitiesMap,
5
6
  isGridEntityBroken,
@@ -62,7 +63,10 @@ export class GridEntityUpdateDetection extends Feature {
62
63
 
63
64
  this.callbacksUsed = [
64
65
  [ModCallback.POST_UPDATE, [this.postUpdate]], // 1
65
- [ModCallback.POST_NEW_ROOM, [this.postNewRoom]], // 19
66
+ ];
67
+
68
+ this.customCallbacksUsed = [
69
+ [ModCallbackCustom.POST_NEW_ROOM_REORDERED, [this.postNewRoomReordered]],
66
70
  ];
67
71
 
68
72
  this.postGridEntityInit = postGridEntityInit;
@@ -204,8 +208,8 @@ export class GridEntityUpdateDetection extends Feature {
204
208
  this.v.room.initializedGridEntities.set(gridIndex, newTuple);
205
209
  }
206
210
 
207
- // ModCallback.POST_NEW_ROOM (19)
208
- private postNewRoom = (): void => {
211
+ // ModCallbackCustom.POST_NEW_ROOM_REORDERED
212
+ private postNewRoomReordered = (): void => {
209
213
  const gridEntitiesMap = getGridEntitiesMap();
210
214
 
211
215
  for (const [gridIndex, gridEntity] of gridEntitiesMap.entries()) {
@@ -1,5 +1,6 @@
1
1
  import { ModUpgradedBase } from "../classes/ModUpgradedBase";
2
2
  import { ISCFeature } from "../enums/ISCFeature";
3
+ import { ModCallbackCustom } from "../enums/ModCallbackCustom";
3
4
  import { patchErrorFunction } from "../patchErrorFunctions";
4
5
  import { applyShaderCrashFix } from "../shaderCrashFix";
5
6
  import { AnyFunction } from "../types/AnyFunction";
@@ -30,6 +31,14 @@ type ISCFeatureTuple<T extends readonly ISCFeature[]> =
30
31
  * @param modVanilla The mod object returned by the `RegisterMod` function.
31
32
  * @param features Optional. An array containing the optional standard library features that you
32
33
  * want to enable, if any. Default is an empty array.
34
+ * @param customCallbacksUsed Optional. An array containing the custom callbacks that you will be
35
+ * subscribing to after you upgrade your mod. Specifying this will
36
+ * immediately initialize the callbacks (as opposed to lazy-initializing
37
+ * them when you first subscribe to the callback). This is only necessary
38
+ * if you the order of callback firing is important for your mod. (For
39
+ * example, you may want the `POST_NEW_ROOM` part of the
40
+ * `POST_GRID_ENTITY_INIT` callback to fire before your own
41
+ * `POST_NEW_ROOM` callbacks.)
33
42
  * @param debug Optional. Whether to log additional output when a callback is fired. Default is
34
43
  * false.
35
44
  * @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
@@ -40,6 +49,7 @@ type ISCFeatureTuple<T extends readonly ISCFeature[]> =
40
49
  export function upgradeMod<T extends readonly ISCFeature[] = never[]>(
41
50
  modVanilla: Mod,
42
51
  features: ISCFeatureTuple<T> = [] as unknown as ISCFeatureTuple<T>,
52
+ customCallbacksUsed: ModCallbackCustom[] | readonly ModCallbackCustom[] = [],
43
53
  debug = false,
44
54
  timeThreshold?: float,
45
55
  ): ModUpgraded<T> {
@@ -48,6 +58,7 @@ export function upgradeMod<T extends readonly ISCFeature[] = never[]>(
48
58
  const mod = new ModUpgradedBase(modVanilla, debug, timeThreshold);
49
59
  applyShaderCrashFix(mod);
50
60
  initOptionalFeatures(mod, features as ISCFeature[]);
61
+ initCallbacksEarly(mod, customCallbacksUsed);
51
62
 
52
63
  return mod as ModUpgraded<T>;
53
64
  }
@@ -68,3 +79,15 @@ function initOptionalFeatures(mod: ModUpgradedBase, features: ISCFeature[]) {
68
79
  }
69
80
  }
70
81
  }
82
+
83
+ function initCallbacksEarly(
84
+ mod: ModUpgradedBase,
85
+ callbacks: ModCallbackCustom[] | readonly ModCallbackCustom[],
86
+ ) {
87
+ for (const modCallbackCustom of callbacks) {
88
+ // We intentionally access the private method here, so we use the string index escape hatch:
89
+ // https://github.com/microsoft/TypeScript/issues/19335
90
+ // eslint-disable-next-line @typescript-eslint/dot-notation
91
+ mod["initCustomCallbackEarly"](modCallbackCustom);
92
+ }
93
+ }