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
@@ -3,6 +3,8 @@ local ____lualib = require("lualib_bundle")
3
3
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
4
4
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
5
5
  local ____exports = {}
6
+ local ____cachedClasses = require("cachedClasses")
7
+ local game = ____cachedClasses.game
6
8
  local ____constants = require("constants")
7
9
  local FAMILIARS_THAT_SHOOT_PLAYER_TEARS = ____constants.FAMILIARS_THAT_SHOOT_PLAYER_TEARS
8
10
  local ____array = require("functions.array")
@@ -30,7 +32,6 @@ function ____exports.getFamiliars(self, matchingVariant, matchingSubType)
30
32
  return familiars
31
33
  end
32
34
  function ____exports.checkFamiliar(self, player, collectibleType, numTargetFamiliars, familiarVariant, familiarSubType)
33
- local game = Game()
34
35
  local familiarSubTypeToSearchFor = familiarSubType == nil and -1 or familiarSubType
35
36
  local playerPtrHash = GetPtrHash(player)
36
37
  local familiars = ____exports.getFamiliars(nil, familiarVariant, familiarSubTypeToSearchFor)
@@ -8,6 +8,8 @@ local Map = ____lualib.Map
8
8
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
9
9
  local ____exports = {}
10
10
  local getAllGridEntities
11
+ local ____cachedClasses = require("cachedClasses")
12
+ local game = ____cachedClasses.game
11
13
  local ____constants = require("constants")
12
14
  local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
13
15
  local ____gridEntityTypeToBrokenStateMap = require("maps.gridEntityTypeToBrokenStateMap")
@@ -25,7 +27,6 @@ local roomUpdateSafe = ____rooms.roomUpdateSafe
25
27
  local ____sprite = require("functions.sprite")
26
28
  local clearSprite = ____sprite.clearSprite
27
29
  function getAllGridEntities(self)
28
- local game = Game()
29
30
  local room = game:GetRoom()
30
31
  local gridSize = room:GetGridSize()
31
32
  local gridEntities = {}
@@ -38,7 +39,6 @@ function getAllGridEntities(self)
38
39
  return gridEntities
39
40
  end
40
41
  function ____exports.getTopLeftWallGridIndex(self)
41
- local game = Game()
42
42
  local room = game:GetRoom()
43
43
  local roomShape = room:GetRoomShape()
44
44
  local topLeftWallGridIndex = ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP:get(roomShape)
@@ -48,7 +48,6 @@ function ____exports.removeGridEntity(self, gridEntity, updateRoom)
48
48
  if updateRoom == nil then
49
49
  updateRoom = true
50
50
  end
51
- local game = Game()
52
51
  local room = game:GetRoom()
53
52
  local gridIndex = gridEntity:GetGridIndex()
54
53
  room:RemoveGridEntity(gridIndex, 0, false)
@@ -57,7 +56,6 @@ function ____exports.removeGridEntity(self, gridEntity, updateRoom)
57
56
  end
58
57
  end
59
58
  function ____exports.spawnGridEntityWithVariant(self, gridEntityType, variant, gridIndex)
60
- local game = Game()
61
59
  local room = game:GetRoom()
62
60
  local existingGridEntity = room:GetGridEntity(gridIndex)
63
61
  if existingGridEntity ~= nil then
@@ -154,13 +152,11 @@ function ____exports.getGridEntitiesMap(self, ...)
154
152
  return gridEntityMap
155
153
  end
156
154
  function ____exports.getTopLeftWall(self)
157
- local game = Game()
158
155
  local room = game:GetRoom()
159
156
  local topLeftWallGridIndex = ____exports.getTopLeftWallGridIndex(nil)
160
157
  return room:GetGridEntity(topLeftWallGridIndex)
161
158
  end
162
159
  function ____exports.getSurroundingGridEntities(self, gridEntity)
163
- local game = Game()
164
160
  local room = game:GetRoom()
165
161
  local gridWidth = room:GetGridWidth()
166
162
  local gridIndex = gridEntity:GetGridIndex()
@@ -184,7 +180,6 @@ function ____exports.getSurroundingGridEntities(self, gridEntity)
184
180
  return surroundingGridEntities
