isaacscript-common 6.1.1 → 6.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 (72) hide show
  1. package/callbacks/reorderedCallbacks.d.ts +9 -0
  2. package/callbacks/reorderedCallbacks.lua +9 -0
  3. package/classes/DefaultMap.lua +2 -2
  4. package/constants.d.ts +9 -0
  5. package/constants.lua +7 -0
  6. package/enums/CornerType.d.ts +6 -0
  7. package/enums/CornerType.lua +11 -0
  8. package/features/customStage/backdrop.d.ts +2 -0
  9. package/features/customStage/backdrop.lua +200 -0
  10. package/features/customStage/boss.d.ts +2 -0
  11. package/features/customStage/boss.lua +74 -0
  12. package/features/customStage/exports.d.ts +4 -2
  13. package/features/customStage/exports.lua +109 -3
  14. package/features/customStage/init.d.ts +2 -1
  15. package/features/customStage/init.lua +63 -4
  16. package/features/customStage/stageAPIBoss.d.ts +29 -0
  17. package/features/customStage/stageAPIBoss.lua +9 -0
  18. package/features/customStage/util.d.ts +11 -0
  19. package/features/customStage/util.lua +51 -0
  20. package/features/customStage/v.d.ts +11 -0
  21. package/features/customStage/v.lua +5 -0
  22. package/features/debugDisplay/debugDisplay.lua +2 -0
  23. package/features/debugDisplay/exports.d.ts +108 -0
  24. package/features/debugDisplay/exports.lua +145 -0
  25. package/features/debugDisplay/v.d.ts +2 -0
  26. package/features/debugDisplay/v.lua +9 -0
  27. package/features/extraConsoleCommands/init.lua +8 -1
  28. package/features/extraConsoleCommands/listCommands.d.ts +12 -4
  29. package/features/extraConsoleCommands/listCommands.lua +30 -15
  30. package/features/extraConsoleCommands/v.d.ts +1 -0
  31. package/features/extraConsoleCommands/v.lua +2 -1
  32. package/features/pause.d.ts +11 -0
  33. package/features/pause.lua +71 -0
  34. package/features/runNextRoom.d.ts +8 -0
  35. package/features/runNextRoom.lua +40 -0
  36. package/functions/chargeBar.lua +4 -6
  37. package/functions/direction.d.ts +1 -1
  38. package/functions/doors.d.ts +6 -2
  39. package/functions/doors.lua +14 -0
  40. package/functions/familiars.d.ts +2 -0
  41. package/functions/familiars.lua +16 -0
  42. package/functions/jsonRoom.d.ts +25 -3
  43. package/functions/jsonRoom.lua +64 -2
  44. package/functions/playerCenter.d.ts +10 -0
  45. package/functions/playerCenter.lua +64 -0
  46. package/functions/playerIndex.d.ts +3 -0
  47. package/functions/playerIndex.lua +3 -0
  48. package/functions/roomShape.d.ts +10 -4
  49. package/functions/roomShape.lua +15 -2
  50. package/functions/rooms.d.ts +1 -1
  51. package/functions/rooms.lua +2 -2
  52. package/functions/sprite.d.ts +1 -1
  53. package/functions/sprite.lua +1 -1
  54. package/functions/stage.d.ts +3 -3
  55. package/functions/stage.lua +5 -4
  56. package/functions/trinkets.lua +1 -1
  57. package/index.d.ts +2 -1
  58. package/index.lua +10 -0
  59. package/initFeatures.lua +7 -1
  60. package/interfaces/Corner.d.ts +6 -0
  61. package/interfaces/Corner.lua +2 -0
  62. package/interfaces/CustomStage.d.ts +9 -50
  63. package/interfaces/CustomStageLua.d.ts +122 -0
  64. package/interfaces/CustomStageLua.lua +2 -0
  65. package/objects/roomShapeCorners.d.ts +6 -0
  66. package/objects/roomShapeCorners.lua +259 -0
  67. package/objects/roomShapeToBottomRightPosition.d.ts +1 -1
  68. package/objects/roomShapeToTopLeftPosition.d.ts +1 -1
  69. package/objects/roomTypeGotoPrefixes.lua +29 -29
  70. package/package.json +1 -1
  71. package/sets/narrowRoomShapesSet.d.ts +2 -0
  72. package/sets/narrowRoomShapesSet.lua +8 -0
@@ -1,3 +1,4 @@
1
+ import { LevelStage, StageType } from "isaac-typescript-definitions";
1
2
  /**
2
3
  * This is a utility function for users of the `ModCallbackCustom.POST_NEW_LEVEL_REORDERED` custom
3
4
  * callback.
@@ -18,3 +19,11 @@ export declare function forceNewLevelCallback(): void;
18
19
  * temporarily force the callback to fire.
19
20
  */
