isaacscript-common 4.2.5 → 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 (46) 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/enums/private/SaveDataKey.d.ts +0 -1
  6. package/enums/private/SaveDataKey.lua +0 -4
  7. package/features/{getCollectibleItemPoolType.d.ts → collectibleItemPoolType.d.ts} +0 -0
  8. package/features/{getCollectibleItemPoolType.lua → collectibleItemPoolType.lua} +2 -2
  9. package/features/customTrapdoor/constants.d.ts +5 -0
  10. package/features/customTrapdoor/constants.lua +7 -0
  11. package/features/customTrapdoor/exports.d.ts +37 -0
  12. package/features/customTrapdoor/exports.lua +120 -0
  13. package/features/customTrapdoor/init.d.ts +1 -0
  14. package/features/customTrapdoor/init.lua +11 -0
  15. package/features/customTrapdoor/stageTravel.d.ts +0 -0
  16. package/features/customTrapdoor/stageTravel.lua +0 -0
  17. package/features/customTrapdoor/trapdoor.d.ts +0 -0
  18. package/features/customTrapdoor/trapdoor.lua +0 -0
  19. package/features/customTrapdoor/v.d.ts +14 -0
  20. package/features/customTrapdoor/v.lua +16 -0
  21. package/features/ponyDetection.d.ts +6 -1
  22. package/features/ponyDetection.lua +14 -1
  23. package/features/roomClearFrame.d.ts +11 -0
  24. package/features/roomClearFrame.lua +38 -0
  25. package/features/saveDataManager/main.lua +4 -2
  26. package/features/stageHistory.d.ts +15 -0
  27. package/features/stageHistory.lua +62 -0
  28. package/functions/character.d.ts +1 -1
  29. package/functions/character.lua +7 -9
  30. package/functions/gridEntity.d.ts +5 -0
  31. package/functions/gridEntity.lua +9 -0
  32. package/functions/gridEntitySpecific.d.ts +11 -6
  33. package/functions/gridEntitySpecific.lua +18 -0
  34. package/functions/log.lua +7 -1
  35. package/functions/nextStage.d.ts +18 -0
  36. package/functions/nextStage.lua +245 -0
  37. package/functions/stage.d.ts +10 -0
  38. package/functions/stage.lua +28 -0
  39. package/index.d.ts +8 -5
  40. package/index.lua +50 -20
  41. package/initFeatures.lua +12 -3
  42. package/interfaces/StageTravelEntityDescription.d.ts +5 -0
  43. package/interfaces/StageTravelEntityDescription.lua +2 -0
  44. package/objects/characterNames.d.ts +0 -1
  45. package/objects/characterNames.lua +0 -1
  46. package/package.json +2 -2
@@ -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
@@ -4,4 +4,3 @@ export declare enum SaveDataKey {
4
4
  LEVEL = "level",
5
5
  ROOM = "room"
6
6
  }
7
- export declare const RESETTABLE_SAVE_DATA_KEYS: ReadonlySet<SaveDataKey>;
@@ -1,11 +1,7 @@
1
- local ____lualib = require("lualib_bundle")
2
- local Set = ____lualib.Set
3
- local __TS__New = ____lualib.__TS__New
4
1
  local ____exports = {}
5
2
  ____exports.SaveDataKey = {}
6
3
  ____exports.SaveDataKey.PERSISTENT = "persistent"
7
4
  ____exports.SaveDataKey.RUN = "run"
8
5
  ____exports.SaveDataKey.LEVEL = "level"
9
6
  ____exports.SaveDataKey.ROOM = "room"
10
- ____exports.RESETTABLE_SAVE_DATA_KEYS = __TS__New(Set, {____exports.SaveDataKey.RUN, ____exports.SaveDataKey.LEVEL, ____exports.SaveDataKey.ROOM})
11
7
  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
File without changes
File without changes
File without changes
File without changes
@@ -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
@@ -1,7 +1,9 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
+ local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
3
5
  local ____exports = {}
4
- local postPlayerInit, preGameExit, postNewLevel, postNewRoomEarly, restoreDefaultsAll, restoreDefaults, clearAndCopyAllElements, mod, loadedDataOnThisRun
6
+ local postPlayerInit, preGameExit, postNewLevel, postNewRoomEarly, restoreDefaultsAll, restoreDefaults, clearAndCopyAllElements, RESETTABLE_SAVE_DATA_KEYS, mod, loadedDataOnThisRun
5
7
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
8
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
7
9
  local ____cachedClasses = require("cachedClasses")