185
181
  end
186
182
  function ____exports.isAllPressurePlatesPushed(self)
187
- local game = Game()
188
183
  local room = game:GetRoom()
189
184
  local hasPressurePlates = room:HasTriggerPressurePlates()
190
185
  if not hasPressurePlates then
@@ -247,7 +242,6 @@ function ____exports.setGridEntityInvisible(self, gridEntity)
247
242
  clearSprite(nil, sprite)
248
243
  end
249
244
  function ____exports.spawnGiantPoop(self, topLeftGridIndex)
250
- local game = Game()
251
245
  local room = game:GetRoom()
252
246
  local gridWidth = room:GetGridWidth()
253
247
  local topRightGridIndex = topLeftGridIndex + 1
@@ -6,6 +6,8 @@ local __TS__ArraySort = ____lualib.__TS__ArraySort
6
6
  local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
7
7
  local Set = ____lualib.Set
8
8
  local ____exports = {}
9
+ local ____cachedClasses = require("cachedClasses")
10
+ local game = ____cachedClasses.game
9
11
  local ____array = require("functions.array")
10
12
  local arrayToString = ____array.arrayToString
11
13
  local ____collectibles = require("functions.collectibles")
@@ -70,7 +72,6 @@ function ____exports.logAllEntityFlags(flags)
70
72
  ____exports.logAllFlags(flags, EntityFlag, "entity")
71
73
  end
72
74
  function ____exports.logAllGameStateFlags()
73
- local game = Game()
74
75
  ____exports.log("Logging all game state flags:")
75
76
  local hasNoFlags = true
76
77
  for key, value in pairs(GameStateFlag) do
@@ -89,7 +90,6 @@ function ____exports.logAllProjectileFlags(flags)
89
90
  ____exports.logAllFlags(flags, ProjectileFlags, "projectile")
90
91
  end
91
92
  function ____exports.logAllSeedEffects()
92
- local game = Game()
93
93
  local seeds = game:GetSeeds()
94
94
  ____exports.log("Logging all seed effects:")
95
95
  local hasNoSeedEffects = true
@@ -1,8 +1,14 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ import { DefaultMap } from "../types/DefaultMap";
2
3
  /** Helper function to copy a map. (You can also use a Map constructor to accomplish this task.) */
3
4
  export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
4
5
  /**
5
- * Helper function to make using map with `Seed` values easier. Use this instead of manually getting
6
- * the current value, incrementing it, and then re-setting it.
6
+ * Helper function to make using default maps with `Seed` values easier. Use this instead of
7
+ * manually getting the current value, incrementing it, and then setting it.
8
+ */
9
+ export declare function defaultMapGetNextSeed<K, A extends unknown[]>(map: DefaultMap<K, Seed, A>, key: K, ...extraArgs: A): Seed;
10
+ /**
11
+ * Helper function to make using maps with `Seed` values easier. Use this instead of manually
12
+ * getting the current value, incrementing it, and then setting it.
7
13
  */
8
14
  export declare function mapGetNextSeed<K>(map: Map<K, Seed>, key: K): Seed | undefined;
@@ -15,6 +15,15 @@ function ____exports.copyMap(self, oldMap)
15
15
  end
16
16
  return newMap
17
17
  end
18
+ function ____exports.defaultMapGetNextSeed(self, map, key, ...)
19
+ local seed = map:getAndSetDefault(key, ...)
20
+ if seed == 0 then
21
+ error("The seed map had a value of 0 for the key of: " .. tostring(key))
22
+ end
23
+ local newSeed = nextSeed(nil, seed)
24
+ map:set(key, newSeed)
25
+ return newSeed
26
+ end
18
27
  function ____exports.mapGetNextSeed(self, map, key)
19
28
  local seed = map:get(key)
20
29
  if seed == nil then
@@ -1,6 +1,10 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { PillEffectClass } from "../types/PillEffectClass";
3
3
  import { PillEffectType } from "../types/PillEffectType";
4
+ /**
5
+ * Helper function to get the final pill effect in the game. This cannot be reliably determined
6
+ * before run-time due to mods adding a variable amount of new pill effects.
7
+ */
4
8
  export declare function getMaxPillEffects(): int;
