isaacscript-common 4.2.8 → 4.3.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 (43) hide show
  1. package/enums/StageTravelEntityState.d.ts +4 -0
  2. package/enums/StageTravelEntityState.lua +7 -0
  3. package/enums/StageTravelState.d.ts +6 -0
  4. package/enums/StageTravelState.lua +11 -0
  5. package/features/{getCollectibleItemPoolType.d.ts → collectibleItemPoolType.d.ts} +0 -0
  6. package/features/{getCollectibleItemPoolType.lua → collectibleItemPoolType.lua} +2 -2
  7. package/features/customTrapdoor/constants.d.ts +5 -0
  8. package/features/customTrapdoor/constants.lua +7 -0
  9. package/features/customTrapdoor/exports.d.ts +37 -0
  10. package/features/customTrapdoor/exports.lua +120 -0
  11. package/features/customTrapdoor/init.d.ts +1 -0
  12. package/features/customTrapdoor/init.lua +11 -0
  13. package/features/{stageTravel → customTrapdoor}/stageTravel.d.ts +0 -0
  14. package/features/{stageTravel → customTrapdoor}/stageTravel.lua +0 -0
  15. package/features/{stageTravel → customTrapdoor}/trapdoor.d.ts +0 -0
  16. package/features/{stageTravel → customTrapdoor}/trapdoor.lua +0 -0
  17. package/features/customTrapdoor/v.d.ts +14 -0
  18. package/features/customTrapdoor/v.lua +16 -0
  19. package/features/ponyDetection.d.ts +6 -1
  20. package/features/ponyDetection.lua +14 -1
  21. package/features/roomClearFrame.d.ts +11 -0
  22. package/features/roomClearFrame.lua +38 -0
  23. package/features/stageHistory.d.ts +15 -0
  24. package/features/stageHistory.lua +62 -0
  25. package/functions/gridEntity.d.ts +5 -0
  26. package/functions/gridEntity.lua +9 -0
  27. package/functions/gridEntitySpecific.d.ts +11 -6
  28. package/functions/gridEntitySpecific.lua +18 -0
  29. package/functions/log.lua +7 -1
  30. package/functions/nextStage.d.ts +18 -0
  31. package/functions/nextStage.lua +245 -0
  32. package/functions/stage.d.ts +10 -0
  33. package/functions/stage.lua +28 -0
  34. package/index.d.ts +8 -5
  35. package/index.lua +50 -20
  36. package/initFeatures.lua +12 -3
  37. package/interfaces/StageTravelEntityDescription.d.ts +5 -0
  38. package/interfaces/StageTravelEntityDescription.lua +2 -0
  39. package/package.json +2 -2
  40. package/enums/StageTravelEntityType.d.ts +0 -5
  41. package/enums/StageTravelEntityType.lua +0 -9
  42. package/features/stageTravel/exports.d.ts +0 -23
  43. package/features/stageTravel/exports.lua +0 -44
@@ -0,0 +1,4 @@
1
+ export declare enum StageTravelEntityState {
2
+ OPEN = 0,
3
+ CLOSED = 1
4
+ }
@@ -0,0 +1,7 @@
1
+ local ____exports = {}
2
+ ____exports.StageTravelEntityState = {}
3
+ ____exports.StageTravelEntityState.OPEN = 0
4
+ ____exports.StageTravelEntityState[____exports.StageTravelEntityState.OPEN] = "OPEN"
5
+ ____exports.StageTravelEntityState.CLOSED = 1
6
+ ____exports.StageTravelEntityState[____exports.StageTravelEntityState.CLOSED] = "CLOSED"
7
+ return ____exports
@@ -0,0 +1,6 @@
1
+ export declare enum StageTravelState {
2
+ DISABLED = 0,
3
+ FADING_TO_BLACK = 1,
4
+ GOING_TO_NEW_FLOOR = 2,
5
+ FADING_IN = 3
6
+ }
@@ -0,0 +1,11 @@
1
+ local ____exports = {}
2
+ ____exports.StageTravelState = {}
3
+ ____exports.StageTravelState.DISABLED = 0
4
+ ____exports.StageTravelState[____exports.StageTravelState.DISABLED] = "DISABLED"
5
+ ____exports.StageTravelState.FADING_TO_BLACK = 1
6
+ ____exports.StageTravelState[____exports.StageTravelState.FADING_TO_BLACK] = "FADING_TO_BLACK"
7
+ ____exports.StageTravelState.GOING_TO_NEW_FLOOR = 2
8
+ ____exports.StageTravelState[____exports.StageTravelState.GOING_TO_NEW_FLOOR] = "GOING_TO_NEW_FLOOR"
9
+ ____exports.StageTravelState.FADING_IN = 3
10
+ ____exports.StageTravelState[____exports.StageTravelState.FADING_IN] = "FADING_IN"
11
+ return ____exports
@@ -28,8 +28,8 @@ local FEATURE_NAME = "get collectible item pool type"
28
28
  v = {run = {collectibleItemPoolTypeMap = __TS__New(Map)}}
29
29
  ---
30
30
  -- @internal
31
- function ____exports.getCollectibleItemPoolTypeInit(self, mod)
32
- saveDataManager(nil, "getCollectibleItemPoolType", v)
31
+ function ____exports.collectibleItemPoolTypeInit(self, mod)
32
+ saveDataManager(nil, "collectibleItemPoolType", v)
33
33
  mod:AddCallback(ModCallback.POST_PICKUP_INIT, postPickupInitCollectible, PickupVariant.COLLECTIBLE)
34
34
  end
35
35
  --- Helper function to get the item pool type that a given collectible came from. Since there is no