20
21
  export declare function forceNewRoomCallback(): void;
22
+ /**
23
+ * Helper function to manually set the variable that the reordered callback logic uses to track the
24
+ * current stage and stage type.
25
+ *
26
+ * This is useful because if the stage is changed with the `Game.SetStage` method, the reordered
27
+ * callbacks will stop working.
28
+ */
29
+ export declare function reorderedCallbacksSetStage(stage: LevelStage, stageType: StageType): void;
@@ -106,4 +106,13 @@ end
106
106
  function ____exports.forceNewRoomCallback(self)
107
107
  forceNewRoom = true
108
108
  end
109
+ --- Helper function to manually set the variable that the reordered callback logic uses to track the
110
+ -- current stage and stage type.
111
+ --
112
+ -- This is useful because if the stage is changed with the `Game.SetStage` method, the reordered
113
+ -- callbacks will stop working.
114
+ function ____exports.reorderedCallbacksSetStage(self, stage, stageType)
115
+ currentStage = stage
116
+ currentStageType = stageType
117
+ end
109
118
  return ____exports
@@ -120,7 +120,7 @@ function DefaultMap.prototype.getDefaultValue(self, ...)
120
120
  if self.defaultValueFactory ~= nil then
121
121
  return self:defaultValueFactory(...)
122
122
  end
123
- return error("A DefaultMap was incorrectly instantiated.")
123
+ error("A DefaultMap was incorrectly instantiated.")
124
124
  end
125
125
  function DefaultMap.prototype.getConstructorArg(self)
126
126
  if self.defaultValue ~= nil then
@@ -129,6 +129,6 @@ function DefaultMap.prototype.getConstructorArg(self)
129
129
  if self.defaultValueFactory ~= nil then
130
130
  return self.defaultValueFactory
131
131
  end
132
- return error("A DefaultMap was incorrectly instantiated.")
132
+ error("A DefaultMap was incorrectly instantiated.")
133
133
  end
134
134
  return ____exports
package/constants.d.ts CHANGED
@@ -85,6 +85,15 @@ export declare const LAST_ROOM_TYPE: RoomType;
85
85
  * effect.
86
86
  */
87
87
  export declare const MAX_SPEED_STAT = 2;
88
+ /** This is in the center of the room. */
89
+ export declare const NEW_FLOOR_STARTING_POSITION_NORMAL_MODE: Vector;
90
+ /** This is near the top door. */
91
+ export declare const NEW_FLOOR_STARTING_POSITION_GREED_MODE: Vector;
92
+ /**
93
+ * This is next to the bottom door. Presumably, the player does not start in the center of the room
94
+ * (like they do when getting to a new stage) so that the controls graphic is more visible.
95
+ */
96
+ export declare const NEW_RUN_PLAYER_STARTING_POSITION: Vector;
88
97
  export declare const FIRST_STAGE = LevelStage.BASEMENT_1;
89
98
  export declare const LAST_STAGE: LevelStage;
90
99
  /** Corresponds to the maximum value for `EntityPlayer.SamsonBerserkCharge`. */
package/constants.lua CHANGED
@@ -74,6 +74,13 @@ ____exports.LAST_ROOM_TYPE = getLastEnumValue(nil, RoomType)
74
74
  --- The maximum speed stat that a player can have. Any additional speed beyond this will not take
75
75
  -- effect.
76
76
  ____exports.MAX_SPEED_STAT = 2
77
+ --- This is in the center of the room.
78
+ ____exports.NEW_FLOOR_STARTING_POSITION_NORMAL_MODE = Vector(320, 280)
79
+ --- This is near the top door.
80
+ ____exports.NEW_FLOOR_STARTING_POSITION_GREED_MODE = Vector(320, 280)
81
+ --- This is next to the bottom door. Presumably, the player does not start in the center of the room
82
+ -- (like they do when getting to a new stage) so that the controls graphic is more visible.
83
+ ____exports.NEW_RUN_PLAYER_STARTING_POSITION = Vector(320, 380)
77
84
  ____exports.FIRST_STAGE = LevelStage.BASEMENT_1
78
85
  ____exports.LAST_STAGE = getLastEnumValue(nil, LevelStage)
79
86
  --- Corresponds to the maximum value for `EntityPlayer.SamsonBerserkCharge`.