5
9
  /**
6
10
  * Helper function to get a pill effect class from a PillEffect enum value. In this context, the
@@ -1,5 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local ____cachedClasses = require("cachedClasses")
4
+ local itemConfig = ____cachedClasses.itemConfig
3
5
  local ____pillEffectClassMap = require("maps.pillEffectClassMap")
4
6
  local PILL_EFFECT_CLASS_MAP = ____pillEffectClassMap.PILL_EFFECT_CLASS_MAP
5
7
  local ____pillEffectNameMap = require("maps.pillEffectNameMap")
@@ -11,7 +13,6 @@ local DEFAULT_PILL_EFFECT_CLASS = ____PillEffectClass.DEFAULT_PILL_EFFECT_CLASS
11
13
  local ____PillEffectType = require("types.PillEffectType")
12
14
  local DEFAULT_PILL_EFFECT_TYPE = ____PillEffectType.DEFAULT_PILL_EFFECT_TYPE
13
15
  function ____exports.getMaxPillEffects(self)
14
- local itemConfig = Isaac.GetItemConfig()
15
16
  return itemConfig:GetPillEffects().Size - 1
16
17
  end
17
18
  function ____exports.getPillEffectClass(self, pillEffect)
@@ -19,7 +20,6 @@ function ____exports.getPillEffectClass(self, pillEffect)
19
20
  return pillEffectClass == nil and DEFAULT_PILL_EFFECT_CLASS or pillEffectClass
20
21
  end
21
22
  function ____exports.getPillEffectName(self, pillEffect)
22
- local itemConfig = Isaac.GetItemConfig()
23
23
  local defaultName = "Unknown"
24
24
  if type(pillEffect) ~= "number" then
25
25
  return defaultName
@@ -11,6 +11,9 @@ local __TS__Iterator = ____lualib.__TS__Iterator
11
11
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
12
12
  local ____exports = {}
13
13
  local getPlayerIndexCollectibleType, getAdjustedPlayerName, isTaintedModded, DEFAULT_COLLECTIBLE_TYPE, EXCLUDED_CHARACTERS
14
+ local ____cachedClasses = require("cachedClasses")
15
+ local game = ____cachedClasses.game
16
+ local itemConfig = ____cachedClasses.itemConfig
14
17
  local ____constants = require("constants")
15
18
  local CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = ____constants.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART
16
19
  local CHARACTERS_WITH_FREE_DEVIL_DEALS = ____constants.CHARACTERS_WITH_FREE_DEVIL_DEALS
@@ -38,7 +41,6 @@ local ____utils = require("functions.utils")
38
41
  local ensureAllCases = ____utils.ensureAllCases
39
42
  local ____repeat = ____utils["repeat"]
40
43
  function ____exports.getAllPlayers(self)
41
- local game = Game()
42
44
  local numPlayers = game:GetNumPlayers()
43
45
  local players = {}
44
46
  do
@@ -245,7 +247,6 @@ end
245
247
  DEFAULT_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_SAD_ONION
246
248
  EXCLUDED_CHARACTERS = __TS__New(Set, {PlayerType.PLAYER_ESAU, PlayerType.PLAYER_THESOUL_B})
247
249
  function ____exports.addCollectibleCostume(self, player, collectibleType)
248
- local itemConfig = Isaac.GetItemConfig()
249
250
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
250
251
  if itemConfigItem == nil then
251
252
  return
@@ -253,7 +254,6 @@ function ____exports.addCollectibleCostume(self, player, collectibleType)
253
254
  player:AddCostume(itemConfigItem, false)
254
255
  end
255
256
  function ____exports.addTrinketCostume(self, player, trinketType)
256
- local itemConfig = Isaac.GetItemConfig()
257
257
  local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
258
258
  if itemConfigTrinket == nil then
259
259
  return
@@ -454,7 +454,6 @@ function ____exports.getPlayerFromIndex(self, playerIndex)
454
454
  )
455
455
  end
456
456
  function ____exports.getPlayerIndexVanilla(self, playerToFind)
457
- local game = Game()
458
457
  local numPlayers = game:GetNumPlayers()
459
458
  local playerToFindHash = GetPtrHash(playerToFind)
460
459
  do
@@ -567,7 +566,6 @@ function ____exports.isTaintedLazarus(self, player)
567
566
  return character == PlayerType.PLAYER_LAZARUS_B or character == PlayerType.PLAYER_LAZARUS2_B
568
567
  end
569
568
  function ____exports.removeCollectibleCostume(self, player, collectibleType)
570
- local itemConfig = Isaac.GetItemConfig()
571
569
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
572
570
  if itemConfigItem == nil then
573
571
  return
@@ -584,7 +582,6 @@ function ____exports.removeDeadEyeMultiplier(self, player)
584
582
  )
585
583
  end
586
584
  function ____exports.removeTrinketCostume(self, player, trinketType)
587
- local itemConfig = Isaac.GetItemConfig()
588
585
  local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
589
586
  if itemConfigTrinket == nil then
590
587
  return
@@ -595,7 +592,6 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
595
592
  if keepInPools == nil then
596
593
  keepInPools = false
597
594
  end
598
- local game = Game()
599
595
  local itemPool = game:GetItemPool()
600
596
  local primaryCollectibleType = player:GetActiveItem(ActiveSlot.SLOT_PRIMARY)
601
597
  local primaryCharge = player:GetActiveCharge(ActiveSlot.SLOT_PRIMARY)
@@ -660,7 +656,6 @@ function ____exports.setBlindfold(self, player, enabled, modifyCostume)
660
656
  if modifyCostume == nil then
661
657
  modifyCostume = true
662
658
  end
663
- local game = Game()
664
659
  local character = player:GetPlayerType()
665
660
  local challenge = Isaac.GetChallenge()
666
661
  if enabled then
@@ -3,6 +3,8 @@ local ____lualib = require("lualib_bundle")
3
3
  local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
+ local ____cachedClasses = require("cachedClasses")
7
+ local game = ____cachedClasses.game
6
8
  local ____constants = require("constants")
7
9
  local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
8
10
  local ____entity = require("functions.entity")
@@ -17,7 +19,6 @@ function ____exports.findFreePosition(self, startingPosition, avoidActiveEntitie
17
19
  if avoidActiveEntities == nil then
18
20
  avoidActiveEntities = false
19
21
  end
20
- local game = Game()
21
22
  local room = game:GetRoom()
22
23
  local heavenDoors = getEffects(nil, EffectVariant.HEAVEN_LIGHT_DOOR, 0)
23
24
  do
@@ -42,8 +42,9 @@ export declare function nextSeed(seed: Seed): Seed;
42
42
  * const fiftyFiftyChance = rng.RandomInt(2) === 0;
43
43
  * ```
44
44
  *
45
- * @param seed The seed to initialize it with.
46
- * (If you aren't initializing it with a seed, then don't use this function and instead simply call
47
- * the `RNG()` constructor.)
45
+ * It is recommended to not deal with RNG objects directly and instead use seeds. Also see the
46
+ * `getRandom`, `getRandomInt`, and `getRandomFloat` helper functions.
47
+ *
48
+ * @param seed The seed to initialize it with. Default is `Random()`.
48
49
  */