@@ -0,0 +1,5 @@
1
+ export declare const STAGE_TRAVEL_FEATURE_NAME = "stageTravel";
2
+ /** This also applies to crawl spaces. The value was determined through trial and error. */
3
+ export declare const TRAPDOOR_OPEN_DISTANCE = 60;
4
+ export declare const TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS: number;
5
+ export declare const TRAPDOOR_BOSS_REACTION_FRAMES = 30;
@@ -0,0 +1,7 @@
1
+ local ____exports = {}
2
+ ____exports.STAGE_TRAVEL_FEATURE_NAME = "stageTravel"
3
+ --- This also applies to crawl spaces. The value was determined through trial and error.
4
+ ____exports.TRAPDOOR_OPEN_DISTANCE = 60
5
+ ____exports.TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = ____exports.TRAPDOOR_OPEN_DISTANCE * 2.5
6
+ ____exports.TRAPDOOR_BOSS_REACTION_FRAMES = 30
7
+ return ____exports
@@ -0,0 +1,37 @@
1
+ import { LevelStage, StageType } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to spawn a trapdoor grid entity that will have one or more of the following
4
+ * attributes:
5
+ *
6
+ * - custom destination (or custom logic for after the player enters)
7
+ * - custom graphics
8
+ * - custom logic for opening/closing
9
+ * - TODO: animation
10
+ *
11
+ * You can use this function to take the player to your custom stage. (See the `registerCustomStage`
12
+ * helper function.)
13
+ *
14
+ * Under the hood, the custom trapdoor is represented by a decoration grid entity and is manually
15
+ * respawned every time the player re-enters the room.
16
+ *
17
+ * @param gridIndexOrPosition The location in the room to spawn the trapdoor.
18
+ * @param _destination Used to specify where the player will go after jumping into the trapdoor. Can
19
+ * either be a tuple containing the stage and stage type, a string containing
20
+ * the name of a custom stage, or a function that returns one of these things.
21
+ * You can also specify a function that returns undefined in order to perform
22
+ * some custom behavior and/or handle the traveling part yourself. By default,
23
+ * the destination will be set to the next floor like that of a vanilla
24
+ * trapdoor.
25
+ * @param _anm2 Optional. The path to the anm2 file to use. By default, the vanilla trapdoor anm2 of
26
+ * "gfx/grid/door_11_trapdoor.anm2" will be used.
27
+ * @param _shouldOpenFunc Optional. If the trapdoor is currently closed, this function will run on
28
+ * every frame to determine if it should open. By default, a function that
29
+ * emulates a vanilla trapdoor will be used.
30
+ * @param _shouldCloseFunc Optional. If the trapdoor is currently open, this function will run on
31
+ * every frame to determine if it should close. By default, a function that
32
+ * emulates a vanilla trapdoor will be used.
33
+ * @param _spawnOpen Optional. Whether or not to spawn the trapdoor in an open state. Can either be
34
+ * a boolean or a function returning a boolean. By default, a function that
35
+ * emulates a vanilla trapdoor will be used.
36
+ */
37
+ export declare function spawnCustomTrapdoor(gridIndexOrPosition: int | Vector, _destination?: [stage: LevelStage, stageType: StageType] | string | ((gridEntity: GridEntity) => [stage: LevelStage, stageType: StageType] | string | undefined), _anm2?: string, _shouldOpenFunc?: (gridEntity: GridEntity) => boolean, _shouldCloseFunc?: (gridEntity: GridEntity) => boolean, _spawnOpen?: boolean | ((gridEntity: GridEntity) => boolean)): GridEntity;
@@ -0,0 +1,120 @@
1
+ local ____exports = {}
2
+ local defaultDestinationFunc, defaultShouldOpenFunc, isPlayerCloseAfterBoss, shouldBeClosedFromStartingInRoomWithEnemies, defaultShouldCloseFunc, defaultShouldSpawnOpenFunc
3
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
+ local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
5
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
6
+ local ____cachedClasses = require("cachedClasses")
7
+ local game = ____cachedClasses.game
8
+ local ____gridEntity = require("functions.gridEntity")
9
+ local spawnGrid = ____gridEntity.spawnGrid
10
+ local ____nextStage = require("functions.nextStage")
11
+ local getNextStage = ____nextStage.getNextStage
12
+ local getNextStageType = ____nextStage.getNextStageType
13
+ local ____positionVelocity = require("functions.positionVelocity")
14
+ local anyPlayerCloserThan = ____positionVelocity.anyPlayerCloserThan
15
+ local ____roomClearFrame = require("features.roomClearFrame")
16
+ local getRoomClearGameFrame = ____roomClearFrame.getRoomClearGameFrame
17
+ local ____constants = require("features.customTrapdoor.constants")
18
+ local TRAPDOOR_BOSS_REACTION_FRAMES = ____constants.TRAPDOOR_BOSS_REACTION_FRAMES
19
+ local TRAPDOOR_OPEN_DISTANCE = ____constants.TRAPDOOR_OPEN_DISTANCE
20
+ local TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = ____constants.TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS
21
+ local ____v = require("features.customTrapdoor.v")
22
+ local getCustomTrapdoorDescription = ____v.getCustomTrapdoorDescription
23
+ function defaultDestinationFunc(self)
24
+ local nextStage = getNextStage(nil)
25
+ local nextStageType = getNextStageType(nil)
26
+ return {nextStage, nextStageType}
27
+ end
28
+ function defaultShouldOpenFunc(self, gridEntity)
29
+ local entityDescription = getCustomTrapdoorDescription(nil, gridEntity)
30
+ if entityDescription == nil then
31
+ return false
32
+ end
33
+ local room = game:GetRoom()
34
+ local roomClear = room:IsClear()
35
+ return not anyPlayerCloserThan(nil, gridEntity.Position, TRAPDOOR_OPEN_DISTANCE) and not isPlayerCloseAfterBoss(nil, gridEntity.Position) and not shouldBeClosedFromStartingInRoomWithEnemies(nil, entityDescription.initial, roomClear)
36
+ end
37
+ function isPlayerCloseAfterBoss(self, position)
38
+ local gameFrameCount = game:GetFrameCount()
39
+ local room = game:GetRoom()
40
+ local roomType = room:GetType()
41
+ local roomClearGameFrame = getRoomClearGameFrame(nil)
42
+ if roomType ~= RoomType.BOSS or roomClearGameFrame == nil or gameFrameCount >= roomClearGameFrame + TRAPDOOR_BOSS_REACTION_FRAMES then
43
+ return false
44
+ end
45
+ return anyPlayerCloserThan(nil, position, TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS)
46
+ end
47
+ function shouldBeClosedFromStartingInRoomWithEnemies(self, initial, roomClear)
48
+ return initial and not roomClear
49
+ end
50
+ function defaultShouldCloseFunc(self)
51
+ return false
52
+ end
53
+ function defaultShouldSpawnOpenFunc(self, gridEntity)
54
+ local room = game:GetRoom()
55
+ local roomFrameCount = room:GetFrameCount()
56
+ local roomClear = room:IsClear()
57
+ if roomFrameCount > 0 then
58
+ return false
59
+ end
60
+ if not roomClear then
61
+ return false
62
+ end
63
+ return defaultShouldOpenFunc(nil, gridEntity)
64
+ end
65
+ --- Helper function to spawn a trapdoor grid entity that will have one or more of the following
66
+ -- attributes:
67
+ --
68
+ -- - custom destination (or custom logic for after the player enters)
69
+ -- - custom graphics
70
+ -- - custom logic for opening/closing
71
+ -- - TODO: animation
72
+ --
73
+ -- You can use this function to take the player to your custom stage. (See the `registerCustomStage`
74
+ -- helper function.)
75
+ --
76
+ -- Under the hood, the custom trapdoor is represented by a decoration grid entity and is manually
77
+ -- respawned every time the player re-enters the room.
78
+ --
79
+ -- @param gridIndexOrPosition The location in the room to spawn the trapdoor.
80
+ -- @param _destination Used to specify where the player will go after jumping into the trapdoor. Can
81
+ -- either be a tuple containing the stage and stage type, a string containing
82
+ -- the name of a custom stage, or a function that returns one of these things.
83
+ -- You can also specify a function that returns undefined in order to perform
84
+ -- some custom behavior and/or handle the traveling part yourself. By default,
85
+ -- the destination will be set to the next floor like that of a vanilla
86
+ -- trapdoor.
87
+ -- @param _anm2 Optional. The path to the anm2 file to use. By default, the vanilla trapdoor anm2 of
88
+ -- "gfx/grid/door_11_trapdoor.anm2" will be used.
89
+ -- @param _shouldOpenFunc Optional. If the trapdoor is currently closed, this function will run on
90
+ -- every frame to determine if it should open. By default, a function that
91
+ -- emulates a vanilla trapdoor will be used.
92
+ -- @param _shouldCloseFunc Optional. If the trapdoor is currently open, this function will run on
93
+ -- every frame to determine if it should close. By default, a function that
94
+ -- emulates a vanilla trapdoor will be used.
95
+ -- @param _spawnOpen Optional. Whether or not to spawn the trapdoor in an open state. Can either be
96
+ -- a boolean or a function returning a boolean. By default, a function that
97
+ -- emulates a vanilla trapdoor will be used.
98
+ function ____exports.spawnCustomTrapdoor(self, gridIndexOrPosition, _destination, _anm2, _shouldOpenFunc, _shouldCloseFunc, _spawnOpen)
99
+ if _destination == nil then
100
+ _destination = defaultDestinationFunc
101
+ end
102
+ if _anm2 == nil then
103
+ _anm2 = "gfx/grid/door_11_trapdoor.anm2"
104
+ end
105
+ if _shouldOpenFunc == nil then
106
+ _shouldOpenFunc = defaultShouldOpenFunc
107
+ end
108
+ if _shouldCloseFunc == nil then
109
+ _shouldCloseFunc = defaultShouldCloseFunc
110
+ end
111
+ if _spawnOpen == nil then
112
+ _spawnOpen = defaultShouldSpawnOpenFunc
113
+ end
114
+ local decoration = spawnGrid(nil, GridEntityType.DECORATION, gridIndexOrPosition)
115
+ if decoration == nil then
116
+ error("Failed to spawn a custom trapdoor.")
117
+ end
118
+ return decoration
119
+ end
120
+ return ____exports
@@ -0,0 +1 @@
1
+ export declare function stageTravelInit(): void;
@@ -0,0 +1,11 @@
1
+ local ____exports = {}
2
+ local ____exports = require("features.saveDataManager.exports")
3
+ local saveDataManager = ____exports.saveDataManager
4
+ local ____constants = require("features.customTrapdoor.constants")
5
+ local STAGE_TRAVEL_FEATURE_NAME = ____constants.STAGE_TRAVEL_FEATURE_NAME
6
+ local ____v = require("features.customTrapdoor.v")
7
+ local v = ____v.default
8
+ function ____exports.stageTravelInit(self)
9
+ saveDataManager(nil, STAGE_TRAVEL_FEATURE_NAME, v)
10
+ end
11
+ return ____exports
@@ -0,0 +1,14 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ import { StageTravelState } from "../../enums/StageTravelState";
3
+ import { StageTravelEntityDescription } from "../../interfaces/StageTravelEntityDescription";
4
+ declare const v: {
5
+ run: {
6
+ state: StageTravelState;
7
+ };
8
+ room: {
9
+ /** Indexed by grid index. */
10
+ trapdoors: Map<number, StageTravelEntityDescription>;
11
+ };
12
+ };
13
+ export default v;
14
+ export declare function getCustomTrapdoorDescription(gridEntity: GridEntity): StageTravelEntityDescription | undefined;
@@ -0,0 +1,16 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local ____StageTravelState = require("enums.StageTravelState")
6
+ local StageTravelState = ____StageTravelState.StageTravelState
7
+ local v = {
8
+ run = {state = StageTravelState.DISABLED},
9
+ room = {trapdoors = __TS__New(Map)}
10
+ }
11
+ ____exports.default = v
12
+ function ____exports.getCustomTrapdoorDescription(self, gridEntity)
13
+ local gridIndex = gridEntity:GetGridIndex()
14
+ return v.room.trapdoors:get(gridIndex)
15
+ end
16
+ return ____exports
@@ -3,4 +3,9 @@
3
3
  * Helper function to see if the player is under the effects of A Pony or White Pony charge.
