isaacscript-common 1.2.64 → 1.2.65

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.
@@ -102,6 +102,7 @@ export declare const MAX_PLAYER_TRINKET_SLOTS = 2;
102
102
  export declare const MAX_ROOM_INDEX = 168;
103
103
  export declare const MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B;
104
104
  export declare const MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING;
105
+ export declare const NUM_DIMENSIONS = 3;
105
106
  export declare const SECOND_IN_MILLISECONDS = 1000;
106
107
  export declare const MINUTE_IN_MILLISECONDS: number;
107
108
  export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
@@ -88,6 +88,7 @@ ____exports.MAX_PLAYER_TRINKET_SLOTS = 2
88
88
  ____exports.MAX_ROOM_INDEX = 168
89
89
  ____exports.MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B
90
90
  ____exports.MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING
91
+ ____exports.NUM_DIMENSIONS = 3
91
92
  ____exports.SECOND_IN_MILLISECONDS = 1000
92
93
  ____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
93
94
  ____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
@@ -23,6 +23,8 @@ local ____jsonRoom = require("functions.jsonRoom")
23
23
  local getRandomJSONRoom = ____jsonRoom.getRandomJSONRoom
24
24
  local ____log = require("functions.log")
25
25
  local log = ____log.log
26
+ local ____math = require("functions.math")
27
+ local range = ____math.range
26
28
  local ____npc = require("functions.npc")
27
29
  local getNPCs = ____npc.getNPCs
28
30
  local ____random = require("functions.random")
@@ -121,24 +123,20 @@ function fillRoomWithDecorations(self)
121
123
  local gridSize = room:GetGridSize()
122
124
  local roomListIndex = getRoomListIndex(nil)
123
125
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
124
- do
125
- local gridIndex = 0
126
- while gridIndex < gridSize do
127
- do
128
- local existingGridEntity = room:GetGridEntity(gridIndex)
129
- if existingGridEntity ~= nil then
130
- goto __continue33
131
- end
132
- local position = room:GetGridPosition(gridIndex)
133
- local decoration = Isaac.GridSpawn(GridEntityType.GRID_DECORATION, 0, position, true)
134
- if decoration ~= nil then
135
- setGridEntityInvisible(nil, decoration)
136
- end
137
- __TS__ArrayPush(decorationGridIndexes, gridIndex)
126
+ for ____, gridIndex in ipairs(range(nil, 0, gridSize - 1)) do
127
+ do
128
+ local existingGridEntity = room:GetGridEntity(gridIndex)
129
+ if existingGridEntity ~= nil then
130
+ goto __continue33
131
+ end
132
+ local position = room:GetGridPosition(gridIndex)
133
+ local decoration = Isaac.GridSpawn(GridEntityType.GRID_DECORATION, 0, position, true)
134
+ if decoration ~= nil then
135
+ setGridEntityInvisible(nil, decoration)
138
136
  end
139
- ::__continue33::
140
- gridIndex = gridIndex + 1
137
+ __TS__ArrayPush(decorationGridIndexes, gridIndex)
141
138
  end
139
+ ::__continue33::
142
140
  end
143
141
  end
144
142
  function spawnAllEntities(self, jsonRoom, seed, verbose)
@@ -9,6 +9,8 @@ local ____exports = {}
9
9
  local ____collectibles = require("functions.collectibles")
10
10
  local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
11
11
  local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
12
+ local ____math = require("functions.math")
13
+ local range = ____math.range
12
14
  local ____set = require("functions.set")
13
15
  local copySet = ____set.copySet
14
16
  local ____utils = require("functions.utils")
@@ -18,13 +20,9 @@ local function initCacheFlagMap(self)
18
20
  local maxCollectibleID = getMaxCollectibleID(nil)
19
21
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
20
22
  local collectiblesSet = __TS__New(Set)
21
- do
22
- local collectibleType = 1
23
- while collectibleType <= maxCollectibleID do
24
- if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
25
- collectiblesSet:add(collectibleType)
26
- end
27
- collectibleType = collectibleType + 1
23
+ for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
24
+ if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
25
+ collectiblesSet:add(collectibleType)
28
26
  end
29
27
  end
30
28
  CACHE_FLAG_TO_COLLECTIBLES_MAP:set(cacheFlag, collectiblesSet)
@@ -5,20 +5,18 @@ local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
6
  local ____collectibles = require("functions.collectibles")
7
7
  local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
8
+ local ____math = require("functions.math")
9
+ local range = ____math.range
8
10
  local ____set = require("functions.set")
9
11
  local copySet = ____set.copySet
10
12
  local COLLECTIBLE_SET = __TS__New(Set)
11
13
  local function initCollectibleSet(self)
12
14
  local itemConfig = Isaac.GetItemConfig()