49
50
  export declare function initRNG(seed?: Seed): RNG;
@@ -3,7 +3,7 @@
3
3
  * Uses the player's current health and other miscellaneous things to determine if incoming damage
4
4
  * will be fatal.
5
5
  */
6
- export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int | null): boolean;
6
+ export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int | undefined): boolean;
7
7
  /**
8
8
  * The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper, so
9
9
  * use this helper function instead for more robust revival detection.
@@ -1,5 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local ____cachedClasses = require("cachedClasses")
4
+ local game = ____cachedClasses.game
3
5
  local ____player = require("functions.player")
4
6
  local getDeathAnimationName = ____player.getDeathAnimationName
5
7
  local getPlayerMaxHeartContainers = ____player.getPlayerMaxHeartContainers
@@ -12,7 +14,6 @@ local ____trinketGive = require("functions.trinketGive")
12
14
  local giveTrinketsBack = ____trinketGive.giveTrinketsBack
13
15
  local temporarilyRemoveTrinket = ____trinketGive.temporarilyRemoveTrinket
14
16
  function ____exports.willMysteriousPaperRevive(self, player)
15
- local game = Game()
16
17
  local gameFrameCount = game:GetFrameCount()
17
18
  local sprite = player:GetSprite()
18
19
  local animation = getDeathAnimationName(nil, player)
@@ -40,7 +41,6 @@ function ____exports.willReviveFromSpiritShackles(self, player)
40
41
  return spiritShacklesEnabled and not playerInSoulForm
41
42
  end
42
43
  function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSource, lastDamageGameFrame)
43
- local game = Game()
44
44
  local gameFrameCount = game:GetFrameCount()
45
45
  local character = player:GetPlayerType()
46
46
  local effects = player:GetEffects()
@@ -1,8 +1,9 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /**
3
3
  * Helper function for quickly switching to a new room without playing a particular animation.
4
- * Use this helper function over invoking `Game().ChangeRoom()` directly to ensure that you do not
5
- * forget to set the LeaveDoor property and to prevent crashing on invalid room grid indexes.
4
+ * Use this helper function over invoking the `Game.ChangeRoom` method directly to ensure that you
5
+ * do not forget to set the `LeaveDoor` property and to prevent crashing on invalid room grid
6
+ * indexes.
6
7
  */