@@ -0,0 +1,6 @@
1
+ export declare enum CornerType {
2
+ TOP_LEFT = 0,
3
+ TOP_RIGHT = 1,
4
+ BOTTOM_LEFT = 2,
5
+ BOTTOM_RIGHT = 3
6
+ }
@@ -0,0 +1,11 @@
1
+ local ____exports = {}
2
+ ____exports.CornerType = {}
3
+ ____exports.CornerType.TOP_LEFT = 0
4
+ ____exports.CornerType[____exports.CornerType.TOP_LEFT] = "TOP_LEFT"
5
+ ____exports.CornerType.TOP_RIGHT = 1
6
+ ____exports.CornerType[____exports.CornerType.TOP_RIGHT] = "TOP_RIGHT"
7
+ ____exports.CornerType.BOTTOM_LEFT = 2
8
+ ____exports.CornerType[____exports.CornerType.BOTTOM_LEFT] = "BOTTOM_LEFT"
9
+ ____exports.CornerType.BOTTOM_RIGHT = 3
10
+ ____exports.CornerType[____exports.CornerType.BOTTOM_RIGHT] = "BOTTOM_RIGHT"
11
+ return ____exports
@@ -0,0 +1,2 @@
1
+ import { CustomStage } from "../../interfaces/CustomStage";
2
+ export declare function setBackdrop(customStage: CustomStage): void;
@@ -0,0 +1,200 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local getBackdropPNGPath, spawnWallEntity, spawnSecondWallEntity, spawnFloorEntity, getNumFloorLayers, BackdropKind, BackdropEntitySubType, ROOM_SHAPE_WALL_ANM2_LAYERS, ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS, WALL_OFFSET, BACKDROP_EFFECT_VARIANT
6
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
+ local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
8
+ local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
9
+ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
10
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
11
+ local ____cachedClasses = require("cachedClasses")
12
+ local game = ____cachedClasses.game
13
+ local ____constants = require("constants")
14
+ local VectorZero = ____constants.VectorZero
15
+ local ____array = require("functions.array")
16
+ local getRandomArrayElement = ____array.getRandomArrayElement
17
+ local ____entitySpecific = require("functions.entitySpecific")
18
+ local spawnEffectWithSeed = ____entitySpecific.spawnEffectWithSeed
19
+ local ____rng = require("functions.rng")
20
+ local newRNG = ____rng.newRNG
21
+ local ____roomShape = require("functions.roomShape")
22
+ local isLRoom = ____roomShape.isLRoom
23
+ local isNarrowRoom = ____roomShape.isNarrowRoom
24
+ local ____string = require("functions.string")
25
+ local trimPrefix = ____string.trimPrefix
26
+ local ____utils = require("functions.utils")
27
+ local erange = ____utils.erange
28
+ local irange = ____utils.irange
29
+ function getBackdropPNGPath(self, customStage, backdropKind, rng)
30
+ local pathArray = customStage.backdrop[backdropKind]
31
+ local path = getRandomArrayElement(nil, pathArray, rng)
32
+ return (customStage.backdrop.prefix .. path) .. customStage.backdrop.suffix
33
+ end
34
+ function spawnWallEntity(self, customStage, rng, isExtraWall)
35
+ local room = game:GetRoom()
36
+ local roomShape = room:GetRoomShape()
37
+ local subType = isExtraWall and BackdropEntitySubType.WALL_EXTRA or BackdropEntitySubType.WALL
38
+ local wallEffect = spawnEffectWithSeed(
39
+ nil,
40
+ BACKDROP_EFFECT_VARIANT,
41
+ subType,
42
+ VectorZero,
43
+ 1
44
+ )
45
+ wallEffect:AddEntityFlags(EntityFlag.RENDER_WALL)
46
+ local sprite = wallEffect:GetSprite()
47
+ sprite:Load("gfx/isaacscript-custom-stage/wall-backdrop.anm2", false)
48
+ local wallLayersArray = isExtraWall and ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS or ROOM_SHAPE_WALL_ANM2_LAYERS
49
+ local numWallLayers = wallLayersArray[roomShape]
50
+ if numWallLayers == nil then
51
+ error("Failed to get the layers when creating the backdrop for custom stage: " .. customStage.name)
52
+ end
53
+ if isLRoom(nil, roomShape) then
54
+ local cornerPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.CORNER, rng)
55
+ sprite:ReplaceSpritesheet(0, cornerPNGPath)
56
+ end
57
+ for ____, layerID in ipairs(irange(nil, 1, numWallLayers)) do
58
+ local wallPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.WALL, rng)
59
+ sprite:ReplaceSpritesheet(layerID, wallPNGPath)
60
+ end
61
+ local topLeftPos = room:GetTopLeftPos()
62
+ local renderPos = topLeftPos + WALL_OFFSET
63
+ local modifiedOffset = renderPos / 40 * 26
64
+ wallEffect.SpriteOffset = modifiedOffset
65
+ sprite:LoadGraphics()
66
+ local roomShapeName = RoomShape[roomShape]
67
+ local animation = trimPrefix(nil, roomShapeName, "SHAPE_")
68
+ local modifiedAnimation = isExtraWall and animation .. "X" or animation
69
+ sprite:Play(modifiedAnimation, true)
70
+ end
71
+ function spawnSecondWallEntity(self, customStage, rng)
72
+ local room = game:GetRoom()
73
+ local roomShape = room:GetRoomShape()
74
+ local extraLayers = ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS[roomShape]
75
+ local roomShapeHasExtraLayers = extraLayers ~= nil
76
+ if roomShapeHasExtraLayers then
77
+ spawnWallEntity(nil, customStage, rng, true)
78
+ end
79
+ end
80
+ function spawnFloorEntity(self, customStage, rng)
81
+ local room = game:GetRoom()
82
+ local roomShape = room:GetRoomShape()
83
+ local floorEffect = spawnEffectWithSeed(
84
+ nil,
85
+ BACKDROP_EFFECT_VARIANT,
86
+ BackdropEntitySubType.FLOOR,
87
+ VectorZero,
88
+ 1
89
+ )
90
+ floorEffect:AddEntityFlags(EntityFlag.RENDER_FLOOR)
91
+ local sprite = floorEffect:GetSprite()
92
+ sprite:Load("gfx/isaacscript-custom-stage/floor-backdrop.anm2", false)
93
+ local numFloorLayers = getNumFloorLayers(nil, roomShape)
94
+ if numFloorLayers ~= nil then
95
+ for ____, layerID in ipairs(erange(nil, 0, numFloorLayers)) do
96
+ local wallPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.WALL, rng)
97
+ sprite:ReplaceSpritesheet(layerID, wallPNGPath)
98
+ end
99
+ end
100
+ if isLRoom(nil, roomShape) then
101
+ for ____, layerID in ipairs({16, 17}) do
102
+ local LFloorPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.L_FLOOR, rng)
103
+ sprite:ReplaceSpritesheet(layerID, LFloorPNGPath)
104
+ end
105
+ end
106
+ if isNarrowRoom(nil, roomShape) then
107
+ for ____, layerID in ipairs({18, 19}) do
108
+ local NFloorPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.N_FLOOR, rng)
109
+ sprite:ReplaceSpritesheet(layerID, NFloorPNGPath)
110
+ end
111
+ end
112
+ local topLeftPos = room:GetTopLeftPos()
113
+ local renderPos = topLeftPos
114
+ local modifiedOffset = renderPos / 40 * 26
115
+ floorEffect.SpriteOffset = modifiedOffset
116
+ sprite:LoadGraphics()
117
+ local roomShapeName = RoomShape[roomShape]
118
+ local animation = trimPrefix(nil, roomShapeName, "SHAPE_")
119
+ sprite:Play(animation, true)
120
+ end
121
+ function getNumFloorLayers(self, roomShape)
122
+ repeat
123
+ local ____switch23 = roomShape
124
+ local ____cond23 = ____switch23 == RoomShape.SHAPE_1x1
125
+ if ____cond23 then
126
+ do
127
+ return 4
128
+ end
129
+ end
130
+ ____cond23 = ____cond23 or (____switch23 == RoomShape.SHAPE_1x2 or ____switch23 == RoomShape.SHAPE_2x1)
131
+ if ____cond23 then
132
+ do
133
+ return 8
134
+ end
135
+ end
136
+ ____cond23 = ____cond23 or ____switch23 == RoomShape.SHAPE_2x2
137
+ if ____cond23 then
138
+ do
139
+ return 16
140
+ end
141
+ end
142
+ do
143
+ do
144
+ return nil
145
+ end
146
+ end
147
+ until true
148
+ end
149
+ BackdropKind = BackdropKind or ({})
150
+ BackdropKind.N_FLOOR = "nFloors"
151
+ BackdropKind.L_FLOOR = "lFloors"
152
+ BackdropKind.WALL = "walls"
153
+ BackdropKind.CORNER = "corners"
154
+ BackdropEntitySubType = BackdropEntitySubType or ({})
155
+ BackdropEntitySubType.VANILLA_LADDER = 0
156
+ BackdropEntitySubType[BackdropEntitySubType.VANILLA_LADDER] = "VANILLA_LADDER"
157
+ BackdropEntitySubType.WALL = 1
158
+ BackdropEntitySubType[BackdropEntitySubType.WALL] = "WALL"
159
+ BackdropEntitySubType.WALL_EXTRA = 2
160
+ BackdropEntitySubType[BackdropEntitySubType.WALL_EXTRA] = "WALL_EXTRA"
161
+ BackdropEntitySubType.FLOOR = 3
162
+ BackdropEntitySubType[BackdropEntitySubType.FLOOR] = "FLOOR"
163
+ ROOM_SHAPE_WALL_ANM2_LAYERS = {
164
+ [RoomShape.SHAPE_1x1] = 44,
165
+ [RoomShape.IH] = 36,
166
+ [RoomShape.IV] = 28,
167
+ [RoomShape.SHAPE_1x2] = 58,
168
+ [RoomShape.IIV] = 42,
169
+ [RoomShape.SHAPE_2x1] = 63,
170
+ [RoomShape.IIH] = 62,
171
+ [RoomShape.SHAPE_2x2] = 63,
172
+ [RoomShape.LTL] = 63,
173
+ [RoomShape.LTR] = 63,
174
+ [RoomShape.LBL] = 63,
175
+ [RoomShape.LBR] = 63
176
+ }
177
+ ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS = {
178
+ [RoomShape.SHAPE_2x1] = 7,
179
+ [RoomShape.SHAPE_2x2] = 21,
180
+ [RoomShape.LTL] = 19,
181
+ [RoomShape.LTR] = 19,
182
+ [RoomShape.LBL] = 19,
183
+ [RoomShape.LBR] = 19
184
+ }
185
+ WALL_OFFSET = Vector(-80, -80)
186
+ BACKDROP_EFFECT_VARIANT = EffectVariant.LADDER
187
+ local BACKDROP_ROOM_TYPE_SET = __TS__New(Set, {RoomType.DEFAULT, RoomType.BOSS, RoomType.MINI_BOSS})
188
+ function ____exports.setBackdrop(self, customStage)
189
+ local room = game:GetRoom()
190
+ local roomType = room:GetType()
191
+ local decorationSeed = room:GetDecorationSeed()
192
+ local rng = newRNG(nil, decorationSeed)
193
+ if not BACKDROP_ROOM_TYPE_SET:has(roomType) then
194
+ return
195
+ end
196
+ spawnWallEntity(nil, customStage, rng, false)
197
+ spawnSecondWallEntity(nil, customStage, rng)
198
+ spawnFloorEntity(nil, customStage, rng)
199
+ end
200
+ return ____exports
@@ -0,0 +1,2 @@
1
+ export declare function playBossRoomAnimation(force?: boolean): void;
2
+ export declare function bossPostRender(): void;
@@ -0,0 +1,74 @@
1
+ local ____exports = {}
2
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
4
+ local SoundEffect = ____isaac_2Dtypescript_2Ddefinitions.SoundEffect
5
+ local ____cachedClasses = require("cachedClasses")
6
+ local game = ____cachedClasses.game
7
+ local sfxManager = ____cachedClasses.sfxManager
8
+ local ____pause = require("features.pause")
9
+ local pause = ____pause.pause
10
+ local unpause = ____pause.unpause
11
+ local ____v = require("features.customStage.v")
12
+ local v = ____v.default
13
+ local VERSUS_SCREEN_ANIMATION = "Scene"
14
+ --- Taken from StageAPI. I do not know why rendering in a certain order is necessary, but otherwise
15
+ -- the overlay layer will be on top of everything else and will hide the other elements.
16
+ local VERSUS_SCREEN_LAYER_RENDER_ORDER = {
17
+ 0,
18
+ 1,
19
+ 2,
20
+ 3,
21
+ 9,
22
+ 14,
23
+ 13,
24
+ 4,
25
+ 5,
26
+ 12,
27
+ 11,
28
+ 6,
29
+ 7,
30
+ 8,
31
+ 10
32
+ }
33
+ local versusScreenSprite = Sprite()
34
+ versusScreenSprite:Load("gfx/ui/boss/versusscreen.anm2", true)
35
+ function ____exports.playBossRoomAnimation(self, force)
36
+ if force == nil then
37
+ force = false
38
+ end
39
+ local room = game:GetRoom()
40
+ local roomType = room:GetType()
41
+ local hud = game:GetHUD()
42
+ if roomType ~= RoomType.BOSS and not force then
43
+ return
44
+ end
45
+ v.run.showingBossVersusScreen = true
46
+ pause(nil)
47
+ hud:SetVisible(false)
48
+ versusScreenSprite:Play(VERSUS_SCREEN_ANIMATION, true)
49
+ versusScreenSprite.PlaybackSpeed = 0.5
50
+ end
51
+ local function finishBossRoomAnimation(self)
52
+ local hud = game:GetHUD()
53
+ v.run.showingBossVersusScreen = false
54
+ unpause(nil)
55
+ hud:SetVisible(true)
56
+ sfxManager:Play(SoundEffect.CASTLE_PORTCULLIS)
57
+ end
58
+ function ____exports.bossPostRender(self)
59
+ if not v.run.showingBossVersusScreen then
60
+ return
61
+ end
62
+ if versusScreenSprite:IsFinished(VERSUS_SCREEN_ANIMATION) then
63
+ finishBossRoomAnimation(nil)
64
+ return
65
+ end
66
+ local room = game:GetRoom()
67
+ local centerPos = room:GetCenterPos()
68
+ local position = Isaac.WorldToRenderPosition(centerPos)
69
+ for ____, layerID in ipairs(VERSUS_SCREEN_LAYER_RENDER_ORDER) do
70
+ versusScreenSprite:RenderLayer(layerID, position)
71
+ end
72
+ versusScreenSprite:Update()
73
+ end
74
+ return ____exports
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Helper function to warp to a custom stage/level.
3
3
  *
