isaacscript-common 1.2.126 → 1.2.129

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.
Files changed (48) hide show
  1. package/dist/cachedClasses.d.ts +37 -0
  2. package/dist/cachedClasses.lua +7 -0
  3. package/dist/callbacks/customRevive.lua +3 -2
  4. package/dist/callbacks/postCursedTeleport.lua +2 -5
  5. package/dist/callbacks/postEsauJr.lua +2 -2
  6. package/dist/callbacks/postNewRoomEarly.lua +2 -1
  7. package/dist/callbacks/postPlayerFatalDamage.lua +6 -6
  8. package/dist/callbacks/postSacrifice.lua +2 -1
  9. package/dist/callbacks/reorderedCallbacks.lua +2 -3
  10. package/dist/features/deployJSONRoom.lua +2 -8
  11. package/dist/features/disableSound.lua +2 -2
  12. package/dist/features/getCollectibleItemPoolType.lua +2 -1
  13. package/dist/features/runInNFrames.lua +2 -2
  14. package/dist/features/saveDataManager/main.lua +2 -1
  15. package/dist/functions/cards.d.ts +6 -0
  16. package/dist/functions/cards.lua +2 -3
  17. package/dist/functions/charge.lua +5 -5
  18. package/dist/functions/collectibleSet.lua +2 -1
  19. package/dist/functions/collectibles.d.ts +6 -0
  20. package/dist/functions/collectibles.lua +2 -11
  21. package/dist/functions/doors.lua +2 -3
  22. package/dist/functions/entity.lua +2 -1
  23. package/dist/functions/familiars.lua +2 -1
  24. package/dist/functions/gridEntity.lua +2 -8
  25. package/dist/functions/log.lua +2 -2
  26. package/dist/functions/map.d.ts +8 -2
  27. package/dist/functions/map.lua +9 -0
  28. package/dist/functions/pills.d.ts +4 -0
  29. package/dist/functions/pills.lua +2 -2
  30. package/dist/functions/player.lua +3 -8
  31. package/dist/functions/positionVelocity.lua +2 -1
  32. package/dist/functions/random.d.ts +4 -3
  33. package/dist/functions/revive.d.ts +1 -1
  34. package/dist/functions/revive.lua +2 -2
  35. package/dist/functions/rooms.d.ts +3 -2
  36. package/dist/functions/rooms.lua +4 -23
  37. package/dist/functions/seeds.lua +2 -1
  38. package/dist/functions/sound.lua +2 -1
  39. package/dist/functions/spawnCollectible.lua +2 -1
  40. package/dist/functions/stage.lua +2 -9
  41. package/dist/functions/trinketSet.lua +2 -1
  42. package/dist/functions/trinkets.d.ts +4 -0
  43. package/dist/functions/trinkets.lua +2 -4
  44. package/dist/functions/ui.lua +2 -1
  45. package/dist/functions/utils.lua +2 -1
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.lua +8 -0
  48. package/package.json +1 -1
@@ -0,0 +1,37 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * A cached version of the `Game()` constructor.
4
+ *
5
+ * Use this instead of invoking the constructor again for a miniscule performance increase.
6
+ *
7
+ * Caching the results of a this constructor is safe, but caching other classes (like `Level` or
8
+ * `Room`) is not safe and can lead to the game crashing in certain situations.
9
+ */
10
+ export declare const game: Game;
11
+ /**
12
+ * A cached version of the `Isaac.GetItemConfig()()` constructor.
13
+ *
14
+ * Use this instead of invoking the constructor again for a miniscule performance increase.
15
+ *
16
+ * Caching the results of a this constructor is safe, but caching other classes (like `Level` or
17
+ * `Room`) is not safe and can lead to the game crashing in certain situations.
18
+ */
19
+ export declare const itemConfig: ItemConfig;
20
+ /**
21
+ * A cached version of the `MusicManager()` constructor.
22
+ *
23
+ * Use this instead of invoking the constructor again for a miniscule performance increase.
24
+ *
25
+ * Caching the results of a this constructor is safe, but caching other classes (like `Level` or
26
+ * `Room`) is not safe and can lead to the game crashing in certain situations.
27
+ */
28
+ export declare const musicManager: MusicManager;
29
+ /**
30
+ * A cached version of the `SFXManager()` constructor.
31
+ *
32
+ * Use this instead of invoking the constructor again for a miniscule performance increase.
33
+ *
34
+ * Caching the results of a this constructor is safe, but caching other classes (like `Level` or
35
+ * `Room`) is not safe and can lead to the game crashing in certain situations.
36
+ */
37
+ export declare const sfxManager: SFXManager;
@@ -0,0 +1,7 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ ____exports.game = Game()
4
+ ____exports.itemConfig = Isaac.GetItemConfig()
5
+ ____exports.musicManager = MusicManager()
6
+ ____exports.sfxManager = SFXManager()
7
+ return ____exports
@@ -1,6 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local hasSubscriptions, postRender, postPEffectUpdateReordered, checkWaitingForItemAnimation, postPlayerFatalDamage, preBerserkDeath, playerIsAboutToDie, CustomReviveState, v
4
+ local ____cachedClasses = require("cachedClasses")
5
+ local sfxManager = ____cachedClasses.sfxManager
4
6
  local ____exports = require("features.saveDataManager.exports")