7
8
  export declare function changeRoom(roomGridIndex: int): void;
8
9
  export declare function getAllRoomGridIndexes(): int[];
@@ -8,6 +8,9 @@ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
8
8
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
9
9
  local Map = ____lualib.Map
10
10
  local ____exports = {}
11
+ local ____cachedClasses = require("cachedClasses")
12
+ local game = ____cachedClasses.game
13
+ local sfxManager = ____cachedClasses.sfxManager
11
14
  local ____constants = require("constants")
12
15
  local MAX_ROOM_INDEX = ____constants.MAX_ROOM_INDEX
13
16
  local NUM_DIMENSIONS = ____constants.NUM_DIMENSIONS
@@ -28,7 +31,6 @@ local getEntityVelocities = ____positionVelocity.getEntityVelocities
28
31
  local setEntityPositions = ____positionVelocity.setEntityPositions
29
32
  local setEntityVelocities = ____positionVelocity.setEntityVelocities
30
33
  function ____exports.getCurrentRoomDescriptorReadOnly(self)
31
- local game = Game()
32
34
  local level = game:GetLevel()
33
35
  return level:GetCurrentRoomDesc()
34
36
  end
@@ -37,7 +39,6 @@ function ____exports.getRoomData(self, roomGridIndex)
37
39
  return roomDescriptor.Data
38
40
  end
39
41
  function ____exports.getRoomDescriptor(self, roomGridIndex)
40
- local game = Game()
41
42
  local level = game:GetLevel()
42
43
  if roomGridIndex == nil then
43
44
  roomGridIndex = ____exports.getRoomGridIndex(nil)
@@ -45,7 +46,6 @@ function ____exports.getRoomDescriptor(self, roomGridIndex)
45
46
  return level:GetRoomByIdx(roomGridIndex)
46
47
  end
47
48
  function ____exports.getRoomGridIndex(self)
48
- local game = Game()
49
49
  local level = game:GetLevel()
50
50
  local currentRoomIndex = level:GetCurrentRoomIndex()
51
51
  if currentRoomIndex < 0 then
@@ -66,7 +66,6 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
66
66
  if includeExtraDimensionalRooms == nil then
67
67
  includeExtraDimensionalRooms = false
68
68
  end
69
- local game = Game()
70
69
  local level = game:GetLevel()
71
70
  local roomList = level:GetRooms()
72
71
  local rooms = {}
@@ -101,7 +100,6 @@ function ____exports.inDeathCertificateArea(self)
101
100
  return roomStageID == 35 and (roomSubType == 33 or roomSubType == 34)
102
101
  end
103
102
  function ____exports.changeRoom(self, roomGridIndex)
104
- local game = Game()
105
103
  local level = game:GetLevel()