4
- * Custom stages/levels must first be registered with the `registerCustomStage` function.
4
+ * Custom stages/levels must first be defined in the "tsconfig.json" file. See the documentation for
5
+ * more details: https://isaacscript.github.io/main/custom-stages/
5
6
  */
6
- export declare function setCustomStage(name: string): void;
7
+ export declare function setCustomStage(name: string, verbose?: boolean): void;
8
+ export declare function setCustomStageDebug(): void;
@@ -1,15 +1,121 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local ____exports = {}
4
+ local postRoomTransition
5
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
+ local Direction = ____isaac_2Dtypescript_2Ddefinitions.Direction
7
+ local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
8
+ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
9
+ local RoomTransitionAnim = ____isaac_2Dtypescript_2Ddefinitions.RoomTransitionAnim
10
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
11
+ local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
12
+ local ____cachedClasses = require("cachedClasses")
13
+ local game = ____cachedClasses.game
14
+ local ____reorderedCallbacks = require("callbacks.reorderedCallbacks")
15
+ local reorderedCallbacksSetStage = ____reorderedCallbacks.reorderedCallbacksSetStage
16
+ local ____log = require("functions.log")
17
+ local log = ____log.log
18
+ local logError = ____log.logError
19
+ local ____playerCenter = require("functions.playerCenter")
20
+ local movePlayersToCenter = ____playerCenter.movePlayersToCenter
21
+ local ____rng = require("functions.rng")
22
+ local newRNG = ____rng.newRNG
23
+ local ____roomData = require("functions.roomData")
24
+ local getRoomData = ____roomData.getRoomData
25
+ local ____rooms = require("functions.rooms")
26
+ local getRooms = ____rooms.getRooms
27
+ local ____stage = require("functions.stage")
28
+ local getGotoCommand = ____stage.getGotoCommand
29
+ local setStage = ____stage.setStage
30
+ local ____runNextRoom = require("features.runNextRoom")
31
+ local runNextRoom = ____runNextRoom.runNextRoom
32
+ local ____boss = require("features.customStage.boss")
33
+ local playBossRoomAnimation = ____boss.playBossRoomAnimation
34
+ local ____util = require("features.customStage.util")
35
+ local getRandomCustomStageRoom = ____util.getRandomCustomStageRoom
4
36
  local ____v = require("features.customStage.v")