5
7
  local saveDataManager = ____exports.saveDataManager
6
8
  local ____collectibles = require("functions.collectibles")
@@ -24,8 +26,7 @@ function postRender(self)
24
26
  if v.run.state ~= CustomReviveState.WAITING_FOR_ITEM_ANIMATION then
25
27
  return
26
28
  end
27
- local sfx = SFXManager()
28
- sfx:Stop(SoundEffect.SOUND_1UP)
29
+ sfxManager:Stop(SoundEffect.SOUND_1UP)
29
30
  end
30
31
  function postPEffectUpdateReordered(self, player)
31
32
  checkWaitingForItemAnimation(nil, player)
@@ -4,6 +4,8 @@ local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
6
  local hasSubscriptions, entityTakeDmgPlayer, setDamageFrame, isPotentialNaturalTeleportFromSacrificeRoom, incrementNumSacrifices, postPlayerRenderPlayer, playerIsTeleportingFromCursedTeleport, v
7
+ local ____cachedClasses = require("cachedClasses")
8
+ local game = ____cachedClasses.game
7
9
  local ____exports = require("features.saveDataManager.exports")
8
10
  local saveDataManager = ____exports.saveDataManager
9
11
  local ____flag = require("functions.flag")
@@ -27,7 +29,6 @@ function entityTakeDmgPlayer(self, tookDamage, _damageAmount, damageFlags, _dama
27
29
  setDamageFrame(nil, tookDamage, damageFlags)
28
30
  end
29
31
  function setDamageFrame(self, tookDamage, damageFlags)
30
- local game = Game()
31
32
  local gameFrameCount = game:GetFrameCount()
32
33
  local player = tookDamage:ToPlayer()
33
34
  if player == nil then
@@ -47,14 +48,12 @@ function setDamageFrame(self, tookDamage, damageFlags)
47
48
  mapSetPlayer(nil, v.run.playersDamageFrameMap, player, newTrackingArray)
48
49
  end
49
50
  function isPotentialNaturalTeleportFromSacrificeRoom(self, damageFlags)
50
- local game = Game()
51
51
  local room = game:GetRoom()
52
52
  local roomType = room:GetType()
53
53
  local isSpikeDamage = hasFlag(nil, damageFlags, DamageFlag.DAMAGE_SPIKES)
54
54
  return roomType == RoomType.ROOM_SACRIFICE and isSpikeDamage and (v.level.numSacrifices == 6 or v.level.numSacrifices >= 12)
55
55
  end
56
56
  function incrementNumSacrifices(self, damageFlags)
57
- local game = Game()
58
57
  local room = game:GetRoom()
59
58
  local roomType = room:GetType()
60
59
  local isSpikeDamage = hasFlag(nil, damageFlags, DamageFlag.DAMAGE_SPIKES)
@@ -78,14 +77,12 @@ function postPlayerRenderPlayer(self, player)
78
77
  if callbackActivatedOnThisFrame then
79
78
  return
80
79
  end
81
- local game = Game()
82
80
  local gameFrameCount = game:GetFrameCount()
83
81
  local newTrackingArray = {gameFrameCount, true}
84
82
  mapSetPlayer(nil, v.run.playersDamageFrameMap, player, newTrackingArray)
85
83
  postCursedTeleportFire(nil, player)
86
84
  end
87
85
  function playerIsTeleportingFromCursedTeleport(self, player, lastDamageFrame)
88
- local game = Game()
89
86
  local gameFrameCount = game:GetFrameCount()
90
87
  if gameFrameCount ~= lastDamageFrame then
91
88
  return false
@@ -3,6 +3,8 @@ local ____lualib = require("lualib_bundle")
3
3
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
4
4
  local ____exports = {}
5
5
  local hasSubscriptions, postUpdate, getPlayerWithControllerIndex, useItemEsauJr, v
6
+ local ____cachedClasses = require("cachedClasses")
7
+ local game = ____cachedClasses.game
6
8
  local ____exports = require("features.saveDataManager.exports")
7
9
  local saveDataManager = ____exports.saveDataManager
8
10
  local ____player = require("functions.player")
@@ -20,7 +22,6 @@ function postUpdate(self)
20
22
  if not hasSubscriptions(nil) then
21
23
  return
22
24
  end
23
- local game = Game()
24
25
  local gameFrameCount = game:GetFrameCount()
25
26
  if v.run.usedEsauJrFrame == nil or gameFrameCount < v.run.usedEsauJrFrame + 1 then
26
27
  return
@@ -51,7 +52,6 @@ function useItemEsauJr(self, _collectibleType, _rng, player, _useFlags, _activeS
51
52
  if not hasSubscriptions(nil) then
52
53
  return
53
54
  end
54
- local game = Game()
55
55
  local gameFrameCount = game:GetFrameCount()
56
56
  v.run.usedEsauJrFrame = gameFrameCount + 1
57
57
  v.run.usedEsauJrControllerIndex = player.ControllerIndex
@@ -1,6 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local hasSubscriptions, postNewRoom, preEntitySpawn, checkRoomChanged, currentRoomTopLeftWallPtrHash
4
+ local ____cachedClasses = require("cachedClasses")
5
+ local game = ____cachedClasses.game
4
6
  local ____gridEntity = require("functions.gridEntity")
5
7
  local getTopLeftWallGridIndex = ____gridEntity.getTopLeftWallGridIndex
6
8
  local spawnGridEntity = ____gridEntity.spawnGridEntity
@@ -23,7 +25,6 @@ function preEntitySpawn(self)
23
25
  checkRoomChanged(nil)
24
26
  end
25
27
  function checkRoomChanged(self)
26
- local game = Game()
27
28
  local room = game:GetRoom()
28
29
  local topLeftWallGridIndex = getTopLeftWallGridIndex(nil)
29
30
  local topLeftWall = room:GetGridEntity(topLeftWallGridIndex)
@@ -1,20 +1,21 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
+ local Map = ____lualib.Map
3
4
  local __TS__New = ____lualib.__TS__New
4
5
  local ____exports = {}
5
6
  local hasSubscriptions, entityTakeDmgPlayer, v
7
+ local ____cachedClasses = require("cachedClasses")
8
+ local game = ____cachedClasses.game
6
9
  local ____exports = require("features.saveDataManager.exports")
7
10
  local saveDataManager = ____exports.saveDataManager
8
11
  local ____player = require("functions.player")
9
12
  local isChildPlayer = ____player.isChildPlayer
10
13
  local ____playerDataStructures = require("functions.playerDataStructures")
11
- local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
14
+ local mapGetPlayer = ____playerDataStructures.mapGetPlayer
12
15
  local mapSetPlayer = ____playerDataStructures.mapSetPlayer
13
16
  local ____revive = require("functions.revive")
14
17
  local isDamageToPlayerFatal = ____revive.isDamageToPlayerFatal
15
18
  local willPlayerRevive = ____revive.willPlayerRevive
16
- local ____DefaultMap = require("types.DefaultMap")
17
- local DefaultMap = ____DefaultMap.DefaultMap
18
19
  local ____postPlayerFatalDamage = require("callbacks.subscriptions.postPlayerFatalDamage")
19
20
  local postPlayerFatalDamageFire = ____postPlayerFatalDamage.postPlayerFatalDamageFire
20
21
  local postPlayerFatalDamageHasSubscriptions = ____postPlayerFatalDamage.postPlayerFatalDamageHasSubscriptions
@@ -32,9 +33,8 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
32
33
  if isChildPlayer(nil, player) then
33
34
  return nil
34
35
  end
35
- local game = Game()
36
36
  local gameFrameCount = game:GetFrameCount()
37
- local lastDamageGameFrame = defaultMapGetPlayer(nil, v.run.playersLastDamageGameFrame, player)
37
+ local lastDamageGameFrame = mapGetPlayer(nil, v.run.playersLastDamageGameFrame, player)
38
38
  mapSetPlayer(nil, v.run.playersLastDamageGameFrame, player, gameFrameCount)
39
39
  if willPlayerRevive(nil, player) then
40
40
  return nil
@@ -61,7 +61,7 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
61
61
  end
62
62
  return nil
63
63
  end
64
- v = {run = {playersLastDamageGameFrame = __TS__New(DefaultMap, nil)}}
64
+ v = {run = {playersLastDamageGameFrame = __TS__New(Map)}}
65
65
  function ____exports.postPlayerFatalDamageCallbackInit(self, mod)
66
66
  saveDataManager(nil, "postPlayerFatalDamage", v)
67
67
  mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, entityTakeDmgPlayer, EntityType.ENTITY_PLAYER)
@@ -1,6 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local hasSubscriptions, entityTakeDmgPlayer, v
4
+ local ____cachedClasses = require("cachedClasses")
5
+ local game = ____cachedClasses.game
4
6
  local ____exports = require("features.saveDataManager.exports")
5
7
  local saveDataManager = ____exports.saveDataManager
6
8
  local ____flag = require("functions.flag")
@@ -19,7 +21,6 @@ function entityTakeDmgPlayer(self, tookDamage, _damageAmount, damageFlags, _dama
19
21
  if player == nil then
20
22
  return
21
23
  end
22
- local game = Game()
23
24
  local room = game:GetRoom()
24
25
  local roomType = room:GetType()
25
26
  local isSpikeDamage = hasFlag(nil, damageFlags, DamageFlag.DAMAGE_SPIKES)
@@ -1,6 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local hasSubscriptions, useItemGlowingHourGlass, postGameStartedVanilla, postNewLevelVanilla, postNewRoomVanilla, recordCurrentStage, currentStage, currentStageType, usedGlowingHourGlass, forceNewLevel, forceNewRoom
4
+ local ____cachedClasses = require("cachedClasses")
5
+ local game = ____cachedClasses.game
4
6
  local ____postGameStartedReordered = require("callbacks.subscriptions.postGameStartedReordered")
5
7
  local postGameStartedReorderedFire = ____postGameStartedReordered.postGameStartedReorderedFire
6
8
  local postGameStartedReorderedHasSubscriptions = ____postGameStartedReordered.postGameStartedReorderedHasSubscriptions
@@ -29,7 +31,6 @@ function postNewLevelVanilla(self)
29
31
  if not hasSubscriptions(nil) then
30
32
  return
31
33
  end
32
- local game = Game()
33
34
  local gameFrameCount = game:GetFrameCount()
34
35
  if gameFrameCount == 0 and not forceNewLevel then
35
36
  return
@@ -43,7 +44,6 @@ function postNewRoomVanilla(self)
43
44
  if not hasSubscriptions(nil) then
44
45
  return
45
46
  end
46
- local game = Game()
47
47
  local gameFrameCount = game:GetFrameCount()
48
48
  local level = game:GetLevel()
49
49
  local stage = level:GetStage()
@@ -64,7 +64,6 @@ function postNewRoomVanilla(self)
64
64
  postNewRoomReorderedFire(nil)
65
65
  end
66
66
  function recordCurrentStage(self)
67
- local game = Game()
68
67
  local level = game:GetLevel()
69
68
  local stage = level:GetStage()
70
69
  local stageType = level:GetStageType()
@@ -7,6 +7,8 @@ local Map = ____lualib.Map
7
7
  local __TS__Iterator = ____lualib.__TS__Iterator
8
8
  local ____exports = {}
9
9
  local postNewRoom, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, initialized, v
10
+ local ____cachedClasses = require("cachedClasses")
11
+ local game = ____cachedClasses.game
10
12
  local ____errors = require("errors")
11
13
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
12
14
  local ____entity = require("functions.entity")
@@ -51,7 +53,6 @@ function postNewRoom(self)
51
53
  respawnPersistentEntities(nil)
52
54
  end
53
55
  function setDecorationsInvisible(self)
54
- local game = Game()
55
56
  local room = game:GetRoom()
56
57
  local roomListIndex = getRoomListIndex(nil)
57
58
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
@@ -63,7 +64,6 @@ function setDecorationsInvisible(self)
63
64
  end
64
65
  end
65
66
  function respawnPersistentEntities(self)
66
- local game = Game()
67
67
  local room = game:GetRoom()
68
68
  local roomListIndex = getRoomListIndex(nil)
69
69
  local persistentEntities = v.level.roomToPersistentEntitiesMap:getAndSetDefault(roomListIndex)
@@ -99,7 +99,6 @@ function ____exports.emptyRoom(self, fillWithDecorations)
99
99
  end
100
100
  end
101
101
  function removeSpecificNPCs(self)
102
- local game = Game()
103
102
  local room = game:GetRoom()
104
103
  for ____, npc in ipairs(getNPCs(nil)) do
105
104
  do
@@ -120,7 +119,6 @@ function removeSpecificNPCs(self)
120
119
  end
121
120
  end
122
121
  function fillRoomWithDecorations(self)
123
- local game = Game()
124
122
  local room = game:GetRoom()
125
123
  local gridSize = room:GetGridSize()
126
124
  local roomListIndex = getRoomListIndex(nil)
@@ -218,7 +216,6 @@ function spawnAllEntities(self, jsonRoom, seed, verbose)
218
216
  return seed
219
217
  end
220
218
  function spawnGridEntityForJSONRoom(self, xmlEntityType, xmlEntityVariant, x, y)
221
- local game = Game()
222
219
  local room = game:GetRoom()
223
220
  local gridEntityTuple = convertXMLGridEntityType(nil, xmlEntityType, xmlEntityVariant)
224
221
  if gridEntityTuple == nil then
@@ -239,7 +236,6 @@ function spawnGridEntityForJSONRoom(self, xmlEntityType, xmlEntityVariant, x, y)
239
236
  return gridEntity
240
237
  end
241
238
  function spawnNormalEntityForJSONRoom(self, entityType, variant, subType, x, y, seed)
242
- local game = Game()
243
239
  local room = game:GetRoom()
244
240
  local roomType = room:GetType()
245
241
  local position = gridToPos(nil, x, y)
@@ -275,7 +271,6 @@ function storePersistentEntity(self, entity)
275
271
  if not PERSISTENT_ENTITY_TYPES:has(entity.Type) then
276
272
  return
277
273
  end
278
- local game = Game()
279
274
  local room = game:GetRoom()
280
275
  local gridIndex = room:GetGridIndex(entity.Position)
281
276
  local roomListIndex = getRoomListIndex(nil)
@@ -284,7 +279,6 @@ function storePersistentEntity(self, entity)
284
279
  __TS__ArrayPush(persistentEntities, persistentEntity)
285
280
  end
286
281
  function fixPitGraphics(self)
287
- local game = Game()
288
282
  local room = game:GetRoom()
289
283
  local gridWidth = room:GetGridWidth()
290
284
  local pitMap = getPitMap(nil)
@@ -4,6 +4,8 @@ local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
6
  local postRender, v
7
+ local ____cachedClasses = require("cachedClasses")
8
+ local musicManager = ____cachedClasses.musicManager
7
9
  local ____errors = require("errors")
8
10
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
11
  local ____sound = require("functions.sound")
@@ -35,7 +37,6 @@ function ____exports.enableAllSound(self, key)
35
37
  end
36
38
  v.run.disableSoundSet:delete(key)
37
39
  if v.run.disableSoundSet.size == 0 and musicWasEnabled then
38
- local musicManager = MusicManager()
39
40
  musicManager:Enable()
40
41
  end
41
42
  stopAllSoundEffects(nil)
@@ -46,7 +47,6 @@ function ____exports.disableAllSound(self, key)
46
47
  error(msg)
47
48
  end
48
49
  if v.run.disableSoundSet.size == 0 then
49
- local musicManager = MusicManager()
50
50
  musicWasEnabled = musicManager:IsEnabled()
51
51
  end
52
52
  v.run.disableSoundSet:add(key)
@@ -4,6 +4,8 @@ local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
6
  local postPickupInitCollectible, v
7
+ local ____cachedClasses = require("cachedClasses")
8
+ local game = ____cachedClasses.game
7
9
  local ____errors = require("errors")
8
10
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
11
  local ____entity = require("functions.entity")
@@ -13,7 +15,6 @@ local getRoomItemPoolType = ____rooms.getRoomItemPoolType
13
15
  local ____exports = require("features.saveDataManager.exports")
14
16
  local saveDataManager = ____exports.saveDataManager
15
17
  function postPickupInitCollectible(self, pickup)
16
- local game = Game()
17
18
  local itemPool = game:GetItemPool()
18
19
  local ptrHash = GetPtrHash(pickup)
19
20
  local lastItemPoolType = itemPool:GetLastPool()
@@ -5,12 +5,13 @@ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
5
5
  local __TS__ArraySplice = ____lualib.__TS__ArraySplice
6
6
  local ____exports = {}
7
7
  local postUpdate, postRender, checkExecuteQueuedFunctions, v
8
+ local ____cachedClasses = require("cachedClasses")
9
+ local game = ____cachedClasses.game
8
10
  local ____errors = require("errors")
9
11
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
10
12
  local ____exports = require("features.saveDataManager.exports")
11
13
  local saveDataManager = ____exports.saveDataManager
12
14
  function postUpdate(self)
13
- local game = Game()
14
15
  local gameFrameCount = game:GetFrameCount()
15
16
  checkExecuteQueuedFunctions(nil, gameFrameCount, v.run.queuedGameFunctionTuples)
16
17
  end
@@ -52,7 +53,6 @@ function ____exports.runInNGameFrames(self, func, frames)
52
53
  local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
53
54
  error(msg)
54
55
  end
55
- local game = Game()
56
56
  local gameFrameCount = game:GetFrameCount()
57
57
  local functionFireFrame = gameFrameCount + frames
58
58
  local tuple = {functionFireFrame, func}
@@ -3,6 +3,8 @@ local ____lualib = require("lualib_bundle")
3
3
  local Map = ____lualib.Map
4
4
  local ____exports = {}
5
5
  local postPlayerInit, preGameExit, postNewLevel, postNewRoomEarly, restoreDefaultsAll, restoreDefaults, clearAndCopyAllElements, mod, loadedDataOnThisRun
6
+ local ____cachedClasses = require("cachedClasses")
7
+ local game = ____cachedClasses.game
6
8
  local ____errors = require("errors")
7
9
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
8
10
  local ____deepCopy = require("functions.deepCopy")
@@ -32,7 +34,6 @@ function postPlayerInit(self)
32
34
  end
33
35
  loadedDataOnThisRun = true
34
36
  loadFromDisk(nil, mod, saveDataMap)
35
- local game = Game()
36
37
  local gameFrameCount = game:GetFrameCount()
37
38
  local isContinued = gameFrameCount ~= 0
38
39
  if not isContinued then
@@ -28,6 +28,12 @@ export declare function getCardName(card: Card | int): string;
28
28
  */
29
29
  export declare function getCardsOfType(...cardTypes: CardType[]): Set<Card>;
30
30
  export declare function getCardType(card: Card | int): CardType;
31
+ /**
32
+ * Helper function to get the final card sub-type in the game.
33
+ *
34
+ * This cannot be reliably determined before run-time due to mods adding a variable amount of new
35
+ * cards.
36
+ */
31
37
  export declare function getMaxCards(): int;
32
38
  /**
33
39
  * Has an equal chance of returning any card (e.g. Fool, Reverse Fool, Wild Card, etc.).
@@ -6,6 +6,8 @@ local Set = ____lualib.Set
6
6
  local __TS__Iterator = ____lualib.__TS__Iterator
7
7
  local ____exports = {}
8
8
  local initCardObjects, CARD_TYPE_TO_CARDS_MAP, CARD_SET
9
+ local ____cachedClasses = require("cachedClasses")
10
+ local itemConfig = ____cachedClasses.itemConfig
9
11
  local ____cardDescriptionMap = require("maps.cardDescriptionMap")
10
12
  local CARD_DESCRIPTION_MAP = ____cardDescriptionMap.CARD_DESCRIPTION_MAP
11
13
  local ____cardNameMap = require("maps.cardNameMap")
@@ -69,13 +71,11 @@ function ____exports.getCardType(self, card)
69
71
  return cardType == nil and DEFAULT_CARD_TYPE or cardType
70
72
  end
71
73
  function ____exports.getMaxCards(self)
72
- local itemConfig = Isaac.GetItemConfig()
73
74
  return itemConfig:GetCards().Size - 1
74
75
  end
75
76
  CARD_TYPE_TO_CARDS_MAP = __TS__New(Map)
76
77
  CARD_SET = __TS__New(Set)
77
78
  function ____exports.getCardDescription(self, card)
78
- local itemConfig = Isaac.GetItemConfig()
79
79
  local defaultDescription = "Unknown"
80
80
  if type(card) ~= "number" then
81
81
  return defaultDescription
@@ -91,7 +91,6 @@ function ____exports.getCardDescription(self, card)
91
91
  return itemConfigCard.Description
92
92
  end
93
93
  function ____exports.getCardName(self, card)
94
- local itemConfig = Isaac.GetItemConfig()
95
94
  local defaultName = "Unknown"
96
95
  if type(card) ~= "number" then
97
96
  return defaultName
@@ -1,6 +1,9 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local getNumChargesToAdd, getNumChargesWithAAAModifier, shouldPlayFullRechargeSound
4
+ local ____cachedClasses = require("cachedClasses")
5
+ local game = ____cachedClasses.game
6
+ local sfxManager = ____cachedClasses.sfxManager
4
7
  local ____collectibles = require("functions.collectibles")
5
8
  local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
6
9
  local ____player = require("functions.player")
@@ -21,7 +24,6 @@ function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, ignoreBi
21
24
  if not player:NeedsCharge(activeSlot) then
22
25
  return
23
26
  end
24
- local game = Game()
25
27
  local hud = game:GetHUD()
26
28
  local totalCharge = getTotalCharge(nil, player, activeSlot)
27
29
  local chargesToAdd = getNumChargesToAdd(nil, player, activeSlot, ignoreBigRoomDoubleCharge)
@@ -35,7 +37,6 @@ function getNumChargesToAdd(self, player, activeSlot, ignoreBigRoomDoubleCharge)
35
37
  if ignoreBigRoomDoubleCharge == nil then
36
38
  ignoreBigRoomDoubleCharge = false
37
39
  end
38
- local game = Game()
39
40
  local room = game:GetRoom()
40
41
  local roomShape = room:GetRoomShape()
41
42
  local activeItem = player:GetActiveItem(activeSlot)
@@ -79,12 +80,11 @@ function getNumChargesWithAAAModifier(self, player, activeSlot, chargesToAdd)
79
80
  return chargesToAdd
80
81
  end
81
82
  function ____exports.playChargeSoundEffect(self, player, activeSlot)
82
- local sfx = SFXManager()
83
83
  for ____, soundEffect in ipairs({SoundEffect.SOUND_BATTERYCHARGE, SoundEffect.SOUND_BEEP}) do
84
- sfx:Stop(soundEffect)
84
+ sfxManager:Stop(soundEffect)
85
85
  end
86
86
  local chargeSoundEffect = shouldPlayFullRechargeSound(nil, player, activeSlot) and SoundEffect.SOUND_BATTERYCHARGE or SoundEffect.SOUND_BEEP
87
- sfx:Play(chargeSoundEffect)
87
+ sfxManager:Play(chargeSoundEffect)
88
88
  end
89
89
  function shouldPlayFullRechargeSound(self, player, activeSlot)
90
90
  local activeItem = player:GetActiveItem(activeSlot)
@@ -3,6 +3,8 @@ local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
+ local ____cachedClasses = require("cachedClasses")
7
+ local itemConfig = ____cachedClasses.itemConfig
6
8
  local ____collectibles = require("functions.collectibles")
7
9
  local getMaxCollectibleType = ____collectibles.getMaxCollectibleType
8
10
  local ____math = require("functions.math")
@@ -11,7 +13,6 @@ local ____set = require("functions.set")
11
13
  local copySet = ____set.copySet
12
14
  local COLLECTIBLE_SET = __TS__New(Set)
13
15
  local function initCollectibleSet(self)
14
- local itemConfig = Isaac.GetItemConfig()
15
16
  local maxCollectibleType = getMaxCollectibleType(nil)
16
17
  for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleType)) do
17
18
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
@@ -52,6 +52,12 @@ export declare function getCollectibleName(collectibleType: CollectibleType | in
52
52
  export declare function getCollectiblePedestalType(collectible: EntityPickup): CollectiblePedestalType;
53
53
  /** Helper function to get all of the collectible entities in the room. */
54
54
  export declare function getCollectibles(matchingSubType?: number): EntityPickup[];
55
+ /**
56
+ * Helper function to get the final collectible type in the game.
57
+ *
58
+ * This cannot be reliably determined before run-time due to mods adding a variable amount of new
59
+ * collectibles.
60
+ */
55
61
  export declare function getMaxCollectibleType(): int;
56
62
  /**
57
63
  * Returns whether or not the given collectible is a "glitched" item. All items are replaced by
@@ -1,6 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local COLLECTIBLE_SPRITE_LAYER, COLLECTIBLE_SHADOW_LAYER
4
+ local ____cachedClasses = require("cachedClasses")
5
+ local itemConfig = ____cachedClasses.itemConfig
4
6
  local ____constants = require("constants")
5
7
  local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
6
8
  local SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = ____constants.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES
@@ -31,7 +33,6 @@ COLLECTIBLE_SPRITE_LAYER = 1
31
33
  COLLECTIBLE_SHADOW_LAYER = 4
32
34
  local GLITCHED_ITEM_THRESHOLD = 4000000000
33
35
  function ____exports.collectibleHasTag(self, collectibleType, tag)
34
- local itemConfig = Isaac.GetItemConfig()
35
36
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
36
37
  if itemConfigItem == nil then
37
38
  return false
@@ -42,7 +43,6 @@ function ____exports.clearCollectibleSprite(self, collectible)
42
43
  ____exports.setCollectibleSprite(nil, collectible, nil)
43
44
  end
44
45
  function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
45
- local itemConfig = Isaac.GetItemConfig()
46
46
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
47
47
  if itemConfigItem == nil then
48
48
  return false
@@ -50,7 +50,6 @@ function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
50
50
  return hasFlag(nil, itemConfigItem.CacheFlags, cacheFlag)
51
51
  end
52
52
  function ____exports.getCollectibleDescription(self, collectibleType)
53
- local itemConfig = Isaac.GetItemConfig()
54
53
  local defaultDescription = "Unknown"
55
54
  if type(collectibleType) ~= "number" then
56
55
  return defaultDescription
@@ -66,7 +65,6 @@ function ____exports.getCollectibleDescription(self, collectibleType)
66
65
  return itemConfigItem.Description
67
66
  end
68
67
  function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player)
69
- local itemConfig = Isaac.GetItemConfig()
70
68
  local maxHearts = player:GetMaxHearts()
71
69
  if collectibleType == CollectibleType.COLLECTIBLE_NULL then
72
70
  return 0
@@ -83,7 +81,6 @@ function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player
83
81
  return itemConfigItem.DevilPrice == 2 and twoHeartPrice or PickupPrice.PRICE_ONE_HEART
84
82
  end
85
83
  function ____exports.getCollectibleGfxFilename(self, collectibleType)
86
- local itemConfig = Isaac.GetItemConfig()
87
84
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
88
85
  if itemConfigItem == nil then
89
86
  return "unknown.png"
@@ -91,7 +88,6 @@ function ____exports.getCollectibleGfxFilename(self, collectibleType)
91
88
  return itemConfigItem.GfxFileName
92
89
  end
93
90
  function ____exports.getCollectibleInitCharges(self, collectibleType)
94
- local itemConfig = Isaac.GetItemConfig()
95
91
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
96
92
  if itemConfigItem == nil then
97
93
  return 0
@@ -99,7 +95,6 @@ function ____exports.getCollectibleInitCharges(self, collectibleType)
99
95
  return itemConfigItem.InitCharge
100
96
  end
101
97
  function ____exports.getCollectibleQuality(self, collectibleType)
102
- local itemConfig = Isaac.GetItemConfig()
103
98
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
104
99
  if itemConfigItem == nil then
105
100
  return 0
@@ -107,7 +102,6 @@ function ____exports.getCollectibleQuality(self, collectibleType)
107
102
  return itemConfigItem.Quality
108
103
  end
109
104
  function ____exports.getCollectibleItemType(self, collectibleType)
110
- local itemConfig = Isaac.GetItemConfig()
111
105
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
112
106
  if itemConfigItem == nil then
113
107
  return ItemType.ITEM_NULL
@@ -115,7 +109,6 @@ function ____exports.getCollectibleItemType(self, collectibleType)
115
109
  return itemConfigItem.Type
116
110
  end
117
111
  function ____exports.getCollectibleMaxCharges(self, collectibleType)
118
- local itemConfig = Isaac.GetItemConfig()
119
112
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
120
113
  if itemConfigItem == nil then
121
114
  return 0
@@ -123,7 +116,6 @@ function ____exports.getCollectibleMaxCharges(self, collectibleType)
123
116
  return itemConfigItem.MaxCharges
124
117
  end
125
118
  function ____exports.getCollectibleName(self, collectibleType)
126
- local itemConfig = Isaac.GetItemConfig()
127
119
  local defaultName = "Unknown"
128
120
  if type(collectibleType) ~= "number" then
129
121
  return defaultName
@@ -152,7 +144,6 @@ function ____exports.getCollectibles(self, matchingSubType)
152
144
  return getPickups(nil, PickupVariant.PICKUP_COLLECTIBLE, matchingSubType)
153
145
  end
154
146
  function ____exports.getMaxCollectibleType(self)
155
- local itemConfig = Isaac.GetItemConfig()
156
147
  return itemConfig:GetCollectibles().Size - 1
157
148
  end
158
149
  function ____exports.isGlitchedCollectible(self, pickup)
@@ -6,11 +6,12 @@ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
6
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
7
7
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
8
8
  local ____exports = {}
9
+ local ____cachedClasses = require("cachedClasses")
10
+ local game = ____cachedClasses.game
9
11
  local ____constants = require("constants")
10
12
  local MAX_NUM_DOORS = ____constants.MAX_NUM_DOORS
11
13
  function ____exports.getDoors(self, ...)
12
14
  local roomTypes = {...}
13
- local game = Game()
14
15
  local room = game:GetRoom()
15
16
  local roomTypesSet = __TS__New(Set, roomTypes)
16
17
  local doors = {}
@@ -41,7 +42,6 @@ function ____exports.isSecretRoomDoor(self, door)
41
42
  return filename == "gfx/grid/Door_08_HoleInWall.anm2"
42
43
  end
43
44
  function ____exports.removeDoor(self, door)
44
- local game = Game()
45
45
  local room = game:GetRoom()
46
46
  room:RemoveDoor(door.Slot)
47
47
  end
@@ -159,7 +159,6 @@ function ____exports.isDoorToMomsHeart(self, door)
159
159
  return filename == "gfx/grid/Door_MomsHeart.anm2"
160
160
  end
161
161
  function ____exports.lockDoor(self, door)
162
- local game = Game()
163
162
  local level = game:GetLevel()
164
163
  local roomDescriptor = level:GetRoomByIdx(door.TargetRoomIndex)
165
164
  roomDescriptor.VisitedCount = 0
@@ -6,6 +6,8 @@ local __TS__New = ____lualib.__TS__New
6
6
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
7
7
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
8
8
  local ____exports = {}
9
+ local ____cachedClasses = require("cachedClasses")
10
+ local game = ____cachedClasses.game
9
11
  local ____constants = require("constants")
10
12
  local STORY_BOSSES = ____constants.STORY_BOSSES
11
13
  local ____random = require("functions.random")
@@ -128,7 +130,6 @@ function ____exports.removeAllMatchingEntities(self, entityType, entityVariant,
128
130
  return ____exports.removeEntities(nil, entities, cap)
129
131
  end
130
132
  function ____exports.rerollEnemy(self, entity)
131
- local game = Game()
132
133
  local oldEntities = ____exports.getEntities(nil)
133
134
  local wasRerolled = game:RerollEnemy(entity)
134
135
  if not wasRerolled then