106
104
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
107
105
  if roomData == nil then
@@ -118,7 +116,6 @@ function ____exports.getAllRoomGridIndexes(self)
118
116
  )
119
117
  end
120
118
  function ____exports.getCurrentDimension(self)
121
- local game = Game()
122
119
  local level = game:GetLevel()
123
120
  if ____exports.inDeathCertificateArea(nil) then
124
121
  return 2
@@ -152,7 +149,6 @@ function ____exports.getRoomGridIndexesForType(self, ...)
152
149
  )
153
150
  end
154
151
  function ____exports.getRoomItemPoolType(self)
155
- local game = Game()
156
152
  local itemPool = game:GetItemPool()
157
153
  local room = game:GetRoom()
158
154
  local roomType = room:GetType()
@@ -176,7 +172,6 @@ function ____exports.getRoomVisitedCount(self, roomGridIndex)
176
172
  return roomDescriptor.VisitedCount
177
173
  end
178
174
  function ____exports.gridToPos(self, x, y)
179
- local game = Game()
180
175
  local room = game:GetRoom()
181
176
  x = x + 1
182
177
  y = y + 1
@@ -184,27 +179,23 @@ function ____exports.gridToPos(self, x, y)
184
179
  return room:GetGridPosition(gridIndex)
185
180
  end
186
181
  function ____exports.in2x1Room(self)
187
- local game = Game()
188
182
  local room = game:GetRoom()
189
183
  local roomShape = room:GetRoomShape()
190
184
  return roomShape == RoomShape.ROOMSHAPE_1x2 or roomShape == RoomShape.ROOMSHAPE_2x1
191
185
  end
192
186
  function ____exports.inAngelShop(self)
193
- local game = Game()
194
187
  local room = game:GetRoom()
195
188
  local roomType = room:GetType()
196
189
  local roomSubType = ____exports.getRoomSubType(nil)
197
190
  return roomType == RoomType.ROOM_ANGEL and roomSubType == 1
198
191
  end
199
192
  function ____exports.inBeastRoom(self)
200
- local game = Game()
201
193
  local room = game:GetRoom()
202
194
  local roomType = room:GetType()
203
195
  local roomSubType = ____exports.getRoomSubType(nil)
204
196
  return roomType == RoomType.ROOM_DUNGEON and roomSubType == 4
205
197
  end
206
198
  function ____exports.inBossRoomOf(self, bossID)
207
- local game = Game()
208
199
  local room = game:GetRoom()
209
200
  local roomType = room:GetType()
210
201
  local roomStageID = ____exports.getRoomStageID(nil)
@@ -212,7 +203,6 @@ function ____exports.inBossRoomOf(self, bossID)
212
203
  return roomType == RoomType.ROOM_BOSS and roomStageID == 0 and roomSubType == bossID
213
204
  end
214
205
  function ____exports.inCrawlspace(self)
215
- local game = Game()
216
206
  local room = game:GetRoom()
217
207
  local roomType = room:GetType()
218
208
  local roomSubType = ____exports.getRoomSubType(nil)
@@ -226,13 +216,11 @@ function ____exports.inDimension(self, dimension)
226
216
  return dimension == ____exports.getCurrentDimension(nil)
227
217
  end
228
218
  function ____exports.inLRoom(self)
229
- local game = Game()
230
219
  local room = game:GetRoom()
231
220
  local roomShape = room:GetRoomShape()
232
221
  return roomShape == RoomShape.ROOMSHAPE_LTL or roomShape == RoomShape.ROOMSHAPE_LTR or roomShape == RoomShape.ROOMSHAPE_LBL or roomShape == RoomShape.ROOMSHAPE_LBR
233
222
  end
234
223
  function ____exports.inGenesisRoom(self)
235
- local game = Game()
236
224
  local room = game:GetRoom()
237
225
  local roomType = room:GetType()
238
226
  local roomSubType = ____exports.getRoomSubType(nil)
@@ -243,7 +231,6 @@ function ____exports.inMegaSatanRoom(self)
243
231
  return roomGridIndex == GridRooms.ROOM_MEGA_SATAN_IDX
244
232
  end