@@ -9,7 +11,6 @@ local game = ____cachedClasses.game
9
11
  local ____ModCallbackCustom = require("enums.ModCallbackCustom")
10
12
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
11
13
  local ____SaveDataKey = require("enums.private.SaveDataKey")
12
- local RESETTABLE_SAVE_DATA_KEYS = ____SaveDataKey.RESETTABLE_SAVE_DATA_KEYS
13
14
  local SaveDataKey = ____SaveDataKey.SaveDataKey
14
15
  local ____SerializationType = require("enums.SerializationType")
15
16
  local SerializationType = ____SerializationType.SerializationType
@@ -102,6 +103,7 @@ function clearAndCopyAllElements(self, oldTable, newTable)
102
103
  oldTable[key] = value
103
104
  end
104
105
  end
106
+ RESETTABLE_SAVE_DATA_KEYS = __TS__New(Set, {SaveDataKey.RUN, SaveDataKey.LEVEL, SaveDataKey.ROOM})
105
107
  mod = nil
106
108
  loadedDataOnThisRun = false
107
109
  ---
@@ -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
@@ -42,7 +42,7 @@ export declare function getCharacterDeathAnimationName(character: PlayerType): s
42
42
  * Mother's Kiss; use the `getPlayerMaxHeartContainers` helper function for that.
43
43
  */
44
44
  export declare function getCharacterMaxHeartContainers(character: PlayerType): int;
45
- /** Helper function to get the name of a character. Returns "unknown" for modded characters. */
45
+ /** Helper function to get the name of a character. Returns "Unknown" for modded characters. */
46
46
  export declare function getCharacterName(character: PlayerType): string;
47
47
  export declare function isModdedCharacter(character: PlayerType): boolean;
48
48
  export declare function isVanillaCharacter(character: PlayerType): boolean;
@@ -5,7 +5,6 @@ local ____constantsFirstLast = require("constantsFirstLast")
5
5
  local LAST_VANILLA_CHARACTER = ____constantsFirstLast.LAST_VANILLA_CHARACTER
6
6
  local ____characterNames = require("objects.characterNames")
7
7
  local CHARACTER_NAMES = ____characterNames.CHARACTER_NAMES
8
- local DEFAULT_CHARACTER_NAME = ____characterNames.DEFAULT_CHARACTER_NAME
9
8
  local ____charactersThatStartWithAnActiveItemSet = require("sets.charactersThatStartWithAnActiveItemSet")
10
9
  local CHARACTERS_THAT_START_WITH_AN_ACTIVE_ITEM_SET = ____charactersThatStartWithAnActiveItemSet.CHARACTERS_THAT_START_WITH_AN_ACTIVE_ITEM_SET
11
10
  local ____charactersWithBlackHeartFromEternalHeartSet = require("sets.charactersWithBlackHeartFromEternalHeartSet")
@@ -18,6 +17,9 @@ local ____charactersWithNoSoulHeartsSet = require("sets.charactersWithNoSoulHear
18
17
  local CHARACTERS_WITH_NO_SOUL_HEARTS_SET = ____charactersWithNoSoulHeartsSet.CHARACTERS_WITH_NO_SOUL_HEARTS_SET
19
18
  local ____lostStyleCharactersSet = require("sets.lostStyleCharactersSet")
20
19
  local LOST_STYLE_CHARACTERS_SET = ____lostStyleCharactersSet.LOST_STYLE_CHARACTERS_SET
20
+ function ____exports.isModdedCharacter(self, character)
21
+ return not ____exports.isVanillaCharacter(nil, character)
22
+ end
21
23
  function ____exports.isVanillaCharacter(self, character)
22
24
  return character <= LAST_VANILLA_CHARACTER
23
25
  end
@@ -82,15 +84,11 @@ function ____exports.getCharacterMaxHeartContainers(self, character)
82
84
  end
83
85
  return 12
84
86
  end
85
- --- Helper function to get the name of a character. Returns "unknown" for modded characters.
87
+ --- Helper function to get the name of a character. Returns "Unknown" for modded characters.
86
88
  function ____exports.getCharacterName(self, character)
87
- if ____exports.isVanillaCharacter(nil, character) then
88
- return "unknown"
89
+ if ____exports.isModdedCharacter(nil, character) then
90
+ return "Unknown"
89
91
  end
90
- local characterName = CHARACTER_NAMES[character]
91
- return characterName == nil and DEFAULT_CHARACTER_NAME or characterName
92
- end
93
- function ____exports.isModdedCharacter(self, character)
94
- return not ____exports.isVanillaCharacter(nil, character)
92
+ return CHARACTER_NAMES[character]
95
93
  end
96
94
  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.