37
+ local v = ____v.default
38
+ local customStageCachedRoomData = ____v.customStageCachedRoomData
5
39
  local customStagesMap = ____v.customStagesMap
40
+ function postRoomTransition(self)
41
+ movePlayersToCenter(nil)
42
+ end
6
43
  --- Helper function to warp to a custom stage/level.
7
44
  --
8
- -- Custom stages/levels must first be registered with the `registerCustomStage` function.
9
- function ____exports.setCustomStage(self, name)
45
+ -- Custom stages/levels must first be defined in the "tsconfig.json" file. See the documentation for
46
+ -- more details: https://isaacscript.github.io/main/custom-stages/
47
+ function ____exports.setCustomStage(self, name, verbose)
48
+ if verbose == nil then
49
+ verbose = false
50
+ end
10
51
  local customStage = customStagesMap:get(name)
11
52
  if customStage == nil then
12
- error(("Failed to set the custom stage of \"" .. name) .. "\" because it was not found in the custom stages map. (This means that you probably forgot to define it in your \"tsconfig.json\" file.) See the website for more details on how to set up custom stages..")
53
+ error(("Failed to set the custom stage of \"" .. name) .. "\" because it was not found in the custom stages map. (This means that you probably forgot to define it in your \"tsconfig.json\" file.) See the website for more details on how to set up custom stages.")
54
+ end
55
+ local level = game:GetLevel()
56
+ local startingRoomGridIndex = level:GetStartingRoomIndex()
57
+ local seeds = game:GetSeeds()
58
+ local startSeed = seeds:GetStartSeed()
59
+ local rng = newRNG(nil, startSeed)
60
+ v.run.currentCustomStage = customStage
61
+ setStage(nil, customStage.baseStage, customStage.baseStageType)
62
+ for ____, room in ipairs(getRooms(nil)) do
63
+ do
64
+ if room.SafeGridIndex == startingRoomGridIndex then
65
+ goto __continue4
66
+ end
67
+ if room.Data == nil then
68
+ goto __continue4
69
+ end
70
+ local roomType = room.Data.Type
71
+ local roomShapeMap = customStage.roomTypeMap:get(roomType)
72
+ if roomShapeMap == nil then
73
+ if roomType == RoomType.DEFAULT then
74
+ logError((((("Failed to find any custom rooms for RoomType." .. tostring(RoomType[roomType])) .. " (") .. tostring(roomType)) .. ") for custom stage: ") .. name)
75
+ end
76
+ goto __continue4
77
+ end
78
+ local roomShape = room.Data.Shape
79
+ local roomDoorSlotFlagMap = roomShapeMap:get(roomShape)
80
+ if roomDoorSlotFlagMap == nil then
81
+ logError((((((((("Failed to find any custom rooms for RoomType." .. tostring(RoomType[roomType])) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ") for custom stage: ") .. name)
82
+ goto __continue4
83
+ end
84
+ local doorSlotFlags = room.Data.Doors
85
+ local roomsMetadata = roomDoorSlotFlagMap:get(doorSlotFlags)
86
+ if roomsMetadata == nil then
87
+ logError((((((((((("Failed to find any custom rooms for RoomType." .. tostring(RoomType[roomType])) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ") + DoorSlotFlags ") .. tostring(doorSlotFlags)) .. " for custom stage: ") .. name)
88
+ goto __continue4
89
+ end
90
+ local randomRoom = getRandomCustomStageRoom(nil, roomsMetadata, rng, verbose)
91
+ local newRoomData = customStageCachedRoomData:get(randomRoom.variant)
92
+ if newRoomData == nil then
93
+ local command = getGotoCommand(nil, roomType, randomRoom.variant)
94
+ Isaac.ExecuteCommand(command)
95
+ newRoomData = getRoomData(nil, GridRoom.DEBUG)
96
+ if newRoomData == nil then
97
+ logError((("Failed to get the room data for room variant " .. tostring(randomRoom.variant)) .. " for custom stage: ") .. name)
98
+ goto __continue4
99
+ end
100
+ customStageCachedRoomData:set(randomRoom.variant, newRoomData)
101
+ end
102
+ room.Data = newRoomData
103
+ end
104
+ ::__continue4::
105
+ end
106
+ local stage = -1
107
+ local stageType = StageType.WRATH_OF_THE_LAMB
108
+ level:SetStage(stage, stageType)
109
+ reorderedCallbacksSetStage(nil, stage, stageType)
110
+ game:StartRoomTransition(startingRoomGridIndex, Direction.NO_DIRECTION, RoomTransitionAnim.FADE)
111
+ runNextRoom(nil, postRoomTransition)
112
+ end
113
+ function ____exports.setCustomStageDebug(self)
114
+ local customStage = v.run.currentCustomStage
115
+ if customStage == nil then
116
+ log("No custom stage is currently loaded.")
117
+ return
13
118
  end
119
+ playBossRoomAnimation(nil, true)
14
120
  end
15
121
  return ____exports
@@ -1 +1,2 @@
1
- export declare function customStageInit(): void;
1
+ import { ModUpgraded } from "../../classes/ModUpgraded";
2
+ export declare function customStageInit(mod: ModUpgraded): void;
@@ -1,18 +1,77 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
+ local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
4
+ local __TS__New = ____lualib.__TS__New
3
5
  local ____exports = {}
6
+ local initRoomTypeMaps, getRoomTypeMap, postRender, postNewRoomReordered
7
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
8
+ local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
9
+ local ____ModCallbackCustom = require("enums.ModCallbackCustom")
10
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
4
11
  local ____array = require("functions.array")
5
12
  local isArray = ____array.isArray
13
+ local ____exports = require("features.saveDataManager.exports")
14
+ local saveDataManager = ____exports.saveDataManager
15
+ local ____backdrop = require("features.customStage.backdrop")
16
+ local setBackdrop = ____backdrop.setBackdrop
17
+ local ____boss = require("features.customStage.boss")
18
+ local bossPostRender = ____boss.bossPostRender
19
+ local playBossRoomAnimation = ____boss.playBossRoomAnimation
6
20
  local metadataJSON = require("features.customStage.metadata")
7
21
  local ____v = require("features.customStage.v")
22
+ local v = ____v.default
8
23
  local customStagesMap = ____v.customStagesMap
9
- function ____exports.customStageInit(self)
10
- local customStages = metadataJSON
11
- if not isArray(nil, customStages) then
24
+ function initRoomTypeMaps(self)
25
+ local customStagesLua = metadataJSON
26
+ if not isArray(nil, customStagesLua) then
12
27
  error("The IsaacScript standard library attempted to read the custom stage metadata from the \"metadata.lua\" file, but it was not an array.")
13
28
  end
14
- for ____, customStage in ipairs(customStages) do
29
+ for ____, customStageLua in ipairs(customStagesLua) do
30
+ local roomTypeMap = getRoomTypeMap(nil, customStageLua)
31
+ local customStage = __TS__ObjectAssign({}, customStageLua, {roomTypeMap = roomTypeMap})
15
32
  customStagesMap:set(customStage.name, customStage)
16
33
  end
17
34
  end
35
+ function getRoomTypeMap(self, customStageLua)
36
+ local roomTypeMap = __TS__New(Map)
37
+ for ____, roomMetadata in ipairs(customStageLua.roomsMetadata) do
38
+ local roomType = roomMetadata.type
39
+ local roomShapeMap = roomTypeMap:get(roomType)
40
+ if roomShapeMap == nil then
41
+ roomShapeMap = __TS__New(Map)
42
+ roomTypeMap:set(roomType, roomShapeMap)
43
+ end
44
+ local roomShape = roomMetadata.shape
45
+ local roomDoorSlotFlagMap = roomShapeMap:get(roomShape)
46
+ if roomDoorSlotFlagMap == nil then
47
+ roomDoorSlotFlagMap = __TS__New(Map)
48
+ roomShapeMap:set(roomShape, roomDoorSlotFlagMap)
49
+ end
50
+ local doorSlotFlags = roomMetadata.doorSlotFlags
51
+ local rooms = roomDoorSlotFlagMap:get(doorSlotFlags)
52
+ if rooms == nil then
53
+ rooms = {}
54
+ roomDoorSlotFlagMap:set(doorSlotFlags, rooms)
55
+ end
56
+ rooms[#rooms + 1] = roomMetadata
57
+ end
58
+ return roomTypeMap
59
+ end
60
+ function postRender(self)
61
+ bossPostRender(nil)
62
+ end
63
+ function postNewRoomReordered(self)
64
+ local customStage = v.run.currentCustomStage
65
+ if customStage == nil then
66
+ return
67
+ end
68
+ setBackdrop(nil, customStage)
69
+ playBossRoomAnimation(nil)
70
+ end
71
+ function ____exports.customStageInit(self, mod)
72
+ saveDataManager(nil, "customStage", v)
73
+ initRoomTypeMaps(nil)
74
+ mod:AddCallback(ModCallback.POST_RENDER, postRender)
75
+ mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
76
+ end
18
77
  return ____exports
@@ -0,0 +1,29 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
4
+ interface ParamTable {
5
+ BossPortrait?: string;
6
+ BossPortraitTwo?: string;
7
+ BossName?: string;
8
+ BossSpot?: string;
9
+ PlayerPortrait?: string;
10
+ PlayerName?: string;
11
+ PlayerSpot?: string;
12
+ Unskippable?: boolean;
13
+ BackgroundColor?: Color;
14
+ DirtColor?: Color;
15
+ NoShake?: boolean;
16
+ Animation?: string;
17
+ Sprite?: Sprite;
18
+ NoLoadGraphics?: boolean;
19
+ BossOffset?: Vector;
20
+ }
21
+ declare const StageAPILocal: {
22
+ BossSprite: Sprite | undefined;
23
+ BossSpriteBg: Sprite | undefined;
24
+ BossSpriteDirt: Sprite | undefined;
25
+ PlayingBossSprite: Sprite | undefined;
26
+ PlayingBossSpriteBg: Sprite | undefined;
27
+ PlayingBossSpriteDirt: Sprite | undefined;
28
+ BossOffset: Vector | undefined;
29
+ };
@@ -0,0 +1,9 @@
1
+ local StageAPILocal = {
2
+ BossSprite = nil,
3
+ BossSpriteBg = nil,
4
+ BossSpriteDirt = nil,
5
+ PlayingBossSprite = nil,
6
+ PlayingBossSpriteBg = nil,
7
+ PlayingBossSpriteDirt = nil,
8
+ BossOffset = nil
9
+ }
@@ -0,0 +1,11 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ import { CustomStageRoomMetadata } from "../../interfaces/CustomStageLua";
4
+ /**
5
+ * Helper function to get a random custom stage room from an array of custom stage rooms.
6
+ *
7
+ * Note that this function does not simply choose a random element in the provided array; it will
8
+ * properly account for each room weight using the algorithm from:
9
+ * https://stackoverflow.com/questions/1761626/weighted-random-numbers
10
+ */
11
+ export declare function getRandomCustomStageRoom(roomsMetadata: readonly CustomStageRoomMetadata[], seedOrRNG?: Seed | RNG, verbose?: boolean): CustomStageRoomMetadata;