isaacscript-common 5.0.3 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,6 +63,7 @@ export declare function emptyArray<T>(array: T[]): void;
63
63
  * For example, if this function is provided an array containing 1, 2, and 3, then it will return an
64
64
  * array containing the following arrays:
65
65
  *
66
+ * - [] (if `includeEmptyArray` is set to true)
66
67
  * - [1]
67
68
  * - [2]
68
69
  * - [3]
@@ -225,6 +225,7 @@ end
225
225
  -- For example, if this function is provided an array containing 1, 2, and 3, then it will return an
226
226
  -- array containing the following arrays:
227
227
  --
228
+ -- - [] (if `includeEmptyArray` is set to true)
228
229
  -- - [1]
229
230
  -- - [2]
230
231
  -- - [3]
@@ -53,6 +53,11 @@ export declare function getDoors(...roomTypes: RoomType[]): GridEntityDoor[];
53
53
  export declare function getDoorsToRoomIndex(...roomGridIndex: int[]): GridEntityDoor[];
54
54
  export declare function getOppositeDoorSlot(doorSlot: DoorSlot): DoorSlot | undefined;
55
55
  export declare function getRepentanceDoor(): GridEntityDoor | undefined;
56
+ /**
57
+ * Helper function to get the room grid coordinates for a specific room shape and door slot
58
+ * combination.
59
+ */
60
+ export declare function getRoomShapeDoorSlotCoordinates(roomShape: RoomShape, doorSlot: DoorSlot): readonly [x: int, y: int] | undefined;
56
61
  /** Helper function to find unused door slots in the room that can be used to make custom doors. */
57
62
  export declare function getUnusedDoorSlots(): DoorSlot[];
58
63
  export declare function isAngelRoomDoor(door: GridEntityDoor): boolean;
@@ -24,6 +24,8 @@ local ____doorSlotToDoorSlotFlag = require("objects.doorSlotToDoorSlotFlag")
24
24
  local DOOR_SLOT_TO_DOOR_SLOT_FLAG = ____doorSlotToDoorSlotFlag.DOOR_SLOT_TO_DOOR_SLOT_FLAG
25
25
  local ____oppositeDoorSlots = require("objects.oppositeDoorSlots")
26
26
  local OPPOSITE_DOOR_SLOTS = ____oppositeDoorSlots.OPPOSITE_DOOR_SLOTS
27
+ local ____roomShapeToDoorSlotCoordinates = require("objects.roomShapeToDoorSlotCoordinates")
28
+ local ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES = ____roomShapeToDoorSlotCoordinates.ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES
27
29
  local ____roomShapeToDoorSlots = require("objects.roomShapeToDoorSlots")
28
30
  local ROOM_SHAPE_TO_DOOR_SLOTS = ____roomShapeToDoorSlots.ROOM_SHAPE_TO_DOOR_SLOTS
29
31
  local ____bitwise = require("functions.bitwise")
@@ -190,6 +192,12 @@ function ____exports.getRepentanceDoor(self)
190
192
  function(____, door) return ____exports.isRepentanceDoor(nil, door) end
191
193
  )
192
194
  end
195
+ --- Helper function to get the room grid coordinates for a specific room shape and door slot
196
+ -- combination.
197
+ function ____exports.getRoomShapeDoorSlotCoordinates(self, roomShape, doorSlot)
198
+ local coordinatesMap = ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES[roomShape]
199
+ return coordinatesMap:get(doorSlot)
200
+ end
193
201
  --- Helper function to find unused door slots in the room that can be used to make custom doors.
194
202
  function ____exports.getUnusedDoorSlots(self)
195
203
  local room = game:GetRoom()
@@ -38,7 +38,7 @@ export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, see
38
38
  * For example, if this function is provided a set containing 1, 2, and 3, then it will return an
39
39
  * array containing the following sets:
40
40
  *
41
- * - []
41
+ * - [] (if `includeEmptyArray` is set to true)
42
42
  * - [1]
43
43
  * - [2]
44
44
  * - [3]
package/functions/set.lua CHANGED
@@ -88,7 +88,7 @@ end
88
88
  -- For example, if this function is provided a set containing 1, 2, and 3, then it will return an
89
89
  -- array containing the following sets:
90
90
  --
91
- -- - []
91
+ -- - [] (if `includeEmptyArray` is set to true)
92
92
  -- - [1]
93
93
  -- - [2]
94
94
  -- - [3]
@@ -1,5 +1,9 @@
1
+ import { DoorSlot, RoomShape } from "isaac-typescript-definitions";
1
2
  /**
2
3
  * The coordinates correspond to the x and y values that are present in a room's XML file.
3
4
  *
4
5
  * e.g. `<door exists="False" x="-1" y="3" />`
5
6
  */