245
233
  function ____exports.inMinibossRoomOf(self, minibossID)
246
- local game = Game()
247
234
  local room = game:GetRoom()
248
235
  local roomType = room:GetType()
249
236
  local roomStageID = ____exports.getRoomStageID(nil)
@@ -254,7 +241,6 @@ function ____exports.inSecretShop(self)
254
241
  return ____exports.getRoomGridIndex(nil) == GridRooms.ROOM_SECRET_SHOP_IDX
255
242
  end
256
243
  function ____exports.inStartingRoom(self)
257
- local game = Game()
258
244
  local level = game:GetLevel()
259
245
  local startingRoomGridIndex = level:GetStartingRoomIndex()
260
246
  local roomGridIndex = ____exports.getRoomGridIndex(nil)
@@ -289,7 +275,6 @@ function ____exports.isRoomInsideMap(self, roomGridIndex)
289
275
  return roomGridIndex >= 0
290
276
  end
291
277
  function ____exports.roomUpdateSafe(self)
292
- local game = Game()
293
278
  local room = game:GetRoom()
294
279
  local entities = getEntities(nil)
295
280
  local entityPositions = getEntityPositions(nil, entities)
@@ -299,10 +284,8 @@ function ____exports.roomUpdateSafe(self)
299
284
  setEntityVelocities(nil, entityVelocities, entities)
300
285
  end
301
286
  function ____exports.setRoomCleared(self)
302
- local game = Game()
303
287
  local room = game:GetRoom()
304
288
  local roomClear = room:IsClear()
305
- local sfx = SFXManager()
306
289
  if roomClear then
307
290
  return
308
291
  end
@@ -317,11 +300,10 @@ function ____exports.setRoomCleared(self)
317
300
  end
318
301
  ::__continue59::
319
302
  end
320
- sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
303
+ sfxManager:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
321
304
  game:ShakeScreen(0)
322
305
  end
323
306
  function ____exports.setRoomUncleared(self)
324
- local game = Game()
325
307
  local room = game:GetRoom()
326
308
  room:SetClear(false)
327
309
  closeAllDoors(nil)