13
15
  local maxCollectibleID = getMaxCollectibleID(nil)
14
- do
15
- local collectibleType = 1
16
- while collectibleType <= maxCollectibleID do
17
- local itemConfigItem = itemConfig:GetCollectible(collectibleType)
18
- if itemConfigItem ~= nil then
19
- COLLECTIBLE_SET:add(collectibleType)
20
- end
21
- collectibleType = collectibleType + 1
16
+ for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
17
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
18
+ if itemConfigItem ~= nil then
19
+ COLLECTIBLE_SET:add(collectibleType)
22
20
  end
23
21
  end
24
22
  end
@@ -15,6 +15,7 @@ local DEFAULT_TOP_LEFT_WALL_GRID_INDEX = ____roomShapeToTopLeftWallGridIndexMap.
15
15
  local ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP = ____roomShapeToTopLeftWallGridIndexMap.ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP
16
16
  local ____math = require("functions.math")
17
17
  local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
18
+ local range = ____math.range
18
19
  local ____rooms = require("functions.rooms")
19
20
  local roomUpdateSafe = ____rooms.roomUpdateSafe
20
21
  local ____sprite = require("functions.sprite")
@@ -101,26 +102,22 @@ function ____exports.getGridEntities(self, ...)
101
102
  local gridSize = room:GetGridSize()
102
103
  local gridEntityTypesSet = __TS__New(Set, gridEntityTypes)
103
104
  local gridEntities = {}
104
- do
105
- local gridIndex = 0
106
- while gridIndex < gridSize do
107
- do
108
- local gridEntity = room:GetGridEntity(gridIndex)
109
- if gridEntity == nil then
110
- goto __continue10
111
- end
112
- if #gridEntityTypes == 0 then
105
+ for ____, gridIndex in ipairs(range(nil, 0, gridSize - 1)) do
106
+ do
107
+ local gridEntity = room:GetGridEntity(gridIndex)
108
+ if gridEntity == nil then
109
+ goto __continue10
110
+ end
111
+ if #gridEntityTypes == 0 then
112
+ __TS__ArrayPush(gridEntities, gridEntity)
113
+ else
114
+ local thisGridEntityType = gridEntity:GetType()
115
+ if gridEntityTypesSet:has(thisGridEntityType) then
113
116
  __TS__ArrayPush(gridEntities, gridEntity)
114
- else
115
- local thisGridEntityType = gridEntity:GetType()
116
- if gridEntityTypesSet:has(thisGridEntityType) then
117
- __TS__ArrayPush(gridEntities, gridEntity)
118
- end
119
117
  end
120
118
  end
121
- ::__continue10::
122
- gridIndex = gridIndex + 1
123
119
  end
120
+ ::__continue10::
124
121
  end
125
122
  return gridEntities
126
123
  end
@@ -8,6 +8,8 @@ local ____constants = require("constants")
8
8
  local MAX_PLAYER_POCKET_ITEM_SLOTS = ____constants.MAX_PLAYER_POCKET_ITEM_SLOTS
9
9
  local ____PocketItemType = require("types.PocketItemType")
10
10
  local PocketItemType = ____PocketItemType.PocketItemType
11
+ local ____math = require("functions.math")
12
+ local range = ____math.range
11
13
  function ____exports.getPocketItems(self, player)
12
14
  local pocketItem = player:GetActiveItem(ActiveSlot.SLOT_POCKET)
13
15
  local hasPocketItem = pocketItem ~= CollectibleType.COLLECTIBLE_NULL
@@ -17,30 +19,26 @@ function ____exports.getPocketItems(self, player)
17
19
  local pocketItems = {}
18
20
  local pocketItemIdentified = false
19
21
  local pocketItem2Identified = false