4
4
  * Detecting this is difficult, as the temporary effect will disappear upon entering a new room.
5
5
  */
6
- export declare function isPonyActive(player: EntityPlayer): boolean;
6
+ export declare function isPlayerUsingPony(player: EntityPlayer): boolean;
7
+ /**
8
+ * Helper function to see if any player is under the effects of A Pony or White Pony charge.
9
+ * Detecting this is difficult, as the temporary effect will disappear upon entering a new room.
10
+ */
11
+ export declare function anyPlayerUsingPony(): boolean;
@@ -1,6 +1,7 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
4
5
  local ____exports = {}
5
6
  local postPEffectUpdateReordered, FLAGS_WHEN_PONY_IS_ACTIVE, v
6
7
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
@@ -16,6 +17,8 @@ local ____playerDataStructures = require("functions.playerDataStructures")
16
17
  local setAddPlayer = ____playerDataStructures.setAddPlayer
17
18
  local setDeletePlayer = ____playerDataStructures.setDeletePlayer
18
19
  local setHasPlayer = ____playerDataStructures.setHasPlayer
20
+ local ____playerIndex = require("functions.playerIndex")
21
+ local getPlayers = ____playerIndex.getPlayers
19
22
  local ____exports = require("features.saveDataManager.exports")
20
23
  local saveDataManager = ____exports.saveDataManager
21
24
  function postPEffectUpdateReordered(self, player)
@@ -46,8 +49,18 @@ function ____exports.ponyDetectionInit(self, mod)
46
49
  end
47
50
  --- Helper function to see if the player is under the effects of A Pony or White Pony charge.
48
51
  -- Detecting this is difficult, as the temporary effect will disappear upon entering a new room.
49
- function ____exports.isPonyActive(self, player)
52
+ function ____exports.isPlayerUsingPony(self, player)
50
53
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
51
54
  return setHasPlayer(nil, v.run.playersIsPonyActive, player)
52
55
  end
56
+ --- Helper function to see if any player is under the effects of A Pony or White Pony charge.
57
+ -- Detecting this is difficult, as the temporary effect will disappear upon entering a new room.
58
+ function ____exports.anyPlayerUsingPony(self)
59
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
60
+ local players = getPlayers(nil)
61
+ return __TS__ArraySome(
62
+ players,
63
+ function(____, player) return ____exports.isPlayerUsingPony(nil, player) end
64
+ )
65
+ end
53
66
  return ____exports
@@ -0,0 +1,11 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to get the game frame (i.e. `Game.GetFrameCount`) of the last time that this room
4
+ * was cleared. Returns undefined if the room has never been cleared.
5
+ */
6
+ export declare function getRoomClearGameFrame(): int | undefined;
7
+ /**
8
+ * Helper function to get the room frame (i.e. `Room.GetFrameCount`) of the last time that this room
9
+ * was cleared. Returns undefined if the room has never been cleared.
10
+ */
11
+ export declare function getRoomClearRoomFrame(): int | undefined;
@@ -0,0 +1,38 @@
1
+ local ____exports = {}
2
+ local postRoomClearChangedTrue, v
3
+ local ____cachedClasses = require("cachedClasses")
4
+ local game = ____cachedClasses.game
5
+ local ____ModCallbackCustom = require("enums.ModCallbackCustom")
6
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
7
+ local ____featuresInitialized = require("featuresInitialized")
8
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
9
+ local ____exports = require("features.saveDataManager.exports")
10
+ local saveDataManager = ____exports.saveDataManager
11
+ function postRoomClearChangedTrue(self)
12
+ local gameFrameCount = game:GetFrameCount()
13
+ local room = game:GetRoom()
14
+ local roomFrameCount = room:GetFrameCount()
15
+ v.room.roomClearGameFrame = gameFrameCount
16
+ v.room.roomClearRoomFrame = roomFrameCount
17
+ end
18
+ local FEATURE_NAME = "room clear frame"
19
+ v = {room = {roomClearGameFrame = nil, roomClearRoomFrame = nil}}
20
+ ---
21
+ -- @internal
22
+ function ____exports.roomClearFrameInit(self, mod)
23
+ saveDataManager(nil, "roomClearFrame", v)
24
+ mod:AddCallbackCustom(ModCallbackCustom.POST_ROOM_CLEAR_CHANGED, postRoomClearChangedTrue, true)
25
+ end
26
+ --- Helper function to get the game frame (i.e. `Game.GetFrameCount`) of the last time that this room
27
+ -- was cleared. Returns undefined if the room has never been cleared.
28
+ function ____exports.getRoomClearGameFrame(self)
29
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
30
+ return v.room.roomClearGameFrame
31
+ end
32
+ --- Helper function to get the room frame (i.e. `Room.GetFrameCount`) of the last time that this room
33
+ -- was cleared. Returns undefined if the room has never been cleared.
34
+ function ____exports.getRoomClearRoomFrame(self)
35
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
36
+ return v.room.roomClearGameFrame
37
+ end
38
+ return ____exports
@@ -0,0 +1,15 @@
1
+ import { LevelStage, StageType } from "isaac-typescript-definitions";
2
+ /** Helper function to get all of the stages that a player has visited thus far on this run. */
3
+ export declare function getStageHistory(): ReadonlyArray<[
4
+ stage: LevelStage,
5
+ stageType: StageType
6
+ ]>;
7
+ /**
8
+ * Helper function to check if a player has previous visited a particular stage (or stage + stage
9
+ * type combination) on this run.
10
+ *
11
+ * @param stage The stage to check for.
12
+ * @param stageType Optional. If provided, will check for a specific stage and stage type
13
+ * combination.
14
+ */
15
+ export declare function hasVisitedStage(stage: LevelStage, stageType?: StageType): boolean;
@@ -0,0 +1,62 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
3
+ local ____exports = {}
4
+ local postNewLevelReordered, v
5
+ local ____cachedClasses = require("cachedClasses")
6
+ local game = ____cachedClasses.game
7
+ local ____ModCallbackCustom = require("enums.ModCallbackCustom")
8
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
9
+ local ____featuresInitialized = require("featuresInitialized")
10
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
11
+ local ____exports = require("features.saveDataManager.exports")
12
+ local saveDataManager = ____exports.saveDataManager
13
+ function postNewLevelReordered(self)
14
+ local level = game:GetLevel()
15
+ local stage = level:GetStage()
16
+ local stageType = level:GetStageType()
17
+ local ____v_run_stageHistory_0 = v.run.stageHistory
18
+ ____v_run_stageHistory_0[#____v_run_stageHistory_0 + 1] = {stage, stageType}
19
+ end
20
+ local FEATURE_NAME = "stage history"
21
+ v = {run = {stageHistory = {}}}
22
+ ---
23
+ -- @internal
24
+ function ____exports.stageHistoryInit(self, mod)
25
+ saveDataManager(nil, "stageHistory", v)
26
+ mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_LEVEL_REORDERED, postNewLevelReordered)
27
+ end
28
+ --- Helper function to get all of the stages that a player has visited thus far on this run.
29
+ function ____exports.getStageHistory(self)
30
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
31
+ return v.run.stageHistory
32
+ end
33
+ --- Helper function to check if a player has previous visited a particular stage (or stage + stage
34
+ -- type combination) on this run.
35
+ --
36
+ -- @param stage The stage to check for.
37
+ -- @param stageType Optional. If provided, will check for a specific stage and stage type
38
+ -- combination.
39
+ function ____exports.hasVisitedStage(self, stage, stageType)
40
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
41
+ if stageType == nil then
42
+ return __TS__ArraySome(
43
+ v.run.stageHistory,
44
+ function(____, ____bindingPattern0)
45
+ local previousStage
46
+ previousStage = ____bindingPattern0[1]
47
+ return previousStage == stage
48
+ end
49
+ )
50
+ end
51
+ return __TS__ArraySome(
52
+ v.run.stageHistory,
53
+ function(____, ____bindingPattern0)
54
+ local previousStageType
55
+ local previousStage
56
+ previousStage = ____bindingPattern0[1]
57
+ previousStageType = ____bindingPattern0[2]
58
+ return previousStage == stage and previousStageType == stageType
59
+ end
60
+ )
61
+ end
62
+ return ____exports
@@ -48,6 +48,11 @@ export declare function getGridEntities(...gridEntityTypes: GridEntityType[]): G
48
48
  export declare function getGridEntitiesMap(...gridEntityTypes: GridEntityType[]): Map<int, GridEntity>;