@@ -333,7 +315,6 @@ function ____exports.teleport(self, roomGridIndex, direction, roomTransitionAnim
333
315
  if roomTransitionAnim == nil then
334
316
  roomTransitionAnim = RoomTransitionAnim.TELEPORT
335
317
  end
336
- local game = Game()
337
318
  local level = game:GetLevel()
338
319
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
339
320
  if roomData == nil then
@@ -1,7 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local ____cachedClasses = require("cachedClasses")
4
+ local game = ____cachedClasses.game
3
5
  function ____exports.getStartSeedString(self)
4
- local game = Game()
5
6
  local seeds = game:GetSeeds()
6
7
  return seeds:GetStartSeedString()
7
8
  end
@@ -1,9 +1,10 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local ____cachedClasses = require("cachedClasses")
4
+ local sfxManager = ____cachedClasses.sfxManager
3
5
  local ____utils = require("functions.utils")
4
6
  local getEnumValues = ____utils.getEnumValues
5
7
  function ____exports.stopAllSoundEffects(self)
6
- local sfxManager = SFXManager()
7
8
  for ____, soundEffect in ipairs(getEnumValues(nil, SoundEffect)) do
8
9
  sfxManager:Stop(soundEffect)
9
10
  end
@@ -1,5 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local ____cachedClasses = require("cachedClasses")
4
+ local game = ____cachedClasses.game
3
5
  local ____preventCollectibleRotate = require("features.preventCollectibleRotate")
4
6
  local preventCollectibleRotate = ____preventCollectibleRotate.preventCollectibleRotate
5
7
  local ____featuresInitialized = require("featuresInitialized")
@@ -22,7 +24,6 @@ function ____exports.spawnCollectible(self, collectibleType, position, seed, opt
22
24
  if seed == 0 then
23
25
  error("Failed to spawn a collectible since the provided seed was 0, which is not allowed. (It will cause the game to crash.)")
24
26
  end
25
- local game = Game()
26
27
  local collectible = game:Spawn(
27
28
  EntityType.ENTITY_PICKUP,
28
29
  PickupVariant.PICKUP_COLLECTIBLE,
@@ -1,12 +1,13 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local ____cachedClasses = require("cachedClasses")
4
+ local game = ____cachedClasses.game
3
5
  local ____utils = require("functions.utils")
4
6
  local ensureAllCases = ____utils.ensureAllCases
5
7
  function ____exports.isRepentanceStage(self, stageType)
6
8
  return stageType == StageType.STAGETYPE_REPENTANCE or stageType == StageType.STAGETYPE_REPENTANCE_B
7
9
  end
8
10
  function ____exports.onRepentanceStage(self)
9
- local game = Game()
10
11
  local level = game:GetLevel()
11
12
  local stageType = level:GetStageType()
12
13
  return ____exports.isRepentanceStage(nil, stageType)
@@ -58,7 +59,6 @@ function ____exports.stageTypeToLetter(self, stageType)
58
59
  until true
59
60
  end
60
61
  function ____exports.getEffectiveStage(self)
61
- local game = Game()
62
62
  local level = game:GetLevel()
63
63
  local stage = level:GetStage()
64
64
  if ____exports.onRepentanceStage(nil) then
@@ -67,12 +67,10 @@ function ____exports.getEffectiveStage(self)
67
67
  return stage
68
68
  end
69
69
  function ____exports.getStage(self)
70
- local game = Game()
71
70
  local level = game:GetLevel()
72
71
  return level:GetStage()
73
72
  end
74
73
  function ____exports.getStageType(self)
75
- local game = Game()
76
74
  local level = game:GetLevel()
77
75
  return level:GetStageType()
78
76
  end
@@ -82,34 +80,29 @@ function ____exports.goToStage(self, stage, stageType)
82
80
  Isaac.ExecuteCommand(command)
83
81
  end
84
82
  function ____exports.onCathedral(self)
85
- local game = Game()
86
83
  local level = game:GetLevel()
87
84
  local stage = level:GetStage()
88
85
  local stageType = level:GetStageType()
89
86
  return stage == 10 and stageType == 1
90
87
  end
91
88
  function ____exports.onChest(self)
92
- local game = Game()
93
89
  local level = game:GetLevel()
94
90
  local stage = level:GetStage()
95
91
  local stageType = level:GetStageType()
96
92
  return stage == 11 and stageType == 1
97
93
  end
98
94
  function ____exports.onDarkRoom(self)
99
- local game = Game()
100
95
  local level = game:GetLevel()
101
96
  local stage = level:GetStage()
102
97
  local stageType = level:GetStageType()
103
98
  return stage == 11 and stageType == 0
104
99
  end
105
100
  function ____exports.onFinalFloor(self)
106
- local game = Game()
107
101
  local level = game:GetLevel()
108
102
  local stage = level:GetStage()
109
103
  return stage == 11 or stage == 12 or stage == 13 or stage == 8 and ____exports.onRepentanceStage(nil)
110
104
  end
111
105
  function ____exports.onSheol(self)
112
- local game = Game()
113
106
  local level = game:GetLevel()
114
107
  local stage = level:GetStage()
115
108
  local stageType = level:GetStageType()
@@ -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 ____math = require("functions.math")
7
9
  local range = ____math.range
8
10
  local ____set = require("functions.set")
@@ -11,7 +13,6 @@ local ____trinkets = require("functions.trinkets")
11
13
  local getMaxTrinketType = ____trinkets.getMaxTrinketType
12
14
  local TRINKET_SET = __TS__New(Set)
13
15
  local function initTrinketSet(self)
14
- local itemConfig = Isaac.GetItemConfig()
15
16
  local maxTrinketID = getMaxTrinketType(nil)
16
17
  for ____, trinketType in ipairs(range(nil, 1, maxTrinketID)) do
17
18
  local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
@@ -1,4 +1,8 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to get the final trinket type in the game. This cannot be reliably determined
4
+ * before run-time due to mods adding a variable amount of new trinkets.
5
+ */
2
6
  export declare function getMaxTrinketType(): int;
3
7
  /**
4
8
  * Returns the slot number corresponding to where a trinket can be safely inserted.