isaacscript-common 6.0.1 → 6.2.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.
Files changed (60) hide show
  1. package/callbacks/postCollectibleEmpty.d.ts +1 -0
  2. package/callbacks/postCollectibleEmpty.lua +40 -0
  3. package/callbacks/subscriptions/postCollectibleEmpty.d.ts +5 -0
  4. package/callbacks/subscriptions/postCollectibleEmpty.lua +29 -0
  5. package/classes/DefaultMap.lua +2 -2
  6. package/enums/ModCallbackCustom.d.ts +92 -77
  7. package/enums/ModCallbackCustom.lua +79 -77
  8. package/features/customStage/exports.d.ts +3 -9
  9. package/features/customStage/exports.lua +86 -15
  10. package/features/customStage/init.d.ts +1 -0
  11. package/features/customStage/init.lua +48 -0
  12. package/features/customStage/metadata.lua +1 -0
  13. package/features/customStage/util.d.ts +11 -0
  14. package/features/customStage/util.lua +51 -0
  15. package/features/customStage/v.d.ts +6 -2
  16. package/features/customStage/v.lua +4 -1
  17. package/features/deployJSONRoom.d.ts +1 -1
  18. package/functions/boss.d.ts +2 -2
  19. package/functions/doors.d.ts +4 -0
  20. package/functions/doors.lua +14 -0
  21. package/functions/entity.d.ts +2 -2
  22. package/functions/entitySpecific.d.ts +20 -20
  23. package/functions/familiars.d.ts +2 -0
  24. package/functions/familiars.lua +16 -0
  25. package/functions/jsonRoom.d.ts +26 -4
  26. package/functions/jsonRoom.lua +64 -2
  27. package/functions/pickups.d.ts +16 -16
  28. package/functions/playerCenter.d.ts +6 -0
  29. package/functions/playerCenter.lua +57 -0
  30. package/functions/rooms.d.ts +1 -1
  31. package/functions/rooms.lua +2 -2
  32. package/functions/stage.d.ts +3 -3
  33. package/functions/stage.lua +5 -4
  34. package/functions/trinkets.lua +1 -1
  35. package/index.d.ts +1 -5
  36. package/initCustomCallbacks.lua +3 -0
  37. package/initFeatures.lua +3 -0
  38. package/interfaces/AddCallbackParameterCustom.d.ts +2 -0
  39. package/interfaces/CustomStage.d.ts +10 -0
  40. package/interfaces/{CustomStageData.lua → CustomStage.lua} +0 -0
  41. package/interfaces/CustomStageLua.d.ts +118 -0
  42. package/interfaces/{JSONDoor.lua → CustomStageLua.lua} +0 -0
  43. package/interfaces/JSONRoomsFile.d.ts +75 -0
  44. package/interfaces/{JSONEntity.lua → JSONRoomsFile.lua} +0 -0
  45. package/objects/callbackRegisterFunctions.lua +3 -0
  46. package/objects/roomTypeGotoPrefixes.lua +29 -29
  47. package/package.json +1 -1
  48. package/features/customStage/constants.d.ts +0 -18
  49. package/features/customStage/constants.lua +0 -29
  50. package/features/customStage/scripts/generateCustomStageRooms.d.ts +0 -27
  51. package/features/customStage/scripts/generateCustomStageRooms.lua +0 -126
  52. package/interfaces/CustomStageData.d.ts +0 -5
  53. package/interfaces/JSONDoor.d.ts +0 -11
  54. package/interfaces/JSONEntity.d.ts +0 -13
  55. package/interfaces/JSONRoom.d.ts +0 -26
  56. package/interfaces/JSONRoom.lua +0 -2
  57. package/interfaces/JSONRooms.d.ts +0 -11
  58. package/interfaces/JSONRooms.lua +0 -2
  59. package/interfaces/JSONSpawn.d.ts +0 -11
  60. package/interfaces/JSONSpawn.lua +0 -2