49
49
  /** Helper function to return a string containing the grid entity's type and variant. */
50
50
  export declare function getGridEntityID(gridEntity: GridEntity): string;
51
+ /**
52
+ * Helper function to get all of the grid entities in the room that specifically match the type and
53
+ * variant provided.
54
+ */
55
+ export declare function getMatchingGridEntities(gridEntityType: GridEntityType, variant: int): GridEntity[];
51
56
  export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
52
57
  export declare function getTopLeftWall(): GridEntity | undefined;
53
58
  /**
@@ -214,6 +214,15 @@ function ____exports.getGridEntityID(self, gridEntity)
214
214
  local gridEntityVariant = gridEntity:GetVariant()
215
215
  return (tostring(gridEntityType) .. ".") .. tostring(gridEntityVariant)
216
216
  end
217
+ --- Helper function to get all of the grid entities in the room that specifically match the type and
218
+ -- variant provided.
219
+ function ____exports.getMatchingGridEntities(self, gridEntityType, variant)
220
+ local gridEntities = ____exports.getGridEntities(nil, gridEntityType)
221
+ return __TS__ArrayFilter(
222
+ gridEntities,
223
+ function(____, gridEntity) return gridEntity:GetVariant() == variant end
224
+ )
225
+ end
217
226
  function ____exports.getSurroundingGridEntities(self, gridEntity)
218
227
  local room = game:GetRoom()
219
228
  local gridWidth = room:GetGridWidth()
@@ -1,9 +1,9 @@
1
- /// <reference types="isaac-typescript-definitions" />
2
- /// <reference types="isaac-typescript-definitions" />
3
- /// <reference types="isaac-typescript-definitions" />
4
- /// <reference types="isaac-typescript-definitions" />
5
- /// <reference types="isaac-typescript-definitions" />
6
- /// <reference types="isaac-typescript-definitions" />
1
+ import { CrawlSpaceState, TrapdoorVariant } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
4
+ * Specify a specific trapdoor variant to select only trapdoors of that variant.
5
+ */
6
+ export declare function getCrawlSpaces(crawlSpaceVariant?: CrawlSpaceState): GridEntity[];
7
7
  /** Helper function to get all of the `GridEntityPit` in the room. */
8
8
  export declare function getPits(): GridEntityPit[];
9
9
  /** Helper function to get all of the `GridEntityPoop` in the room. */
@@ -16,6 +16,11 @@ export declare function getRocks(): GridEntityRock[];
16
16
  export declare function getSpikes(): GridEntitySpikes[];
17
17
  /** Helper function to get all of the `GridEntityTNT` in the room. */
18
18
  export declare function getTNT(): GridEntityTNT[];