20
- do
21
- local slot = 0
22
- while slot < MAX_PLAYER_POCKET_ITEM_SLOTS do
23
- local card = player:GetCard(slot)
24
- local pill = player:GetPill(slot)
25
- if card ~= Card.CARD_NULL then
26
- __TS__ArrayPush(pocketItems, {type = PocketItemType.CARD, id = card, slot = slot})
27
- elseif pill ~= PillColor.PILL_NULL then
28
- __TS__ArrayPush(pocketItems, {type = PocketItemType.PILL, id = pill, slot = slot})
29
- elseif hasPocketItem and not hasPocketItem2 and not pocketItemIdentified then
30
- pocketItemIdentified = true
31
- __TS__ArrayPush(pocketItems, {type = PocketItemType.ACTIVE_ITEM, id = pocketItem, slot = slot})
32
- elseif not hasPocketItem and hasPocketItem2 and not pocketItem2Identified then
33
- pocketItem2Identified = true
34
- __TS__ArrayPush(pocketItems, {type = PocketItemType.DICE_BAG_DICE, id = pocketItem2, slot = slot})
35
- elseif hasPocketItem and hasPocketItem2 then
36
- __TS__ArrayPush(pocketItems, {type = PocketItemType.UNDETERMINABLE, id = 0, slot = slot})
37
- else
38
- __TS__ArrayPush(pocketItems, {type = PocketItemType.EMPTY, id = 0, slot = slot})
39
- end
40
- if slot + 1 == maxPocketItems then
41
- break
42
- end
43
- slot = slot + 1
22
+ for ____, slot in ipairs(range(nil, 0, MAX_PLAYER_POCKET_ITEM_SLOTS - 1)) do
23
+ local card = player:GetCard(slot)
24
+ local pillColor = player:GetPill(slot)
25
+ if card ~= Card.CARD_NULL then
26
+ __TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.CARD, subType = card})
27
+ elseif pillColor ~= PillColor.PILL_NULL then
28
+ __TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.PILL, subType = pillColor})
29
+ elseif hasPocketItem and not hasPocketItem2 and not pocketItemIdentified then
30
+ pocketItemIdentified = true
31
+ __TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.ACTIVE_ITEM, subType = pocketItem})
32
+ elseif not hasPocketItem and hasPocketItem2 and not pocketItem2Identified then
33
+ pocketItem2Identified = true
34
+ __TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.DICE_BAG_DICE, subType = pocketItem2})
35
+ elseif hasPocketItem and hasPocketItem2 then
36
+ __TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.UNDETERMINABLE, subType = 0})
37
+ else
38
+ __TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.EMPTY, subType = 0})
39
+ end
40
+ if slot + 1 == maxPocketItems then
41
+ break
44
42
  end
45
43
  end
46
44
  return pocketItems
@@ -13,6 +13,7 @@ local ____constants = require("constants")
13
13
  local GENESIS_ROOM_SUBTYPE = ____constants.GENESIS_ROOM_SUBTYPE
14
14
  local GENESIS_ROOM_VARIANT = ____constants.GENESIS_ROOM_VARIANT
15
15
  local MAX_ROOM_INDEX = ____constants.MAX_ROOM_INDEX
16
+ local NUM_DIMENSIONS = ____constants.NUM_DIMENSIONS
16
17
  local ____doors = require("functions.doors")
17
18
  local closeAllDoors = ____doors.closeAllDoors
18
19
  local getDoors = ____doors.getDoors
@@ -26,6 +27,8 @@ local setEntityPositions = ____entity.setEntityPositions
26
27
  local setEntityVelocities = ____entity.setEntityVelocities
27
28
  local ____flag = require("functions.flag")
28
29
  local hasFlag = ____flag.hasFlag
30
+ local ____math = require("functions.math")
31
+ local range = ____math.range
29
32
  function ____exports.getCurrentRoomDescriptorReadOnly(self)
30
33
  local game = Game()
31
34
  local level = game:GetLevel()
@@ -116,15 +119,11 @@ function ____exports.getCurrentDimension(self)
116
119
  local startingRoomGridIndex = level:GetStartingRoomIndex()
117
120
  local startingRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, -1)
118
121
  local startingRoomHash = GetPtrHash(startingRoomDesc)
119
- do
120
- local dimension = 0
121
- while dimension <= 2 do
122
- local dimensionRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, dimension)
123
- local dimensionRoomHash = GetPtrHash(dimensionRoomDesc)
124
- if dimensionRoomHash == startingRoomHash then
125
- return dimension
126
- end
127
- dimension = dimension + 1
122
+ for ____, dimension in ipairs(range(nil, 0, NUM_DIMENSIONS - 1)) do
123
+ local dimensionRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, dimension)
124
+ local dimensionRoomHash = GetPtrHash(dimensionRoomDesc)
125
+ if dimensionRoomHash == startingRoomHash then
126
+ return dimension
128
127
  end
129
128
  end
130
129
  return error("Failed to get the current dimension using the starting room index of: " .. tostring(startingRoomGridIndex))
@@ -298,12 +297,12 @@ function ____exports.setRoomCleared(self)
298
297
  for ____, door in ipairs(getDoors(nil)) do
299
298
  do
300
299
  if isHiddenSecretRoomDoor(nil, door) then
301
- goto __continue55
300
+ goto __continue56
302
301
  end
303
302
  openDoorFast(nil, door)
304
303
  door.ExtraVisible = false
305
304
  end
306
- ::__continue55::
305
+ ::__continue56::
307
306
  end
308
307
  sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
309
308
  game:ShakeScreen(0)
@@ -10,6 +10,8 @@ local TRANSFORMATION_NAME_MAP = ____transformationNameMap.TRANSFORMATION_NAME_MA
10
10
  local ____collectibles = require("functions.collectibles")
