isaacscript-common 1.2.278 → 1.2.281

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.
@@ -5,9 +5,9 @@ import { AnyEntity } from "../types/AnyEntity";
5
5
  * `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
6
6
  * enemies.
7
7
  *
8
- * @param entityType Default is -1.
9
- * @param variant Default is -1.
10
- * @param subType Default is -1.
8
+ * @param entityType Default is -1. -1 matches every entity type.
9
+ * @param variant Default is -1. -1 matches every variant.
10
+ * @param subType Default is -1. -1 matches every sub-type.
11
11
  * @param ignoreFriendly Default is false.
12
12
  */
13
13
  export declare function countEntities(entityType?: EntityType | int, variant?: number, subType?: number, ignoreFriendly?: boolean): int;
@@ -41,8 +41,10 @@ export declare function getClosestEntityTo<T extends AnyEntity>(referenceEntity:
41
41
  *
42
42
  * @param entityType Optional. If specified, will only return NPCs that match this entity
43
43
  * type.
44
- * @param variant Optional. If specified, will only return NPCs that match this variant.
45
- * @param subType Optional. If specified, will only return NPCs that match this sub-type.
44
+ * @param variant Optional. If specified, will only return NPCs that match this variant. Default is
45
+ * -1. -1 matches every variant.
46
+ * @param subType Optional. If specified, will only return NPCs that match this sub-type. Default is
47
+ * -1. -1 matches every sub-type.
46
48
  * @param ignoreFriendly Optional. If set to true, it will exclude friendly NPCs from being
47
49
  * returned. Default is false. Will only be taken into account if `matchingEntityType` is specified.
48
50
  */
@@ -89,10 +91,8 @@ export declare function parseEntityTypeVariantString(entityTypeVariantString: st
89
91
  * Helper function to remove all of the matching entities in the room.
90
92
  *
91
93
  * @param entityType The entity type to match.
92
- * @param entityVariant Optional. The variant to match. Default is -1 (which will match every
93
- * variant).
94
- * @param entitySubType Optional. The sub-type to match. Default is -1 (which will match every
95
- * sub-type).
94
+ * @param entityVariant Optional. The variant to match. Default is -1. -1 matches every variant.
95
+ * @param entitySubType Optional. The sub-type to match. Default is -1. -1 matches every sub-type.
96
96
  * @param cap Optional. If specified, will only remove the given amount of collectibles.
97
97
  * @returns True if one or more entities were removed, false otherwise.
98
98
  */
@@ -32,13 +32,22 @@ export declare function getRoomGridIndexesForType(...roomTypes: RoomType[]): int
32
32
  export declare function getRoomItemPoolType(): ItemPoolType;
33
33
  /**
34
34
  * Helper function to get the room descriptor for every room on the level. Uses the `Level.GetRooms`
35
- * method to accomplish this.
35
+ * method to accomplish this. Rooms without data are assumed to be non-existent and are not added to
36
+ * the list.
36
37
  *
37
38
  * @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
38
39
  * extra-dimensional rooms are automatically be generated and can be seen when you iterate over the
39
40
  * `RoomList`. Default is false.
40
41
  */
41
42
  export declare function getRooms(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
43
+ /**
44
+ * Helper function to get the room descriptor for every room on the level in a specific dimension.
45
+ * Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
46
+ * non-existent and are not added to the list.
47
+ *
48
+ * @returns A map of room ListIndex to RoomDescriptor.
49
+ */
50
+ export declare function getRoomsOfDimension(dimension: Dimension): RoomDescriptor[];
42
51
  /**
43
52
  * Helper function to determine if the current room shape is equal to `RoomShape.ROOMSHAPE_1x2` or
44
53
  * `RoomShape.ROOMSHAPE_2x1`.
@@ -3,9 +3,10 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
+ local Map = ____lualib.Map
7
+ local __TS__Spread = ____lualib.__TS__Spread
6
8
  local __TS__StringIncludes = ____lualib.__TS__StringIncludes
7
9
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
8
- local Map = ____lualib.Map
9
10
  local ____exports = {}
10
11
  local ____cachedClasses = require("cachedClasses")
11
12
  local game = ____cachedClasses.game
@@ -47,14 +48,14 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
47
48
  end
48
49
  local level = game:GetLevel()
49
50
  local roomList = level:GetRooms()
50
- local rooms = {}
51
+ local roomsMap = __TS__New(Map)
51
52
  if includeExtraDimensionalRooms then
52
53
  do
53
54
  local i = 0
54
55
  while i < roomList.Size do
55
56
  local roomDescriptor = roomList:Get(i)
56
- if roomDescriptor ~= nil then
57
- rooms[#rooms + 1] = roomDescriptor
57
+ if roomDescriptor ~= nil and roomDescriptor.Data ~= nil then
58
+ roomsMap:set(roomDescriptor.ListIndex, roomDescriptor)
58
59
  end
59
60
  i = i + 1
60
61
  end
@@ -64,14 +65,14 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
64
65
  local i = 0
65
66
  while i <= MAX_ROOM_INDEX do
66
67
  local roomDescriptor = level:GetRoomByIdx(i)
67
- if roomDescriptor ~= nil then
68
- rooms[#rooms + 1] = roomDescriptor
68
+ if roomDescriptor.Data ~= nil then
69
+ roomsMap:set(roomDescriptor.ListIndex, roomDescriptor)
69
70
  end
70
71
  i = i + 1
71
72
  end
72
73
  end
73
74
  end
74
- return rooms
75
+ return {__TS__Spread(roomsMap:values())}
75
76
  end
76
77
  function ____exports.inDeathCertificateArea(self)
77
78
  local roomStageID = getRoomStageID(nil)
@@ -134,6 +135,21 @@ function ____exports.getRoomItemPoolType(self)
134
135
  local roomSeed = room:GetSpawnSeed()
135
136
  return itemPool:GetPoolForRoom(roomType, roomSeed)
136
137
  end
138
+ function ____exports.getRoomsOfDimension(self, dimension)
139
+ local level = game:GetLevel()
140
+ local roomsMap = __TS__New(Map)
141
+ do
142
+ local i = 0
143
+ while i <= MAX_ROOM_INDEX do
144
+ local roomDescriptor = level:GetRoomByIdx(i, dimension)
145
+ if roomDescriptor.Data ~= nil then
146
+ roomsMap:set(roomDescriptor.ListIndex, roomDescriptor)
147
+ end
148
+ i = i + 1
149
+ end
150
+ end
151
+ return {__TS__Spread(roomsMap:values())}
152
+ end
137
153
  function ____exports.in2x1Room(self)
138
154
  local room = game:GetRoom()
139
155
  local roomShape = room:GetRoomShape()
@@ -274,12 +290,12 @@ function ____exports.setRoomCleared(self)
274
290
  for ____, door in ipairs(getDoors(nil)) do
275
291
  do
276
292
  if isHiddenSecretRoomDoor(nil, door) then
277
- goto __continue52
293
+ goto __continue55
278
294
  end
279
295
  openDoorFast(nil, door)
280
296
  door.ExtraVisible = false
281
297
  end
282
- ::__continue52::
298
+ ::__continue55::
283
299
  end
284
300
  sfxManager:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
285
301
  game:ShakeScreen(0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.278",
3
+ "version": "1.2.281",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,9 +25,9 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.392",
28
+ "isaac-typescript-definitions": "^1.0.393",
29
29
  "isaacscript-lint": "^1.0.99",
30
- "isaacscript-tsconfig": "^1.1.8",
30
+ "isaacscript-tsconfig": "^1.1.9",
31
31
  "typedoc": "^0.22.15",
32
32
  "typescript": "4.6.3",
33
33
  "typescript-to-lua": "^1.4.3"