@@ -223,42 +223,42 @@ export declare function removeAllSlots(slotVariant?: SlotVariant, subType?: int,
223
223
  */
224
224
  export declare function removeAllTears(tearVariant?: TearVariant, subType?: int, cap?: int): EntityTear[];
225
225
  /** Helper function to spawn a `EntityType.BOMB` (4). */
226
- export declare function spawnBomb(bombVariant: BombVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityBomb;
226
+ export declare function spawnBomb(bombVariant: BombVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityBomb;
227
227
  /** Helper function to spawn a `EntityType.BOMB` (4) with a specific seed. */
228
- export declare function spawnBombWithSeed(bombVariant: BombVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityBomb;
228
+ export declare function spawnBombWithSeed(bombVariant: BombVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityBomb;
229
229
  /** Helper function to spawn a `EntityType.EFFECT` (1000). */
230
- export declare function spawnEffect(effectVariant: EffectVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityEffect;
230
+ export declare function spawnEffect(effectVariant: EffectVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityEffect;
231
231
  /** Helper function to spawn a `EntityType.EFFECT` (1000) with a specific seed. */
232
- export declare function spawnEffectWithSeed(effectVariant: EffectVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityEffect;
232
+ export declare function spawnEffectWithSeed(effectVariant: EffectVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityEffect;
233
233
  /** Helper function to spawn a `EntityType.FAMILIAR` (3). */
234
- export declare function spawnFamiliar(familiarVariant: FamiliarVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityFamiliar;
234
+ export declare function spawnFamiliar(familiarVariant: FamiliarVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityFamiliar;
235
235
  /** Helper function to spawn a `EntityType.FAMILIAR` (3) with a specific seed. */
236
- export declare function spawnFamiliarWithSeed(familiarVariant: FamiliarVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityFamiliar;
236
+ export declare function spawnFamiliarWithSeed(familiarVariant: FamiliarVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityFamiliar;
237
237
  /** Helper function to spawn a `EntityType.KNIFE` (8). */
238
- export declare function spawnKnife(knifeVariant: KnifeVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityKnife;
238
+ export declare function spawnKnife(knifeVariant: KnifeVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityKnife;
239
239
  /** Helper function to spawn a `EntityType.KNIFE` (8) with a specific seed. */
240
- export declare function spawnKnifeWithSeed(knifeVariant: KnifeVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityKnife;
240
+ export declare function spawnKnifeWithSeed(knifeVariant: KnifeVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityKnife;
241
241
  /** Helper function to spawn a `EntityType.LASER` (7). */
242
- export declare function spawnLaser(laserVariant: LaserVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityLaser;
242
+ export declare function spawnLaser(laserVariant: LaserVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityLaser;
243
243
  /** Helper function to spawn a `EntityType.LASER` (7) with a specific seed. */
244
- export declare function spawnLaserWithSeed(laserVariant: LaserVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityLaser;
244
+ export declare function spawnLaserWithSeed(laserVariant: LaserVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityLaser;
245
245
  /** Helper function to spawn an NPC. */
246
- export declare function spawnNPC(entityType: EntityType, variant: int, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityNPC;
246
+ export declare function spawnNPC(entityType: EntityType, variant: int, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityNPC;
247
247
  /** Helper function to spawn an NPC with a specific seed. */
248
- export declare function spawnNPCWithSeed(entityType: EntityType, variant: int, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityNPC;
248
+ export declare function spawnNPCWithSeed(entityType: EntityType, variant: int, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityNPC;
249
249
  /** Helper function to spawn a `EntityType.PICKUP` (5). */
250
- export declare function spawnPickup(pickupVariant: PickupVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickup;
250
+ export declare function spawnPickup(pickupVariant: PickupVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickup;
251
251
  /** Helper function to spawn a `EntityType.PICKUP` (5) with a specific seed. */
252
- export declare function spawnPickupWithSeed(pickupVariant: PickupVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
252
+ export declare function spawnPickupWithSeed(pickupVariant: PickupVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickup;
253
253
  /** Helper function to spawn a `EntityType.PROJECTILE` (9). */
254
- export declare function spawnProjectile(projectileVariant: ProjectileVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityProjectile;
254
+ export declare function spawnProjectile(projectileVariant: ProjectileVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityProjectile;
255
255
  /** Helper function to spawn a `EntityType.PROJECTILE` (9) with a specific seed. */
256
- export declare function spawnProjectileWithSeed(projectileVariant: ProjectileVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityProjectile;
256
+ export declare function spawnProjectileWithSeed(projectileVariant: ProjectileVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityProjectile;
257
257
  /** Helper function to spawn a `EntityType.SLOT` (6). */
258
- export declare function spawnSlot(slotVariant: SlotVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntitySlot;
258
+ export declare function spawnSlot(slotVariant: SlotVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntitySlot;
259
259
  /** Helper function to spawn a `EntityType.SLOT` (6) with a specific seed. */
260
- export declare function spawnSlotWithSeed(slotVariant: SlotVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntitySlot;
260
+ export declare function spawnSlotWithSeed(slotVariant: SlotVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntitySlot;
261
261
  /** Helper function to spawn a `EntityType.TEAR` (2). */
262
- export declare function spawnTear(tearVariant: TearVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityTear;
262
+ export declare function spawnTear(tearVariant: TearVariant, subType: int, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityTear;
263
263
  /** Helper function to spawn a `EntityType.EntityType` (2) with a specific seed. */
264
- export declare function spawnTearWithSeed(tearVariant: TearVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityTear;
264
+ export declare function spawnTearWithSeed(tearVariant: TearVariant, subType: int, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityTear;
@@ -57,4 +57,6 @@ export declare function checkFamiliar(player: EntityPlayer, collectibleType: Col
57
57
  * spawn new familiars with a sub-type of 0.
58
58
  */
59
59
  export declare function checkFamiliarFromCollectibles(player: EntityPlayer, collectibleType: CollectibleType, familiarVariant: FamiliarVariant, familiarSubType?: int): void;
60
+ /** Helper function to get only the familiars that belong to a specific player. */
61
+ export declare function getPlayerFamiliars(player: EntityPlayer): EntityFamiliar[];
60
62
  export declare function isFamiliarThatShootsPlayerTears(familiar: EntityFamiliar): boolean;
@@ -1,8 +1,12 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
1
3
  local ____exports = {}
2
4
  local ____cachedClasses = require("cachedClasses")
3
5
  local itemConfig = ____cachedClasses.itemConfig
4
6
  local ____familiarsThatShootPlayerTearsSet = require("sets.familiarsThatShootPlayerTearsSet")
5
7
  local FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET = ____familiarsThatShootPlayerTearsSet.FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET
8
+ local ____entitySpecific = require("functions.entitySpecific")
9
+ local getFamiliars = ____entitySpecific.getFamiliars
6
10
  --- Helper function to add and remove familiars based on a target amount that you specify.
7
11
  --
8
12
  -- This is a convenience wrapper around the `EntityPlayer.CheckFamiliar` method. Use this helper
@@ -79,6 +83,18 @@ function ____exports.checkFamiliarFromCollectibles(self, player, collectibleType
79
83
  familiarSubType
80
84
  )
81
85
  end
86
+ --- Helper function to get only the familiars that belong to a specific player.
87
+ function ____exports.getPlayerFamiliars(self, player)
88
+ local playerPtrHash = GetPtrHash(player)
89
+ local familiars = getFamiliars(nil)
90
+ return __TS__ArrayFilter(
91
+ familiars,
92
+ function(____, familiar)
93
+ local familiarPlayerPtrHash = GetPtrHash(familiar.Player)
94
+ return familiarPlayerPtrHash == playerPtrHash
95
+ end
96
+ )
97
+ end
82
98
  function ____exports.isFamiliarThatShootsPlayerTears(self, familiar)
83
99
  return FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET:has(familiar.Variant)
84
100
  end
@@ -1,8 +1,24 @@
1
- /// <reference types="isaac-typescript-definitions" />
2
- /// <reference types="isaac-typescript-definitions" />
3
- /// <reference types="isaac-typescript-definitions" />
4
- import { JSONRoom } from "../interfaces/JSONRoom";
1
+ import { DoorSlotFlag } from "isaac-typescript-definitions";
2
+ import { JSONRoom } from "../interfaces/JSONRoomsFile";
3
+ /**
4
+ * Helper function to calculate what the resulting `BitFlags<DoorSlotFlag>` value would be for a
5
+ * given JSON room.
6
+ */
7
+ export declare function getJSONRoomDoorSlotFlags(jsonRoom: JSONRoom): BitFlags<DoorSlotFlag>;
8
+ /**
9
+ * Helper function to find a specific room from an array of JSON rooms.
10
+ *
11
+ * @param jsonRooms The array of rooms to search through.
12
+ * @param variant The room variant to select. (The room variant can be thought of as the ID of the
13
+ * room.)
14
+ */
5
15
  export declare function getJSONRoomOfVariant(jsonRooms: JSONRoom[] | readonly JSONRoom[], variant: int): JSONRoom | undefined;
16
+ /**
17
+ * Helper function to find all of the JSON rooms that match the sub-type provided.
18
+ *
19
+ * @param jsonRooms The array of rooms to search through.
20
+ * @param subType The sub-type to match.
21
+ */
6
22
  export declare function getJSONRoomsOfSubType(jsonRooms: JSONRoom[] | readonly JSONRoom[], subType: int): JSONRoom[];
7
23
  /**
8
24
  * Helper function to get a random JSON room from an array of JSON rooms.
@@ -10,5 +26,11 @@ export declare function getJSONRoomsOfSubType(jsonRooms: JSONRoom[] | readonly J
10
26
  * Note that this function does not simply choose a random element in the provided array; it will
11
27
  * properly account for each room weight using the algorithm from:
12
28
  * https://stackoverflow.com/questions/1761626/weighted-random-numbers
29
+ *
30
+ * @param jsonRooms The array of rooms to random choose between.
31
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
32
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
33
+ * @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
34
+ * what the function is doing. Default is false.
13
35
  */
14
36
  export declare function getRandomJSONRoom(jsonRooms: JSONRoom[] | readonly JSONRoom[], seedOrRNG?: Seed | RNG, verbose?: boolean): JSONRoom;
@@ -3,8 +3,15 @@ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
3
3
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
4
4
  local ____exports = {}
5
5
  local getTotalWeightOfJSONRooms, getJSONRoomWithChosenWeight
6
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
+ local DoorSlotFlagZero = ____isaac_2Dtypescript_2Ddefinitions.DoorSlotFlagZero
6
8
  local ____array = require("functions.array")
7
9
  local sumArray = ____array.sumArray
10
+ local ____doors = require("functions.doors")
11
+ local doorSlotToDoorSlotFlag = ____doors.doorSlotToDoorSlotFlag
12
+ local getRoomShapeDoorSlot = ____doors.getRoomShapeDoorSlot
13
+ local ____flag = require("functions.flag")
14
+ local addFlag = ____flag.addFlag
8
15
  local ____log = require("functions.log")
9
16
  local log = ____log.log
10
17
  local ____random = require("functions.random")
@@ -37,8 +44,53 @@ function getJSONRoomWithChosenWeight(self, jsonRooms, chosenWeight)
37
44
  end
38
45
  chosenWeight = chosenWeight - roomWeight
39
46
  end
40
- return error("Failed to get a JSON room with chosen weight: " .. tostring(chosenWeight))
47
+ error("Failed to get a JSON room with chosen weight: " .. tostring(chosenWeight))
41
48
  end
49
+ --- Helper function to calculate what the resulting `BitFlags<DoorSlotFlag>` value would be for a
50
+ -- given JSON room.
51
+ function ____exports.getJSONRoomDoorSlotFlags(self, jsonRoom)
52
+ local roomShapeString = jsonRoom["$"].shape
53
+ local roomShapeNumber = tonumber(roomShapeString)
54
+ if roomShapeNumber == nil then
55
+ error("Failed to parse the \"shape\" property of a JSON room: " .. roomShapeString)
56
+ end
57
+ local roomShape = roomShapeNumber
58
+ local doorSlotFlags = DoorSlotFlagZero
59
+ for ____, door in ipairs(jsonRoom.door) do
60
+ do
61
+ local existsString = door["$"].exists
62
+ if existsString ~= "True" and existsString ~= "False" then
63
+ error("Failed to parse the \"exists\" property of a JSON room door: " .. existsString)
64
+ end
65
+ if existsString == "False" then
66
+ goto __continue4
67
+ end
68
+ local xString = door["$"].x
69
+ local x = tonumber(xString)
70
+ if x == nil then
71
+ error("Failed to parse the \"x\" property of a JSON room door: " .. xString)
72
+ end
73
+ local yString = door["$"].y
74
+ local y = tonumber(yString)
75
+ if y == nil then
76
+ error("Failed to parse the \"y\" property of a JSON room door: " .. yString)
77
+ end
78
+ local doorSlot = getRoomShapeDoorSlot(nil, roomShape, x, y)
79
+ if doorSlot == nil then
80
+ error(((("Failed to retrieve the door slot for a JSON room door at coordinates: [" .. tostring(x)) .. ", ") .. tostring(y)) .. "]")
81
+ end
82
+ local doorSlotFlag = doorSlotToDoorSlotFlag(nil, doorSlot)
83
+ doorSlotFlags = addFlag(nil, doorSlotFlags, doorSlotFlag)
84
+ end
85
+ ::__continue4::
86
+ end
87
+ return doorSlotFlags
88
+ end
89
+ --- Helper function to find a specific room from an array of JSON rooms.
90
+ --
91
+ -- @param jsonRooms The array of rooms to search through.
92
+ -- @param variant The room variant to select. (The room variant can be thought of as the ID of the
93
+ -- room.)
42
94
  function ____exports.getJSONRoomOfVariant(self, jsonRooms, variant)
43
95
  local jsonRoomsOfVariant = __TS__ArrayFilter(
44
96
  jsonRooms,
@@ -54,8 +106,12 @@ function ____exports.getJSONRoomOfVariant(self, jsonRooms, variant)
54
106
  if #jsonRoomsOfVariant == 1 then
55
107
  return jsonRoomsOfVariant[1]
56
108
  end
57
- return error(((("Found " .. tostring(#jsonRoomsOfVariant)) .. " JSON rooms with a variant of ") .. tostring(variant)) .. ", when there should only be 1.")
109
+ error(((("Found " .. tostring(#jsonRoomsOfVariant)) .. " JSON rooms with a variant of ") .. tostring(variant)) .. ", when there should only be 1.")
58
110
  end
111
+ --- Helper function to find all of the JSON rooms that match the sub-type provided.
112
+ --
113
+ -- @param jsonRooms The array of rooms to search through.
114
+ -- @param subType The sub-type to match.
59
115
  function ____exports.getJSONRoomsOfSubType(self, jsonRooms, subType)
60
116
  return __TS__ArrayFilter(
61
117
  jsonRooms,
@@ -71,6 +127,12 @@ end
71
127
  -- Note that this function does not simply choose a random element in the provided array; it will
72
128
  -- properly account for each room weight using the algorithm from:
73
129
  -- https://stackoverflow.com/questions/1761626/weighted-random-numbers
130
+ --
131
+ -- @param jsonRooms The array of rooms to random choose between.
132
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
133
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
134
+ -- @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
135
+ -- what the function is doing. Default is false.
74
136
  function ____exports.getRandomJSONRoom(self, jsonRooms, seedOrRNG, verbose)
75
137
  if seedOrRNG == nil then
76
138
  seedOrRNG = getRandomSeed(nil)
@@ -103,30 +103,30 @@ export declare function removeAllTrinkets(trinketType?: TrinketType, cap?: int):
103
103
  /**
104
104
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.LIL_BATTERY` (90).
105
105
  */
106
- export declare function spawnBattery(subType: BatterySubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupBattery;
107
- export declare function spawnBatteryWithSeed(subType: BatterySubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupBattery;
106
+ export declare function spawnBattery(subType: BatterySubType, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupBattery;
107
+ export declare function spawnBatteryWithSeed(subType: BatterySubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupBattery;
108
108
  /**
109
109
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TAROT_CARD` (300).
110
110
  */
111
- export declare function spawnCard(subType: Card, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupCard;
112
- export declare function spawnCardWithSeed(subType: Card, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupCard;
111
+ export declare function spawnCard(subType: Card, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupCard;
112
+ export declare function spawnCardWithSeed(subType: Card, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupCard;
113
113
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.COIN` (20). */
114
- export declare function spawnCoin(subType: CoinSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupCoin;
115
- export declare function spawnCoinWithSeed(subType: CoinSubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupCoin;
114
+ export declare function spawnCoin(subType: CoinSubType, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupCoin;
115
+ export declare function spawnCoinWithSeed(subType: CoinSubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupCoin;
116
116
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.HEART` (10). */
117
- export declare function spawnHeart(subType: HeartSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupHeart;
118
- export declare function spawnHeartWithSeed(subType: HeartSubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupHeart;
117
+ export declare function spawnHeart(subType: HeartSubType, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupHeart;
118
+ export declare function spawnHeartWithSeed(subType: HeartSubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupHeart;
119
119
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.KEY` (30). */
120
- export declare function spawnKey(subType: KeySubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupKey;
121
- export declare function spawnKeyWithSeed(subType: KeySubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupKey;
120
+ export declare function spawnKey(subType: KeySubType, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupKey;
121
+ export declare function spawnKeyWithSeed(subType: KeySubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupKey;
122
122
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.PILL` (70). */
123
- export declare function spawnPill(pillColor: PillColor, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupPill;
124
- export declare function spawnPillWithSeed(subType: PillColor, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupPill;
123
+ export declare function spawnPill(pillColor: PillColor, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupPill;
124
+ export declare function spawnPillWithSeed(subType: PillColor, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupPill;
125
125
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.SACK` (69). */
126
- export declare function spawnSack(subType: SackSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupSack;
127
- export declare function spawnSackWithSeed(subType: SackSubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupSack;
126
+ export declare function spawnSack(subType: SackSubType, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupSack;
127
+ export declare function spawnSackWithSeed(subType: SackSubType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupSack;
128
128
  /**
129
129
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TRINKET` (350).
130
130
  */
131
- export declare function spawnTrinket(subType: TrinketType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupTrinket;
132
- export declare function spawnTrinketWithSeed(subType: TrinketType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupTrinket;
131
+ export declare function spawnTrinket(subType: TrinketType, position: Vector, velocity?: Vector, spawner?: Entity | undefined, seedOrRNG?: Seed | RNG | undefined): EntityPickupTrinket;
132
+ export declare function spawnTrinketWithSeed(subType: TrinketType, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupTrinket;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Helper function to move all of the players to the center of the room.
3
+ *
4
+ * This function emulates what happens in the vanilla game when you travel to a new floor.
5
+ */
6
+ export declare function movePlayersToCenter(): void;
@@ -0,0 +1,57 @@
1
+ local ____exports = {}
2
+ local movePlayerAndTheirFamiliars
3
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
+ local Direction = ____isaac_2Dtypescript_2Ddefinitions.Direction
5
+ local ____cachedClasses = require("cachedClasses")
6
+ local game = ____cachedClasses.game
7
+ local ____familiars = require("functions.familiars")
8
+ local getPlayerFamiliars = ____familiars.getPlayerFamiliars
9
+ local ____math = require("functions.math")
10
+ local getCircleDiscretizedPoints = ____math.getCircleDiscretizedPoints
11
+ local ____playerIndex = require("functions.playerIndex")
12
+ local getPlayers = ____playerIndex.getPlayers
13
+ function movePlayerAndTheirFamiliars(self, player, position)
14
+ player.Position = position
15
+ local familiars = getPlayerFamiliars(nil, player)
16
+ for ____, familiar in ipairs(familiars) do
17
+ familiar.Position = position
18
+ end
19
+ end
20
+ local CIRCLE_RADIUS_BETWEEN_PLAYERS = 50
21
+ --- Helper function to move all of the players to the center of the room.
22
+ --
23
+ -- This function emulates what happens in the vanilla game when you travel to a new floor.
24
+ function ____exports.movePlayersToCenter(self)
25
+ local room = game:GetRoom()
26
+ local centerPos = room:GetCenterPos()
27
+ local players = getPlayers(nil)
28
+ local firstPlayer = players[1]
29
+ if firstPlayer == nil then
30
+ return
31
+ end
32
+ if #players == 1 then
33
+ movePlayerAndTheirFamiliars(nil, firstPlayer, centerPos)
34
+ return
35
+ end
36
+ local circlePoints = getCircleDiscretizedPoints(
37
+ nil,
38
+ centerPos,
39
+ CIRCLE_RADIUS_BETWEEN_PLAYERS,
40
+ #players,
41
+ 1,
42
+ 1,
43
+ Direction.LEFT
44
+ )
45
+ do
46
+ local i = 0
47
+ while i < #players do
48
+ local player = players[i + 1]
49
+ local position = circlePoints[i + 1]
50
+ if player ~= nil and position ~= nil then
51
+ player.Position = position
52
+ end
53
+ i = i + 1
54
+ end
55
+ end
56
+ end
57
+ return ____exports
@@ -55,7 +55,7 @@ export declare function getRoomTypeName(roomType: RoomType): string;
55
55
  * non-existent and are not added to the list.
56
56
  *
57
57
  * @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
58
- * extra-dimensional rooms are automatically be generated and can be
58
+ * extra-dimensional rooms are automatically generated and can be
59
59
  * seen when you iterate over the `RoomList`. Default is false.
60
60
  */
61
61
  export declare function getRooms(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
@@ -72,7 +72,7 @@ end
72
72
  -- non-existent and are not added to the list.
73
73
  --
74
74
  -- @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
75
- -- extra-dimensional rooms are automatically be generated and can be
75
+ -- extra-dimensional rooms are automatically generated and can be
76
76
  -- seen when you iterate over the `RoomList`. Default is false.
77
77
  function ____exports.getRooms(self, includeExtraDimensionalRooms)
78
78
  if includeExtraDimensionalRooms == nil then
@@ -145,7 +145,7 @@ function ____exports.getDimension(self)
145
145
  return dimension
146
146
  end
147
147
  end
148
- return error("Failed to get the current dimension.")
148
+ error("Failed to get the current dimension.")
149
149
  end
150
150
  --- Helper function to get the number of rooms that are currently on the floor layout. This does not
151
151
  -- include off-grid rooms, like the Devil Room.
@@ -16,10 +16,10 @@ export declare function calculateStageTypeRepentance(stage: LevelStage): StageTy
16
16
  */
17
17
  export declare function getEffectiveStage(): int;
18
18
  /**
19
- * Helper function to get the prefix to use with the "goto" console command that would correspond to
20
- * the provided room type.
19
+ * Helper function to get the corresponding "goto" console command that would correspond to the
20
+ * provided room type and room variant.
21
21
  */
22
- export declare function getGotoCommandPrefix(roomType: RoomType): string;
22
+ export declare function getGotoCommand(roomType: RoomType, roomVariant: int): string;
23
23
  /** Alias for the `Level.GetStage` method. */
24
24
  export declare function getStage(): LevelStage;
25
25
  /** Alias for the `Level.GetStageType` method. */
@@ -64,10 +64,11 @@ function ____exports.getEffectiveStage(self)
64
64
  end
65
65
  return stage
66
66
  end
67
- --- Helper function to get the prefix to use with the "goto" console command that would correspond to
68
- -- the provided room type.
69
- function ____exports.getGotoCommandPrefix(self, roomType)
70
- return ROOM_TYPE_GOTO_PREFIXES[roomType]
67
+ --- Helper function to get the corresponding "goto" console command that would correspond to the
68
+ -- provided room type and room variant.
69
+ function ____exports.getGotoCommand(self, roomType, roomVariant)
70
+ local prefix = ROOM_TYPE_GOTO_PREFIXES[roomType]
71
+ return (("goto " .. prefix) .. ".") .. tostring(roomVariant)
71
72
  end
72
73
  --- Alias for the `Level.GetStage` method.
73
74
  function ____exports.getStage(self)
@@ -76,7 +76,7 @@ function ____exports.getOpenTrinketSlot(self, player)
76
76
  end
77
77
  return trinketType2 == TrinketType.NULL and 1 or nil
78
78
  end
79
- return error("The player has an unknown number of trinket slots: " .. tostring(maxTrinkets))
79
+ error("The player has an unknown number of trinket slots: " .. tostring(maxTrinkets))
80
80
  end
81
81
  --- Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
82
82
  -- trinket type was not valid.
package/index.d.ts CHANGED
@@ -121,11 +121,7 @@ export * from "./functions/utils";
121
121
  export * from "./functions/vector";
122
122
  export * from "./interfaces/AddCallbackParameterCustom";
123
123
  export * from "./interfaces/ChargeBarSprites";
124
- export * from "./interfaces/JSONDoor";
125
- export * from "./interfaces/JSONEntity";
126
- export * from "./interfaces/JSONRoom";
127
- export * from "./interfaces/JSONRooms";
128
- export * from "./interfaces/JSONSpawn";
124
+ export * from "./interfaces/JSONRoomsFile";
129
125
  export * from "./interfaces/PlayerHealth";
130
126
  export * from "./interfaces/PocketItemDescription";
131
127
  export * from "./interfaces/SaveData";
@@ -11,6 +11,8 @@ local ____postBombInitLate = require("callbacks.postBombInitLate")
11
11
  local postBombInitLateInit = ____postBombInitLate.postBombInitLateInit
12
12
  local ____postBoneSwing = require("callbacks.postBoneSwing")
13
13
  local postBoneSwingInit = ____postBoneSwing.postBoneSwingInit
14
+ local ____postCollectibleEmpty = require("callbacks.postCollectibleEmpty")
15
+ local postCollectibleEmptyInit = ____postCollectibleEmpty.postCollectibleEmptyInit
14
16
  local ____postCollectibleInitFirst = require("callbacks.postCollectibleInitFirst")
15
17
  local postCollectibleInitFirstInit = ____postCollectibleInitFirst.postCollectibleInitFirstInit
16
18
  local ____postCursedTeleport = require("callbacks.postCursedTeleport")
@@ -134,6 +136,7 @@ function ____exports.initCustomCallbacks(self, mod)
134
136
  postBombExplodedInit(nil, mod)
135
137
  postBombInitLateInit(nil, mod)
136
138
  postBoneSwingInit(nil, mod)
139
+ postCollectibleEmptyInit(nil, mod)
137
140
  postCollectibleInitFirstInit(nil, mod)
138
141
  postCursedTeleportInit(nil, mod)
139
142
  postCustomDoorEnterInit(nil)
package/initFeatures.lua CHANGED
@@ -7,6 +7,8 @@ local ____collectibleItemPoolType = require("features.collectibleItemPoolType")
7
7
  local collectibleItemPoolTypeInit = ____collectibleItemPoolType.collectibleItemPoolTypeInit
8
8
  local ____customGridEntity = require("features.customGridEntity")
9
9
  local customGridEntityInit = ____customGridEntity.customGridEntityInit
10
+ local ____init = require("features.customStage.init")
11
+ local customStageInit = ____init.customStageInit
10
12
  local ____deployJSONRoom = require("features.deployJSONRoom")
11
13
  local deployJSONRoomInit = ____deployJSONRoom.deployJSONRoomInit
12
14
  local ____disableAllSound = require("features.disableAllSound")
@@ -40,6 +42,7 @@ local stageHistoryInit = ____stageHistory.stageHistoryInit
40
42
  local ____taintedLazarusPlayers = require("features.taintedLazarusPlayers")
41
43
  local taintedLazarusPlayersInit = ____taintedLazarusPlayers.taintedLazarusPlayersInit
42
44
  function ____exports.initFeaturesMajor(self, mod)
45
+ customStageInit(nil)
43
46
  deployJSONRoomInit(nil, mod)
44
47
  runInNFramesInit(nil, mod)
45
48
  characterStatsInit(nil, mod)
@@ -3,6 +3,7 @@ import { PostAmbushStartedRegisterParameters } from "../callbacks/subscriptions/
3
3
  import { PostBombInitRegisterParameters } from "../callbacks/subscriptions/postBombInitLate";
4
4
  import { PostBombExplodedRegisterParameters } from "../callbacks/subscriptions/postBoneExploded";
5
5
  import { PostBoneSwingRegisterParameters } from "../callbacks/subscriptions/postBoneSwing";
6
+ import { PostCollectibleEmptyRegisterParameters } from "../callbacks/subscriptions/postCollectibleEmpty";
6
7
  import { PostCollectibleInitFirstRegisterParameters } from "../callbacks/subscriptions/postCollectibleInitFirst";
7
8
  import { PostCursedTeleportRegisterParameters } from "../callbacks/subscriptions/postCursedTeleport";
8
9
  import { PostCustomDoorEnterRegisterParameters } from "../callbacks/subscriptions/postCustomDoorEnter";
@@ -87,6 +88,7 @@ export interface AddCallbackParameterCustom {
87
88
  [ModCallbackCustom.POST_BOMB_EXPLODED]: PostBombExplodedRegisterParameters;
88
89
  [ModCallbackCustom.POST_BOMB_INIT_LATE]: PostBombInitRegisterParameters;
89
90
  [ModCallbackCustom.POST_BONE_SWING]: PostBoneSwingRegisterParameters;
91
+ [ModCallbackCustom.POST_COLLECTIBLE_EMPTY]: PostCollectibleEmptyRegisterParameters;
90
92
  [ModCallbackCustom.POST_COLLECTIBLE_INIT_FIRST]: PostCollectibleInitFirstRegisterParameters;
91
93
  [ModCallbackCustom.POST_CURSED_TELEPORT]: PostCursedTeleportRegisterParameters;
92
94
  [ModCallbackCustom.POST_CUSTOM_DOOR_ENTER]: PostCustomDoorEnterRegisterParameters;
@@ -0,0 +1,10 @@
1
+ import { DoorSlotFlag, RoomShape, RoomType } from "isaac-typescript-definitions";
2
+ import { CustomStageLua, CustomStageRoomMetadata } from "./CustomStageLua";
3
+ export interface CustomStage extends CustomStageLua {
4
+ /** A map that makes it easier to select certain room type/shape/door combinations. */
5
+ readonly roomTypeMap: RoomTypeMap;
6
+ }
7
+ export declare type RoomTypeMap = ReadonlyMap<RoomType, RoomShapeMap>;
8
+ declare type RoomShapeMap = ReadonlyMap<RoomShape, RoomDoorSlotMap>;
9
+ declare type RoomDoorSlotMap = ReadonlyMap<DoorSlotFlag, CustomStageRoomMetadata[]>;
10
+ export {};