11
11
  local collectibleHasTag = ____collectibles.collectibleHasTag
12
12
  local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
13
+ local ____math = require("functions.math")
14
+ local range = ____math.range
13
15
  local ____set = require("functions.set")
14
16
  local copySet = ____set.copySet
15
17
  local TRANSFORMATION_TO_TAG_MAP = __TS__New(Map, {
@@ -38,31 +40,27 @@ local function initMaps(self)
38
40
  __TS__New(Set)
39
41
  )
40
42
  end
41
- do
42
- local collectibleType = 1
43
- while collectibleType <= maxCollectibleID do
44
- for ____, ____value in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:entries()) do
45
- local playerForm = ____value[1]
46
- local tag = ____value[2]
47
- do
48
- if not collectibleHasTag(nil, collectibleType, tag) then
49
- goto __continue6
50
- end
51
- local collectibleTypesSet = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
52
- if collectibleTypesSet == nil then
53
- error("Failed to get the collectible types for transformation: " .. tostring(playerForm))
54
- end
55
- collectibleTypesSet:add(collectibleType)
56
- local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:get(collectibleType)
57
- if transformations == nil then
58
- transformations = __TS__New(Set)
59
- COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:set(collectibleType, transformations)
60
- end
61
- transformations:add(playerForm)
43
+ for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
44
+ for ____, ____value in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:entries()) do
45
+ local playerForm = ____value[1]
46
+ local tag = ____value[2]
47
+ do
48
+ if not collectibleHasTag(nil, collectibleType, tag) then
49
+ goto __continue6
62
50
  end
63
- ::__continue6::
51
+ local collectibleTypesSet = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
52
+ if collectibleTypesSet == nil then
53
+ error("Failed to get the collectible types for transformation: " .. tostring(playerForm))
54
+ end
55
+ collectibleTypesSet:add(collectibleType)
56
+ local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:get(collectibleType)
57
+ if transformations == nil then
58
+ transformations = __TS__New(Set)
59
+ COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:set(collectibleType, transformations)
60
+ end
61
+ transformations:add(playerForm)
64
62
  end
65
- collectibleType = collectibleType + 1
63
+ ::__continue6::
66
64
  end
67
65
  end
68
66
  end
@@ -5,6 +5,8 @@ local __TS__New = ____lualib.__TS__New
5
5
  local Set = ____lualib.Set
6
6
  local __TS__Iterator = ____lualib.__TS__Iterator
7
7
  local ____exports = {}
8
+ local ____math = require("functions.math")
9
+ local range = ____math.range
8
10
  local ____set = require("functions.set")
9
11
  local copySet = ____set.copySet
10
12
  local ____trinkets = require("functions.trinkets")
@@ -17,13 +19,9 @@ local function initCacheFlagMap(self)
17
19
  local maxTrinketID = getMaxTrinketID(nil)
18
20
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
19
21
  local trinketsSet = __TS__New(Set)
20
- do
21
- local trinketType = 1
22
- while trinketType <= maxTrinketID do
23
- if trinketHasCacheFlag(nil, trinketType, cacheFlag) then
24
- trinketsSet:add(trinketType)
25
- end
26
- trinketType = trinketType + 1
22
+ for ____, trinketType in ipairs(range(nil, 1, maxTrinketID)) do
23
+ if trinketHasCacheFlag(nil, trinketType, cacheFlag) then
24
+ trinketsSet:add(trinketType)
27
25
  end
28
26
  end
29
27
  CACHE_FLAG_TO_TRINKETS_MAP:set(cacheFlag, trinketsSet)
@@ -43,9 +43,8 @@ declare type SecondArg<K, V, A extends unknown[]> = V | FactoryFunction<K, V, A>
43
43
  * first:
44
44
  *
45
45
  * ```ts
46
- * const defaultMapWithExtraArgs = new DefaultMap<string, string>((_key: string, arg2: boolean) => {
47
- * return arg2 ? 0 : 1;
48
- * })
46
+ * const factoryFunction = (_key: string, arg2: boolean) => arg2 ? 0 : 1;
47
+ * const defaultMapWithExtraArgs = new DefaultMap<string, string, [arg2: boolean]>(factoryFunction);
49
48
  * ```
50
49
  */
51
50
  export declare class DefaultMap<K, V, A extends unknown[] = []> extends Map<K, V> {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { PocketItemType } from "./PocketItemType";
3
3
  export interface PocketItemDescription {
4
- type: PocketItemType;
5
- id: int;
6
4
  slot: PocketItemSlot;
5
+ type: PocketItemType;
6
+ subType: int;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.64",
3
+ "version": "1.2.65",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",