7
+ export declare const ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES: {
8
+ readonly [key in RoomShape]: ReadonlyMap<DoorSlot, [x: int, y: int]>;
9
+ };
@@ -0,0 +1,84 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
+ local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
7
+ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
8
+ --- The coordinates correspond to the x and y values that are present in a room's XML file.
9
+ --
10
+ -- e.g. `<door exists="False" x="-1" y="3" />`
11
+ ____exports.ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES = {
12
+ [RoomShape.SHAPE_1x1] = __TS__New(Map, {{DoorSlot.LEFT_0, {-1, 3}}, {DoorSlot.UP_0, {6, -1}}, {DoorSlot.RIGHT_0, {13, 3}}, {DoorSlot.DOWN_0, {6, 7}}}),
13
+ [RoomShape.IH] = __TS__New(Map, {{DoorSlot.LEFT_0, {-1, 3}}, {DoorSlot.RIGHT_0, {13, 3}}}),
14
+ [RoomShape.IV] = __TS__New(Map, {{DoorSlot.UP_0, {6, -1}}, {DoorSlot.DOWN_0, {6, 7}}}),
15
+ [RoomShape.SHAPE_1x2] = __TS__New(Map, {
16
+ {DoorSlot.LEFT_0, {-1, 3}},
17
+ {DoorSlot.UP_0, {6, -1}},
18
+ {DoorSlot.RIGHT_0, {13, 3}},
19
+ {DoorSlot.DOWN_0, {6, 14}},
20
+ {DoorSlot.LEFT_1, {-1, 10}},
21
+ {DoorSlot.RIGHT_1, {13, 10}}
22
+ }),
23
+ [RoomShape.IIV] = __TS__New(Map, {{DoorSlot.UP_0, {6, -1}}, {DoorSlot.DOWN_0, {6, 14}}}),
24
+ [RoomShape.SHAPE_2x1] = __TS__New(Map, {
25
+ {DoorSlot.LEFT_0, {-1, 3}},
26
+ {DoorSlot.UP_0, {6, -1}},
27
+ {DoorSlot.RIGHT_0, {26, 3}},
28
+ {DoorSlot.DOWN_0, {6, 7}},
29
+ {DoorSlot.UP_1, {19, -1}},
30
+ {DoorSlot.DOWN_1, {19, 7}}
31
+ }),
32
+ [RoomShape.IIH] = __TS__New(Map, {{DoorSlot.LEFT_0, {-1, 3}}, {DoorSlot.RIGHT_0, {26, 3}}}),
33
+ [RoomShape.SHAPE_2x2] = __TS__New(Map, {
34
+ {DoorSlot.LEFT_0, {-1, 3}},
35
+ {DoorSlot.UP_0, {6, -1}},
36
+ {DoorSlot.RIGHT_0, {26, 3}},
37
+ {DoorSlot.DOWN_0, {6, 14}},
38
+ {DoorSlot.LEFT_1, {-1, 10}},
39
+ {DoorSlot.UP_1, {19, -1}},
40
+ {DoorSlot.RIGHT_1, {26, 10}},
41
+ {DoorSlot.DOWN_1, {19, 14}}
42
+ }),
43
+ [RoomShape.LTL] = __TS__New(Map, {
44
+ {DoorSlot.LEFT_0, {12, 3}},
45
+ {DoorSlot.UP_0, {6, 6}},
46
+ {DoorSlot.RIGHT_0, {26, 3}},
47
+ {DoorSlot.DOWN_0, {6, 14}},
48
+ {DoorSlot.LEFT_1, {-1, 10}},
49
+ {DoorSlot.UP_1, {19, -1}},
50
+ {DoorSlot.RIGHT_1, {26, 10}},
51
+ {DoorSlot.DOWN_1, {19, 14}}
52
+ }),
53
+ [RoomShape.LTR] = __TS__New(Map, {
54
+ {DoorSlot.LEFT_0, {-1, 3}},
55
+ {DoorSlot.UP_0, {6, -1}},
56
+ {DoorSlot.RIGHT_0, {13, 3}},
57
+ {DoorSlot.DOWN_0, {6, 14}},
58
+ {DoorSlot.LEFT_1, {-1, 10}},
59
+ {DoorSlot.UP_1, {19, 6}},
60
+ {DoorSlot.RIGHT_1, {26, 10}},
61
+ {DoorSlot.DOWN_1, {19, 14}}
62
+ }),
63
+ [RoomShape.LBL] = __TS__New(Map, {
64
+ {DoorSlot.LEFT_0, {-1, 3}},
65
+ {DoorSlot.UP_0, {6, -1}},
66
+ {DoorSlot.RIGHT_0, {26, 3}},
67
+ {DoorSlot.DOWN_0, {6, 7}},
68
+ {DoorSlot.LEFT_1, {12, 10}},
69
+ {DoorSlot.UP_1, {19, -1}},
70
+ {DoorSlot.RIGHT_1, {26, 10}},
71
+ {DoorSlot.DOWN_1, {19, 14}}
72
+ }),
73
+ [RoomShape.LBR] = __TS__New(Map, {
74
+ {DoorSlot.LEFT_0, {-1, 3}},
75
+ {DoorSlot.UP_0, {6, -1}},
76
+ {DoorSlot.RIGHT_0, {26, 3}},
77
+ {DoorSlot.DOWN_0, {6, 14}},
78
+ {DoorSlot.LEFT_1, {-1, 10}},
79
+ {DoorSlot.UP_1, {19, -1}},
80
+ {DoorSlot.RIGHT_1, {13, 10}},
81
+ {DoorSlot.DOWN_1, {19, 7}}
82
+ })
83
+ }
84
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "5.0.3",
3
+ "version": "5.1.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",