19
+ /**
20
+ * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
21
+ * Specify a specific trapdoor variant to select only trapdoors of that variant.
22
+ */
23
+ export declare function getTrapdoors(trapdoorVariant?: TrapdoorVariant): GridEntity[];
19
24
  /**
20
25
  * Helper function to determine if all of the pressure plates in the current room are pushed.
21
26
  * Returns true if there are no pressure plates in the room.
@@ -2,11 +2,21 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
3
3
  local ____exports = {}
4
4
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
5
+ local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
5
6
  local PressurePlateState = ____isaac_2Dtypescript_2Ddefinitions.PressurePlateState
6
7
  local ____cachedClasses = require("cachedClasses")
7
8
  local game = ____cachedClasses.game
8
9
  local ____gridEntity = require("functions.gridEntity")
9
10
  local getGridEntities = ____gridEntity.getGridEntities
11
+ local getMatchingGridEntities = ____gridEntity.getMatchingGridEntities
12
+ --- Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
13
+ -- Specify a specific trapdoor variant to select only trapdoors of that variant.
14
+ function ____exports.getCrawlSpaces(self, crawlSpaceVariant)
15
+ if crawlSpaceVariant == nil then
16
+ return getGridEntities(nil, GridEntityType.CRAWL_SPACE)
17
+ end
18
+ return getMatchingGridEntities(nil, GridEntityType.CRAWL_SPACE, crawlSpaceVariant)
19
+ end
10
20
  --- Helper function to get all of the `GridEntityPit` in the room.
11
21
  function ____exports.getPits(self)
12
22
  local gridEntities = getGridEntities(nil)
@@ -79,6 +89,14 @@ function ____exports.getTNT(self)
79
89
  end
80
90
  return tntArray
81
91
  end
92
+ --- Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
93
+ -- Specify a specific trapdoor variant to select only trapdoors of that variant.
94
+ function ____exports.getTrapdoors(self, trapdoorVariant)
95
+ if trapdoorVariant == nil then
96
+ return getGridEntities(nil, GridEntityType.TRAPDOOR)
97
+ end
98
+ return getMatchingGridEntities(nil, GridEntityType.TRAPDOOR, trapdoorVariant)
99
+ end
82
100
  --- Helper function to determine if all of the pressure plates in the current room are pushed.
83
101
  -- Returns true if there are no pressure plates in the room.
84
102
  function ____exports.isAllPressurePlatesPushed(self)
package/functions/log.lua CHANGED
@@ -14,6 +14,7 @@ local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
14
14
  local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
15
15
  local GameStateFlag = ____isaac_2Dtypescript_2Ddefinitions.GameStateFlag
16
16
  local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
17
+ local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
17
18
  local LevelStateFlag = ____isaac_2Dtypescript_2Ddefinitions.LevelStateFlag
18
19
  local ProjectileFlag = ____isaac_2Dtypescript_2Ddefinitions.ProjectileFlag
19
20
  local SeedEffect = ____isaac_2Dtypescript_2Ddefinitions.SeedEffect
@@ -412,7 +413,12 @@ function ____exports.logRoom()
412
413
  ____exports.log((((("Current room type/variant/sub-type: " .. tostring(roomData.Type)) .. ".") .. tostring(roomData.Variant)) .. ".") .. tostring(roomData.Subtype))
413
414
  ____exports.log("Current room name: " .. roomData.Name)
414
415
  end
415
- ____exports.log("Current room grid index: " .. tostring(roomGridIndex))
416
+ local roomGridIndexName = GridRoom[roomGridIndex]
417
+ if roomGridIndexName == nil then
418
+ ____exports.log("Current room grid index: " .. tostring(roomGridIndex))
419
+ else
420
+ ____exports.log(((("Current room grid index: " .. tostring(roomGridIndex)) .. " (GridRoom.") .. roomGridIndexName) .. ")")
421
+ end
416
422
  ____exports.log("Current room list index: " .. tostring(roomListIndex))
417
423
  end
418
424
  --- Helper function for printing out every seed effect (i.e. Easter Egg) that is turned on for the
@@ -0,0 +1,18 @@
1
+ import { LevelStage, StageType } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to get the stage that a trapdoor or heaven door would take the player to, based
4
+ * on the current stage, room, and game state flags.
5
+ *
6
+ * Note that in non-upgraded mods, this function will not account for the player having visited
7
+ * Repentance floors in The Ascent. (Handling this requires stateful tracking as the player
8
+ * progresses through the run.)
9
+ */
10
+ export declare function getNextStage(): LevelStage;
11
+ /**
12
+ * Helper function to get the stage type that a trapdoor or heaven door would take the player to,
13
+ * based on the current stage, room, and game state flags.
14
+ *
15
+ * @param upwards Whether or not the player should go up to Cathedral in the case of being on Womb
16
+ * 2. Defaults to false.
17
+ */
18
+ export declare function getNextStageType(upwards?: boolean): StageType;
@@ -0,0 +1,245 @@
1
+ local ____exports = {}
2
+ local getNextStageBackwardsPath, getStageTypeBackwardsPath
3
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
+ local GameStateFlag = ____isaac_2Dtypescript_2Ddefinitions.GameStateFlag
5
+ local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
6
+ local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
7
+ local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
8
+ local ____cachedClasses = require("cachedClasses")
9
+ local game = ____cachedClasses.game
10
+ local ____stageHistory = require("features.stageHistory")
11
+ local hasVisitedStage = ____stageHistory.hasVisitedStage
12
+ local ____featuresInitialized = require("featuresInitialized")
13
+ local areFeaturesInitialized = ____featuresInitialized.areFeaturesInitialized
14
+ local ____roomData = require("functions.roomData")
15
+ local getRoomGridIndex = ____roomData.getRoomGridIndex
16
+ local ____stage = require("functions.stage")
17
+ local calculateStageType = ____stage.calculateStageType
18
+ local calculateStageTypeRepentance = ____stage.calculateStageTypeRepentance
19
+ local onRepentanceStage = ____stage.onRepentanceStage
20
+ function getNextStageBackwardsPath(self, stage, repentanceStage)
21
+ if not areFeaturesInitialized(nil) then
22
+ return stage - 1
23
+ end
24
+ local visitedDownpour1 = hasVisitedStage(nil, LevelStage.BASEMENT_1, StageType.REPENTANCE)
25
+ local visitedDross1 = hasVisitedStage(nil, LevelStage.BASEMENT_1, StageType.REPENTANCE_B)
26
+ local visitedDownpour2 = hasVisitedStage(nil, LevelStage.BASEMENT_2, StageType.REPENTANCE)
27
+ local visitedDross2 = hasVisitedStage(nil, LevelStage.BASEMENT_2, StageType.REPENTANCE_B)
28
+ local visitedMines1 = hasVisitedStage(nil, LevelStage.CAVES_1, StageType.REPENTANCE)
29
+ local visitedAshpit1 = hasVisitedStage(nil, LevelStage.CAVES_1, StageType.REPENTANCE_B)
30
+ local visitedMines2 = hasVisitedStage(nil, LevelStage.DEPTHS_2, StageType.REPENTANCE)
31
+ local visitedAshpit2 = hasVisitedStage(nil, LevelStage.DEPTHS_2, StageType.REPENTANCE_B)
32
+ if stage == LevelStage.BASEMENT_1 then
33
+ if repentanceStage then
34
+ return LevelStage.BASEMENT_1
35
+ end
36
+ return LevelStage.HOME
37
+ end
38
+ if stage == LevelStage.BASEMENT_2 then
39
+ if repentanceStage then
40
+ if visitedDownpour1 or visitedDross1 then
41
+ return LevelStage.BASEMENT_1
42
+ end
43
+ return LevelStage.BASEMENT_2
44
+ end
45
+ return LevelStage.BASEMENT_1
46
+ end
47
+ if stage == LevelStage.CAVES_1 then
48
+ if repentanceStage then
49
+ if visitedDownpour2 or visitedDross2 then
50
+ return LevelStage.BASEMENT_2
51
+ end
52
+ return LevelStage.CAVES_1
53
+ end
54
+ return LevelStage.BASEMENT_2
55
+ end
56
+ if stage == LevelStage.CAVES_2 then
57
+ if repentanceStage then
58
+ if visitedMines1 or visitedAshpit1 then
59
+ return LevelStage.CAVES_1
60
+ end
61
+ return LevelStage.CAVES_2
62
+ end
63
+ return LevelStage.CAVES_1
64
+ end
65
+ if stage == LevelStage.DEPTHS_1 then
66
+ if repentanceStage then
67
+ if visitedMines2 or visitedAshpit2 then
68
+ return LevelStage.CAVES_2
69
+ end
70
+ return LevelStage.DEPTHS_1
71
+ end
72
+ return LevelStage.CAVES_2
73
+ end
74
+ if stage == LevelStage.DEPTHS_2 then
75
+ if repentanceStage then
76
+ return LevelStage.DEPTHS_2
77
+ end
78
+ return LevelStage.DEPTHS_1
79
+ end
80
+ return stage - 1
81
+ end
82
+ function getStageTypeBackwardsPath(self, stage, nextStage, repentanceStage)
83
+ local visitedDownpour1 = hasVisitedStage(nil, LevelStage.BASEMENT_1, StageType.REPENTANCE)
84
+ local visitedDross1 = hasVisitedStage(nil, LevelStage.BASEMENT_1, StageType.REPENTANCE_B)
85
+ local visitedDownpour2 = hasVisitedStage(nil, LevelStage.BASEMENT_2, StageType.REPENTANCE)
86
+ local visitedDross2 = hasVisitedStage(nil, LevelStage.BASEMENT_2, StageType.REPENTANCE_B)
87
+ local visitedMines1 = hasVisitedStage(nil, LevelStage.CAVES_1, StageType.REPENTANCE)
88
+ local visitedAshpit1 = hasVisitedStage(nil, LevelStage.CAVES_1, StageType.REPENTANCE_B)
89
+ local visitedMines2 = hasVisitedStage(nil, LevelStage.DEPTHS_2, StageType.REPENTANCE)
90
+ local visitedAshpit2 = hasVisitedStage(nil, LevelStage.DEPTHS_2, StageType.REPENTANCE_B)
91
+ if stage == LevelStage.BASEMENT_2 and repentanceStage then
92
+ if visitedDownpour1 then
93
+ return StageType.REPENTANCE
94
+ end
95
+ if visitedDross1 then
96
+ return StageType.REPENTANCE_B
97
+ end
98
+ end
99
+ if stage == LevelStage.CAVES_1 and repentanceStage then
100
+ if visitedDownpour2 then
101
+ return StageType.REPENTANCE
102
+ end
103
+ if visitedDross2 then
104
+ return StageType.REPENTANCE_B
105
+ end
106
+ end
107
+ if stage == LevelStage.CAVES_2 and not repentanceStage then
108
+ if visitedDownpour2 then
109
+ return StageType.REPENTANCE
110
+ end
111
+ if visitedDross2 then
112
+ return StageType.REPENTANCE_B
113
+ end
114
+ end
115
+ if stage == LevelStage.CAVES_2 and repentanceStage then
116
+ if visitedMines1 then
117
+ return StageType.REPENTANCE
118
+ end
119
+ if visitedAshpit1 then
120
+ return StageType.REPENTANCE_B
121
+ end
122
+ end
123
+ if stage == LevelStage.DEPTHS_2 and not repentanceStage then
124
+ if visitedAshpit2 then
125
+ return StageType.REPENTANCE_B
126
+ end
127
+ if visitedMines2 then
128
+ return StageType.REPENTANCE
129
+ end
130
+ end
131
+ return calculateStageType(nil, nextStage)
132
+ end
133
+ --- Helper function to get the stage that a trapdoor or heaven door would take the player to, based
134
+ -- on the current stage, room, and game state flags.
135
+ --
136
+ -- Note that in non-upgraded mods, this function will not account for the player having visited
137
+ -- Repentance floors in The Ascent. (Handling this requires stateful tracking as the player
138
+ -- progresses through the run.)
139
+ function ____exports.getNextStage(self)
140
+ local level = game:GetLevel()
141
+ local backwardsPath = game:GetStateFlag(GameStateFlag.BACKWARDS_PATH)
142
+ local mausoleumHeartKilled = game:GetStateFlag(GameStateFlag.MAUSOLEUM_HEART_KILLED)
143
+ local stage = level:GetStage()
144
+ local repentanceStage = onRepentanceStage(nil)
145
+ local roomGridIndex = getRoomGridIndex(nil)
146
+ if backwardsPath then
147
+ return getNextStageBackwardsPath(nil, stage, repentanceStage)
148
+ end
149
+ repeat
150
+ local ____switch4 = roomGridIndex
151
+ local ____cond4 = ____switch4 == GridRoom.BLUE_WOMB
152
+ if ____cond4 then
153
+ do
154
+ return LevelStage.BLUE_WOMB
155
+ end
156
+ end
157
+ ____cond4 = ____cond4 or ____switch4 == GridRoom.THE_VOID
158
+ if ____cond4 then
159
+ do
160
+ return LevelStage.THE_VOID
161
+ end
162
+ end
163
+ ____cond4 = ____cond4 or ____switch4 == GridRoom.SECRET_EXIT
164
+ if ____cond4 then
165
+ do
166
+ if repentanceStage then
167
+ return stage + 1
168
+ end
169
+ if stage == LevelStage.DEPTHS_2 then
170
+ return LevelStage.DEPTHS_2
171
+ end
172
+ return stage
173
+ end
174
+ end
175
+ until true
176
+ if repentanceStage and stage == LevelStage.BASEMENT_2 then
177
+ return LevelStage.CAVES_2
178
+ end
179
+ if repentanceStage and stage == LevelStage.CAVES_2 then
180
+ return LevelStage.DEPTHS_2
181
+ end
182
+ if repentanceStage and stage == LevelStage.DEPTHS_2 then
183
+ if mausoleumHeartKilled then
184
+ return LevelStage.WOMB_1
185
+ end
186
+ return LevelStage.WOMB_2
187
+ end
188
+ if stage == LevelStage.WOMB_2 then
189
+ return LevelStage.SHEOL_CATHEDRAL
190
+ end
191
+ if stage == LevelStage.DARK_ROOM_CHEST then
192
+ return LevelStage.DARK_ROOM_CHEST
193
+ end
194
+ if stage == LevelStage.THE_VOID then
195
+ return LevelStage.THE_VOID
196
+ end
197
+ return stage + 1
198
+ end
199
+ --- Helper function to get the stage type that a trapdoor or heaven door would take the player to,
200
+ -- based on the current stage, room, and game state flags.
201
+ --
202
+ -- @param upwards Whether or not the player should go up to Cathedral in the case of being on Womb
203
+ -- 2. Defaults to false.
204
+ function ____exports.getNextStageType(self, upwards)
205
+ if upwards == nil then
206
+ upwards = false
207
+ end
208
+ local backwardsPath = game:GetStateFlag(GameStateFlag.BACKWARDS_PATH)
209
+ local mausoleumHeartKilled = game:GetStateFlag(GameStateFlag.MAUSOLEUM_HEART_KILLED)
210
+ local level = game:GetLevel()
211
+ local stage = level:GetStage()
212
+ local stageType = level:GetStageType()
213
+ local repentanceStage = onRepentanceStage(nil)
214
+ local roomGridIndex = getRoomGridIndex(nil)
215
+ local nextStage = ____exports.getNextStage(nil)
216
+ if backwardsPath then
217
+ return getStageTypeBackwardsPath(nil, stage, nextStage, repentanceStage)
218
+ end
219
+ if roomGridIndex == GridRoom.SECRET_EXIT then
220
+ return calculateStageTypeRepentance(nil, nextStage)
221
+ end
222
+ if repentanceStage and (stage == LevelStage.BASEMENT_1 or stage == LevelStage.CAVES_1 or stage == LevelStage.DEPTHS_1 or stage == LevelStage.WOMB_1) then
223
+ return calculateStageTypeRepentance(nil, nextStage)
224
+ end
225
+ if repentanceStage and stage == LevelStage.DEPTHS_2 and mausoleumHeartKilled then
226
+ return calculateStageTypeRepentance(nil, nextStage)
227
+ end
228
+ if nextStage == LevelStage.BLUE_WOMB then
229
+ return StageType.ORIGINAL
230
+ end
231
+ if nextStage == LevelStage.SHEOL_CATHEDRAL then
232
+ if upwards then
233
+ return StageType.WRATH_OF_THE_LAMB
234
+ end
235
+ return StageType.ORIGINAL
236
+ end
237
+ if nextStage == LevelStage.DARK_ROOM_CHEST then
238
+ if stageType == StageType.ORIGINAL then
239
+ return StageType.ORIGINAL
240
+ end
241
+ return StageType.WRATH_OF_THE_LAMB
242
+ end
243
+ return calculateStageType(nil, nextStage)
244
+ end
245
+ return ____exports
@@ -1,4 +1,14 @@
1
1
  import { LevelStage, StageType } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function that calculates what the stage type should be for the provided stage. This
4
+ * emulates what the game's internal code does.
5
+ */
6
+ export declare function calculateStageType(stage: LevelStage): StageType;
7
+ /**
8
+ * Helper function that calculates what the Repentance stage type should be for the provided stage.
9
+ * This emulates what the game's internal code does.
10
+ */
11
+ export declare function calculateStageTypeRepentance(stage: LevelStage): StageType;
2
12
  /**
3
13
  * Helper function to account for Repentance floors being offset by 1. For example, Downpour 2 is
4
14
  * the third level of the run, but the game considers it to have a stage of 2. This function will
@@ -21,6 +21,34 @@ end
21
21
  function ____exports.stageTypeToLetter(self, stageType)
22
22
  return STAGE_TYPE_TO_LETTER[stageType]
23
23
  end
24
+ --- Helper function that calculates what the stage type should be for the provided stage. This
25
+ -- emulates what the game's internal code does.
26
+ function ____exports.calculateStageType(self, stage)
27
+ local seeds = game:GetSeeds()
28
+ local stageSeed = seeds:GetStageSeed(stage)
29
+ if stageSeed % 2 == 0 then
30
+ return StageType.WRATH_OF_THE_LAMB
31
+ end
32
+ if stageSeed % 3 == 0 then
33
+ return StageType.AFTERBIRTH
34
+ end
35
+ return StageType.ORIGINAL
36
+ end
37
+ --- Helper function that calculates what the Repentance stage type should be for the provided stage.
38
+ -- This emulates what the game's internal code does.
39
+ function ____exports.calculateStageTypeRepentance(self, stage)
40
+ if stage == LevelStage.WOMB_1 or stage == LevelStage.WOMB_2 then
41
+ return StageType.REPENTANCE
42
+ end
43
+ local seeds = game:GetSeeds()
44
+ local adjustedStage = stage + 1
45
+ local stageSeed = seeds:GetStageSeed(adjustedStage)
46
+ local halfStageSeed = math.floor(stageSeed / 2)
47
+ if halfStageSeed % 2 == 0 then
48
+ return StageType.REPENTANCE_B
49
+ end
50
+ return StageType.REPENTANCE
51
+ end
24
52
  --- Helper function to account for Repentance floors being offset by 1. For example, Downpour 2 is
25
53
  -- the third level of the run, but the game considers it to have a stage of 2. This function will
26
54
  -- consider Downpour 2 to have a stage of 3.
package/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export * from "./enums/PocketItemType";
11
11
  export * from "./enums/SerializationType";
12
12
  export { ConversionHeartSubType, registerCharacterHealthConversion, } from "./features/characterHealthConversion";
13
13
  export { registerCharacterStats } from "./features/characterStats";
14
+ export { getCollectibleItemPoolType } from "./features/collectibleItemPoolType";
15
+ export * from "./features/customTrapdoor/exports";
14
16
  export * from "./features/debugDisplay/exports";
15
17
  export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/deployJSONRoom";
16
18
  export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
@@ -19,14 +21,15 @@ export { addConsoleCommand, enableExtraConsoleCommands, removeConsoleCommand, }
19
21
  export { removeFadeIn, restoreFadeIn } from "./features/fadeInRemover";
20
22
  export { disableFastReset, enableFastReset } from "./features/fastReset";
21
23
  export { forgottenSwitch } from "./features/forgottenSwitch";
22
- export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
23
24
  export { removePersistentEntity, spawnPersistentEntity, } from "./features/persistentEntities";
24
25
  export { getPlayerInventory } from "./features/playerInventory";
25
- export * from "./features/ponyDetection";
26
+ export { anyPlayerUsingPony, isPlayerUsingPony as isPonyActive, } from "./features/ponyDetection";
26
27
  export { preventCollectibleRotation } from "./features/preventCollectibleRotation";
28
+ export { getRoomClearGameFrame, getRoomClearRoomFrame, } from "./features/roomClearFrame";
27
29
  export { runInNGameFrames, runInNRenderFrames, runNextGameFrame, runNextRenderFrame, } from "./features/runInNFrames";
28
30
  export * from "./features/saveDataManager/exports";
29
31
  export { hasSirenStolenFamiliar, setFamiliarNoSirenSteal, } from "./features/sirenHelpers";
32
+ export { getStageHistory, hasVisitedStage } from "./features/stageHistory";
30
33
  export { getTaintedLazarusSubPlayer } from "./features/taintedLazarusPlayers";
31
34
  export * from "./functions/ambush";
32
35
  export * from "./functions/array";
@@ -46,8 +49,8 @@ export * from "./functions/collectibleSet";
46
49
  export * from "./functions/collectibleTag";
47
50
  export * from "./functions/color";
48
51
  export * from "./functions/debug";
49
- export { deepCopy } from "./functions/deepCopy";
50
- export { deepCopyTests } from "./functions/deepCopyTests";
52
+ export * from "./functions/deepCopy";
53
+ export * from "./functions/deepCopyTests";
51
54
  export * from "./functions/direction";
52
55
  export * from "./functions/doors";
53
56
  export * from "./functions/easing";
@@ -73,7 +76,7 @@ export * from "./functions/level";
73
76
  export * from "./functions/log";
74
77
  export * from "./functions/map";
75
78
  export * from "./functions/math";
76
- export { mergeTests } from "./functions/mergeTests";
79
+ export * from "./functions/mergeTests";
77
80
  export * from "./functions/npc";
78
81
  export * from "./functions/pickups";
79
82
  export * from "./functions/pickupVariants";
package/index.lua CHANGED
@@ -95,6 +95,19 @@ do
95
95
  local registerCharacterStats = ____characterStats.registerCharacterStats
96
96
  ____exports.registerCharacterStats = registerCharacterStats
97
97
  end
98
+ do
99
+ local ____collectibleItemPoolType = require("features.collectibleItemPoolType")
100
+ local getCollectibleItemPoolType = ____collectibleItemPoolType.getCollectibleItemPoolType
101
+ ____exports.getCollectibleItemPoolType = getCollectibleItemPoolType
102
+ end
103
+ do
104
+ local ____export = require("features.customTrapdoor.exports")
105
+ for ____exportKey, ____exportValue in pairs(____export) do
106
+ if ____exportKey ~= "default" then
107
+ ____exports[____exportKey] = ____exportValue
108
+ end
109
+ end
110
+ end
98
111
  do
99
112
  local ____export = require("features.debugDisplay.exports")
100
113
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -162,11 +175,6 @@ do
162
175
  local forgottenSwitch = ____forgottenSwitch.forgottenSwitch
163
176
  ____exports.forgottenSwitch = forgottenSwitch
164
177
  end
165
- do
166
- local ____getCollectibleItemPoolType = require("features.getCollectibleItemPoolType")
167
- local getCollectibleItemPoolType = ____getCollectibleItemPoolType.getCollectibleItemPoolType
168
- ____exports.getCollectibleItemPoolType = getCollectibleItemPoolType
169
- end
170
178
  do
171
179
  local ____persistentEntities = require("features.persistentEntities")
172
180
  local removePersistentEntity = ____persistentEntities.removePersistentEntity
@@ -180,18 +188,24 @@ do
180
188
  ____exports.getPlayerInventory = getPlayerInventory
181
189
  end
182
190
  do
183
- local ____export = require("features.ponyDetection")
184
- for ____exportKey, ____exportValue in pairs(____export) do
185
- if ____exportKey ~= "default" then
186
- ____exports[____exportKey] = ____exportValue
187
- end
188
- end
191
+ local ____ponyDetection = require("features.ponyDetection")
192
+ local anyPlayerUsingPony = ____ponyDetection.anyPlayerUsingPony
193
+ local isPonyActive = ____ponyDetection.isPlayerUsingPony
194
+ ____exports.anyPlayerUsingPony = anyPlayerUsingPony
195
+ ____exports.isPonyActive = isPonyActive
189
196
  end
190
197
  do
191
198
  local ____preventCollectibleRotation = require("features.preventCollectibleRotation")
192
199
  local preventCollectibleRotation = ____preventCollectibleRotation.preventCollectibleRotation
193
200
  ____exports.preventCollectibleRotation = preventCollectibleRotation
194
201
  end
202
+ do
203
+ local ____roomClearFrame = require("features.roomClearFrame")
204
+ local getRoomClearGameFrame = ____roomClearFrame.getRoomClearGameFrame
205
+ local getRoomClearRoomFrame = ____roomClearFrame.getRoomClearRoomFrame
206
+ ____exports.getRoomClearGameFrame = getRoomClearGameFrame
207
+ ____exports.getRoomClearRoomFrame = getRoomClearRoomFrame
208
+ end
195
209
  do
196
210
  local ____runInNFrames = require("features.runInNFrames")
197
211
  local runInNGameFrames = ____runInNFrames.runInNGameFrames
@@ -218,6 +232,13 @@ do
218
232
  ____exports.hasSirenStolenFamiliar = hasSirenStolenFamiliar
219
233
  ____exports.setFamiliarNoSirenSteal = setFamiliarNoSirenSteal
220
234
  end
235
+ do
236
+ local ____stageHistory = require("features.stageHistory")
237
+ local getStageHistory = ____stageHistory.getStageHistory
238
+ local hasVisitedStage = ____stageHistory.hasVisitedStage
239
+ ____exports.getStageHistory = getStageHistory
240
+ ____exports.hasVisitedStage = hasVisitedStage
241
+ end
221
242
  do
222
243
  local ____taintedLazarusPlayers = require("features.taintedLazarusPlayers")
223
244
  local getTaintedLazarusSubPlayer = ____taintedLazarusPlayers.getTaintedLazarusSubPlayer
@@ -368,14 +389,20 @@ do
368
389
  end
369
390
  end
370
391
  do
371
- local ____deepCopy = require("functions.deepCopy")
372
- local deepCopy = ____deepCopy.deepCopy
373
- ____exports.deepCopy = deepCopy
392
+ local ____export = require("functions.deepCopy")
393
+ for ____exportKey, ____exportValue in pairs(____export) do
394
+ if ____exportKey ~= "default" then
395
+ ____exports[____exportKey] = ____exportValue
396
+ end
397
+ end
374
398
  end
375
399
  do
376
- local ____deepCopyTests = require("functions.deepCopyTests")
377
- local deepCopyTests = ____deepCopyTests.deepCopyTests
378
- ____exports.deepCopyTests = deepCopyTests
400
+ local ____export = require("functions.deepCopyTests")
401
+ for ____exportKey, ____exportValue in pairs(____export) do
402
+ if ____exportKey ~= "default" then
403
+ ____exports[____exportKey] = ____exportValue
404
+ end
405
+ end
379
406
  end
380
407
  do
381
408
  local ____export = require("functions.direction")
@@ -578,9 +605,12 @@ do
578
605
  end
579
606
  end
580
607
  do
581
- local ____mergeTests = require("functions.mergeTests")
582
- local mergeTests = ____mergeTests.mergeTests
583
- ____exports.mergeTests = mergeTests
608
+ local ____export = require("functions.mergeTests")
609
+ for ____exportKey, ____exportValue in pairs(____export) do
610
+ if ____exportKey ~= "default" then
611
+ ____exports[____exportKey] = ____exportValue
612
+ end
613
+ end
584
614
  end
585
615
  do
586
616
  local ____export = require("functions.npc")
package/initFeatures.lua CHANGED
@@ -3,6 +3,10 @@ local ____characterHealthConversion = require("features.characterHealthConversio
3
3
  local characterHealthConversionInit = ____characterHealthConversion.characterHealthConversionInit
4
4
  local ____characterStats = require("features.characterStats")
5
5
  local characterStatsInit = ____characterStats.characterStatsInit
6
+ local ____collectibleItemPoolType = require("features.collectibleItemPoolType")
7
+ local collectibleItemPoolTypeInit = ____collectibleItemPoolType.collectibleItemPoolTypeInit
8
+ local ____init = require("features.customTrapdoor.init")
9
+ local stageTravelInit = ____init.stageTravelInit
6
10
  local ____deployJSONRoom = require("features.deployJSONRoom")
7
11
  local deployJSONRoomInit = ____deployJSONRoom.deployJSONRoomInit
8
12
  local ____disableInputs = require("features.disableInputs")
@@ -15,8 +19,6 @@ local ____fastReset = require("features.fastReset")
15
19
  local fastResetInit = ____fastReset.fastResetInit
16
20
  local ____forgottenSwitch = require("features.forgottenSwitch")
17
21
  local forgottenSwitchInit = ____forgottenSwitch.forgottenSwitchInit
18
- local ____getCollectibleItemPoolType = require("features.getCollectibleItemPoolType")
19
- local getCollectibleItemPoolTypeInit = ____getCollectibleItemPoolType.getCollectibleItemPoolTypeInit
20
22
  local ____persistentEntities = require("features.persistentEntities")
21
23
  local persistentEntitiesInit = ____persistentEntities.persistentEntitiesInit
22
24
  local ____playerInventory = require("features.playerInventory")
@@ -25,10 +27,14 @@ local ____ponyDetection = require("features.ponyDetection")
25
27
  local ponyDetectionInit = ____ponyDetection.ponyDetectionInit
26
28
  local ____preventCollectibleRotation = require("features.preventCollectibleRotation")
27
29
  local preventCollectibleRotationInit = ____preventCollectibleRotation.preventCollectibleRotationInit
30
+ local ____roomClearFrame = require("features.roomClearFrame")
31
+ local roomClearFrameInit = ____roomClearFrame.roomClearFrameInit
28
32
  local ____runInNFrames = require("features.runInNFrames")
29
33
  local runInNFramesInit = ____runInNFrames.runInNFramesInit
30
34
  local ____sirenHelpers = require("features.sirenHelpers")
31
35
  local sirenHelpersInit = ____sirenHelpers.sirenHelpersInit
36
+ local ____stageHistory = require("features.stageHistory")
37
+ local stageHistoryInit = ____stageHistory.stageHistoryInit
32
38
  local ____taintedLazarusPlayers = require("features.taintedLazarusPlayers")
33
39
  local taintedLazarusPlayersInit = ____taintedLazarusPlayers.taintedLazarusPlayersInit
34
40
  function ____exports.initFeaturesMajor(self, mod)
@@ -43,12 +49,15 @@ function ____exports.initFeaturesMinor(self, mod)
43
49
  fadeInRemoverInit(nil, mod)
44
50
  fastResetInit(nil, mod)
45
51
  forgottenSwitchInit(nil, mod)
46
- getCollectibleItemPoolTypeInit(nil, mod)
52
+ collectibleItemPoolTypeInit(nil, mod)
47
53
  persistentEntitiesInit(nil, mod)
48
54
  playerInventoryInit(nil, mod)
49
55
  ponyDetectionInit(nil, mod)
50
56
  preventCollectibleRotationInit(nil, mod)
57
+ roomClearFrameInit(nil, mod)
51
58
  sirenHelpersInit(nil, mod)
59
+ stageHistoryInit(nil, mod)
60
+ stageTravelInit(nil)
52
61
  taintedLazarusPlayersInit(nil, mod)
53
62
  end
54
63
  return ____exports
@@ -0,0 +1,5 @@
1
+ import { StageTravelEntityState } from "../enums/StageTravelEntityState";
2
+ export interface StageTravelEntityDescription {
3
+ initial: boolean;
4
+ state: StageTravelEntityState;
5
+ }
@@ -0,0 +1,2 @@
1
+ local ____exports = {}
2
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "4.2.8",
3
+ "version": "4.3.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "index",
23
23
  "types": "index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^3.0.12"
25
+ "isaac-typescript-definitions": "^3.0.13"
26
26
  }
27
27
  }
@@ -1,5 +0,0 @@
1
- export declare enum StageTravelEntityType {
2
- TRAPDOOR = 0,
3
- CRAWLSPACE = 1,
4
- HEAVEN_DOOR = 2
5
- }
@@ -1,9 +0,0 @@
1
- local ____exports = {}
2
- ____exports.StageTravelEntityType = {}
3
- ____exports.StageTravelEntityType.TRAPDOOR = 0
4
- ____exports.StageTravelEntityType[____exports.StageTravelEntityType.TRAPDOOR] = "TRAPDOOR"
5
- ____exports.StageTravelEntityType.CRAWLSPACE = 1
6
- ____exports.StageTravelEntityType[____exports.StageTravelEntityType.CRAWLSPACE] = "CRAWLSPACE"
7
- ____exports.StageTravelEntityType.HEAVEN_DOOR = 2
8
- ____exports.StageTravelEntityType[____exports.StageTravelEntityType.HEAVEN_DOOR] = "HEAVEN_DOOR"
9
- return ____exports
@@ -1,23 +0,0 @@
1
- /// <reference types="isaac-typescript-definitions" />
2
- /// <reference types="isaac-typescript-definitions" />
3
- /// <reference types="isaac-typescript-definitions" />
4
- /// <reference types="isaac-typescript-definitions" />
5
- /**
6
- * Spawn a trapdoor grid entity that will have one or more of the following custom attributes:
7
- *
8
- * - custom sprite
9
- * - custom opening/closing logic
10
- * - custom destination / logic for after the player enters
11
- */
12
- export declare function spawnCustomTrapdoor(gridIndexOrPosition: int | Vector): GridEntity;
13
- /**
14
- * Convert an existing trapdoor into a custom trapdoor that will have one or more of the following
15
- * custom attributes:
16
- *
17
- * - custom sprite
18
- * - custom opening/closing logic
19
- * - custom destination / logic for after the player enters
20
- */
21
- export declare function initCustomTrapdoor(_trapdoor: GridEntity, _shouldSpawnOpenFunc?: typeof defaultShouldSpawnOpenFunc): void;
22
- declare function defaultShouldSpawnOpenFunc(_entity: GridEntity | EntityEffect): boolean;
23
- export {};
@@ -1,44 +0,0 @@
1
- local ____exports = {}
2
- local defaultShouldSpawnOpenFunc
3
- local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
- local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
5
- local ____cachedClasses = require("cachedClasses")
6
- local game = ____cachedClasses.game
7
- local ____gridEntity = require("functions.gridEntity")
8
- local spawnGrid = ____gridEntity.spawnGrid
9
- --- Convert an existing trapdoor into a custom trapdoor that will have one or more of the following
10
- -- custom attributes:
11
- --
12
- -- - custom sprite
13
- -- - custom opening/closing logic
14
- -- - custom destination / logic for after the player enters
15
- function ____exports.initCustomTrapdoor(self, _trapdoor, _shouldSpawnOpenFunc)
16
- if _shouldSpawnOpenFunc == nil then
17
- _shouldSpawnOpenFunc = defaultShouldSpawnOpenFunc
18
- end
19
- end
20
- function defaultShouldSpawnOpenFunc(self, _entity)
21
- local room = game:GetRoom()
22
- local roomFrameCount = room:GetFrameCount()
23
- local roomClear = room:IsClear()
24
- if roomFrameCount == 0 then
25
- if not roomClear then
26
- return false
27
- end
28
- end
29
- return false
30
- end
31
- --- Spawn a trapdoor grid entity that will have one or more of the following custom attributes:
32
- --
33
- -- - custom sprite
34
- -- - custom opening/closing logic
35
- -- - custom destination / logic for after the player enters
36
- function ____exports.spawnCustomTrapdoor(self, gridIndexOrPosition)
37
- local trapdoor = spawnGrid(nil, GridEntityType.TRAPDOOR, gridIndexOrPosition)
38
- if trapdoor == nil then
39
- error("Failed to spawn a custom trapdoor.")
40
- end
41
- ____exports.initCustomTrapdoor(nil, trapdoor)
42
- return trapdoor
43
- end
44
- return ____exports