isaacscript-common 6.2.0 → 6.4.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 (96) hide show
  1. package/cachedClasses.d.ts +15 -0
  2. package/cachedClasses.lua +20 -0
  3. package/callbacks/reorderedCallbacks.d.ts +9 -0
  4. package/callbacks/reorderedCallbacks.lua +9 -0
  5. package/constants.d.ts +26 -4
  6. package/constants.lua +20 -4
  7. package/enums/CornerType.d.ts +6 -0
  8. package/enums/CornerType.lua +11 -0
  9. package/features/customStage/backdrop.d.ts +2 -0
  10. package/features/customStage/backdrop.lua +202 -0
  11. package/features/customStage/customStageConstants.d.ts +1 -0
  12. package/features/customStage/customStageConstants.lua +3 -0
  13. package/features/customStage/exports.d.ts +28 -0
  14. package/features/customStage/exports.lua +58 -1
  15. package/features/customStage/init.d.ts +2 -1
  16. package/features/customStage/init.lua +45 -9
  17. package/features/customStage/streakText.d.ts +2 -0
  18. package/features/customStage/streakText.lua +22 -0
  19. package/features/customStage/v.d.ts +10 -0
  20. package/features/customStage/v.lua +4 -0
  21. package/features/customStage/versusScreen.d.ts +3 -0
  22. package/features/customStage/versusScreen.lua +193 -0
  23. package/features/debugDisplay/debugDisplay.lua +2 -0
  24. package/features/debugDisplay/exports.d.ts +108 -0
  25. package/features/debugDisplay/exports.lua +145 -0
  26. package/features/debugDisplay/v.d.ts +2 -0
  27. package/features/debugDisplay/v.lua +9 -0
  28. package/features/deployJSONRoom.lua +6 -2
  29. package/features/extraConsoleCommands/init.lua +8 -1
  30. package/features/extraConsoleCommands/listCommands.d.ts +12 -4
  31. package/features/extraConsoleCommands/listCommands.lua +30 -15
  32. package/features/extraConsoleCommands/v.d.ts +1 -0
  33. package/features/extraConsoleCommands/v.lua +2 -1
  34. package/features/pause.d.ts +11 -0
  35. package/features/pause.lua +71 -0
  36. package/features/runNextRoom.d.ts +8 -0
  37. package/features/runNextRoom.lua +40 -0
  38. package/features/saveDataManager/exports.lua +2 -2
  39. package/features/saveDataManager/load.lua +3 -3
  40. package/features/saveDataManager/main.lua +3 -3
  41. package/features/saveDataManager/merge.lua +2 -2
  42. package/features/saveDataManager/save.lua +3 -3
  43. package/features/saveDataManager/{constants.d.ts → saveDataManagerConstants.d.ts} +0 -0
  44. package/features/saveDataManager/{constants.lua → saveDataManagerConstants.lua} +0 -0
  45. package/functions/chargeBar.lua +4 -6
  46. package/functions/color.d.ts +0 -2
  47. package/functions/color.lua +0 -4
  48. package/functions/deepCopy.lua +2 -2
  49. package/functions/direction.d.ts +1 -1
  50. package/functions/doors.d.ts +2 -2
  51. package/functions/entity.d.ts +5 -0
  52. package/functions/entity.lua +13 -0
  53. package/functions/gridEntity.d.ts +5 -0
  54. package/functions/gridEntity.lua +7 -2
  55. package/functions/kColor.d.ts +0 -2
  56. package/functions/kColor.lua +0 -4
  57. package/functions/log.lua +2 -1
  58. package/functions/playerCenter.d.ts +5 -1
  59. package/functions/playerCenter.lua +15 -8
  60. package/functions/playerIndex.d.ts +3 -0
  61. package/functions/playerIndex.lua +3 -0
  62. package/functions/roomShape.d.ts +10 -4
  63. package/functions/roomShape.lua +15 -2
  64. package/functions/sprite.d.ts +1 -1
  65. package/functions/sprite.lua +1 -1
  66. package/functions/ui.d.ts +2 -0
  67. package/functions/ui.lua +8 -0
  68. package/functions/utils.d.ts +6 -4
  69. package/functions/utils.lua +6 -4
  70. package/index.d.ts +2 -1
  71. package/index.lua +10 -0
  72. package/initFeatures.lua +7 -1
  73. package/interfaces/Corner.d.ts +6 -0
  74. package/interfaces/Corner.lua +2 -0
  75. package/interfaces/CustomStageLua.d.ts +38 -9
  76. package/objects/bossNamePNGFileNames.d.ts +5 -0
  77. package/objects/bossNamePNGFileNames.lua +108 -0
  78. package/objects/bossPortraitPNGFileNames.d.ts +5 -0
  79. package/objects/bossPortraitPNGFileNames.lua +108 -0
  80. package/objects/colors.d.ts +15 -8
  81. package/objects/colors.lua +9 -2
  82. package/objects/playerNamePNGFileNames.d.ts +5 -0
  83. package/objects/playerNamePNGFileNames.lua +49 -0
  84. package/objects/playerPortraitPNGFileNames.d.ts +5 -0
  85. package/objects/playerPortraitPNGFileNames.lua +49 -0
  86. package/objects/roomShapeCorners.d.ts +6 -0
  87. package/objects/roomShapeCorners.lua +259 -0
  88. package/objects/roomShapeToBottomRightPosition.d.ts +1 -1
  89. package/objects/roomShapeToTopLeftPosition.d.ts +1 -1
  90. package/objects/versusScreenBackgroundColors.d.ts +5 -0
  91. package/objects/versusScreenBackgroundColors.lua +38 -0
  92. package/objects/versusScreenDirtSpotColors.d.ts +5 -0
  93. package/objects/versusScreenDirtSpotColors.lua +38 -0
  94. package/package.json +2 -2
  95. package/sets/narrowRoomShapesSet.d.ts +2 -0
  96. package/sets/narrowRoomShapesSet.lua +8 -0
@@ -38,3 +38,18 @@ export declare const musicManager: MusicManager;
38
38
  * `Room`) is not safe and can lead to the game crashing in certain situations.
39
39
  */
40
40
  export declare const sfxManager: SFXManager;
41
+ /**
42
+ * An object containing all 7 vanilla fonts that are pre-loaded and ready to use.
43
+ *
44
+ * For more information on the vanilla fonts and to see what they look like, see:
45
+ * https://wofsauge.github.io/IsaacDocs/rep/tutorials/Tutorial-Rendertext.html
46
+ */
47
+ export declare const fonts: {
48
+ readonly droid: Font;
49
+ readonly pfTempestaSevenCondensed: Font;
50
+ readonly teamMeatFont10: Font;
51
+ readonly teamMeatFont12: Font;
52
+ readonly teamMeatFont16Bold: Font;
53
+ readonly terminus: Font;
54
+ readonly upheaval: Font;
55
+ };
package/cachedClasses.lua CHANGED
@@ -27,4 +27,24 @@ ____exports.musicManager = MusicManager()
27
27
  -- Caching the results of this constructor is safe, but caching other classes (like `Level` or
28
28
  -- `Room`) is not safe and can lead to the game crashing in certain situations.
29
29
  ____exports.sfxManager = SFXManager()
30
+ --- An object containing all 7 vanilla fonts that are pre-loaded and ready to use.
31
+ --
32
+ -- For more information on the vanilla fonts and to see what they look like, see:
33
+ -- https://wofsauge.github.io/IsaacDocs/rep/tutorials/Tutorial-Rendertext.html
34
+ ____exports.fonts = {
35
+ droid = Font(),
36
+ pfTempestaSevenCondensed = Font(),
37
+ teamMeatFont10 = Font(),
38
+ teamMeatFont12 = Font(),
39
+ teamMeatFont16Bold = Font(),
40
+ terminus = Font(),
41
+ upheaval = Font()
42
+ }
43
+ ____exports.fonts.droid:Load("font/droid.fnt")
44
+ ____exports.fonts.pfTempestaSevenCondensed:Load("font/pftempestasevencondensed.fnt")
45
+ ____exports.fonts.teamMeatFont10:Load("font/teammeatfont10.fnt")
46
+ ____exports.fonts.teamMeatFont12:Load("font/teammeatfont12.fnt")
47
+ ____exports.fonts.teamMeatFont16Bold:Load("font/teammeatfont16bold.fnt")
48
+ ____exports.fonts.terminus:Load("font/terminus.fnt")
49
+ ____exports.fonts.upheaval:Load("font/upheaval.fnt")
30
50
  return ____exports
@@ -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
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`. */
@@ -106,12 +115,25 @@ export declare const TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE = 10000;
106
115
  */
107
116
  export declare const UI_HEART_WIDTH = 12;
108
117
  /**
109
- * This is a safer version of the `Vector.One` constant. (Other mods can mutate this `Vector.One`,
110
- * so it is not safe to use.)
118
+ * This is a safer version of the `Vector.One` constant. (Other mods can mutate `Vector.One`, so it
119
+ * is not safe to use.)
111
120
  */
112
121
  export declare const VectorOne: Readonly<Vector>;
113
122
  /**
114
- * This is a safer version of the `Vector.Zero` constant. (Other mods can mutate `Vector.Zero`
115
- * vector, so it is not safe to use.)
123
+ * This is a safer version of the `Vector.Zero` constant. (Other mods can mutate `Vector.Zero`, so
124
+ * it is not safe to use.)
116
125
  */
117
126
  export declare const VectorZero: Readonly<Vector>;
127
+ /**
128
+ * This is a safer version of the `Color.Default` constant. (Other mods can mutate `Color.Default`,
129
+ * so it is not safe to use.)
130
+ *
131
+ * If you need to mutate this, make a copy first with the `copyColor` helper function.
132
+ */
133
+ export declare const ColorDefault: Readonly<Color>;
134
+ /**
135
+ * Equal to `KColor(1, 1, 1, 1)`.
136
+ *
137
+ * If you need to mutate this, make a copy first with the `copyKColor` helper function.
138
+ */
139
+ export declare const KColorDefault: Readonly<KColor>;
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`.
@@ -90,10 +97,19 @@ ____exports.TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE = 10000
90
97
  --- This is the number of draw coordinates that each heart spans on the UI in the upper left hand
91
98
  -- corner.
92
99
  ____exports.UI_HEART_WIDTH = 12
93
- --- This is a safer version of the `Vector.One` constant. (Other mods can mutate this `Vector.One`,
94
- -- so it is not safe to use.)
100
+ --- This is a safer version of the `Vector.One` constant. (Other mods can mutate `Vector.One`, so it
101
+ -- is not safe to use.)
95
102
  ____exports.VectorOne = Vector(1, 1)
96
- --- This is a safer version of the `Vector.Zero` constant. (Other mods can mutate `Vector.Zero`
97
- -- vector, so it is not safe to use.)
103
+ --- This is a safer version of the `Vector.Zero` constant. (Other mods can mutate `Vector.Zero`, so
104
+ -- it is not safe to use.)
98
105
  ____exports.VectorZero = Vector(0, 0)
106
+ --- This is a safer version of the `Color.Default` constant. (Other mods can mutate `Color.Default`,
107
+ -- so it is not safe to use.)
108
+ --
109
+ -- If you need to mutate this, make a copy first with the `copyColor` helper function.
110
+ ____exports.ColorDefault = Color(1, 1, 1)
111
+ --- Equal to `KColor(1, 1, 1, 1)`.
112
+ --
113
+ -- If you need to mutate this, make a copy first with the `copyKColor` helper function.
114
+ ____exports.KColorDefault = KColor(1, 1, 1, 1)
99
115
  return ____exports
@@ -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,202 @@
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
+ local ____customStageConstants = require("features.customStage.customStageConstants")
30
+ local ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH = ____customStageConstants.ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH
31
+ function getBackdropPNGPath(self, customStage, backdropKind, rng)
32
+ local pathArray = customStage.backdrop[backdropKind]
33
+ local path = getRandomArrayElement(nil, pathArray, rng)
34
+ return (customStage.backdrop.prefix .. path) .. customStage.backdrop.suffix
35
+ end
36
+ function spawnWallEntity(self, customStage, rng, isExtraWall)
37
+ local room = game:GetRoom()
38
+ local roomShape = room:GetRoomShape()
39
+ local subType = isExtraWall and BackdropEntitySubType.WALL_EXTRA or BackdropEntitySubType.WALL
40
+ local wallEffect = spawnEffectWithSeed(
41
+ nil,
42
+ BACKDROP_EFFECT_VARIANT,
43
+ subType,
44
+ VectorZero,
45
+ 1
46
+ )
47
+ wallEffect:AddEntityFlags(EntityFlag.RENDER_WALL)
48
+ local sprite = wallEffect:GetSprite()
49
+ sprite:Load(ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH .. "/wall-backdrop.anm2", false)
50
+ local wallLayersArray = isExtraWall and ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS or ROOM_SHAPE_WALL_ANM2_LAYERS
51
+ local numWallLayers = wallLayersArray[roomShape]
52
+ if numWallLayers == nil then
53
+ error("Failed to get the layers when creating the backdrop for custom stage: " .. customStage.name)
54
+ end
55
+ if isLRoom(nil, roomShape) then
56
+ local cornerPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.CORNER, rng)
57
+ sprite:ReplaceSpritesheet(0, cornerPNGPath)
58
+ end
59
+ for ____, layerID in ipairs(irange(nil, 1, numWallLayers)) do
60
+ local wallPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.WALL, rng)
61
+ sprite:ReplaceSpritesheet(layerID, wallPNGPath)
62
+ end
63
+ local topLeftPos = room:GetTopLeftPos()
64
+ local renderPos = topLeftPos + WALL_OFFSET
65
+ local modifiedOffset = renderPos / 40 * 26
66
+ wallEffect.SpriteOffset = modifiedOffset
67
+ sprite:LoadGraphics()
68
+ local roomShapeName = RoomShape[roomShape]
69
+ local animation = trimPrefix(nil, roomShapeName, "SHAPE_")
70
+ local modifiedAnimation = isExtraWall and animation .. "X" or animation
71
+ sprite:Play(modifiedAnimation, true)
72
+ end
73
+ function spawnSecondWallEntity(self, customStage, rng)
74
+ local room = game:GetRoom()
75
+ local roomShape = room:GetRoomShape()
76
+ local extraLayers = ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS[roomShape]
77
+ local roomShapeHasExtraLayers = extraLayers ~= nil
78
+ if roomShapeHasExtraLayers then
79
+ spawnWallEntity(nil, customStage, rng, true)
80
+ end
81
+ end
82
+ function spawnFloorEntity(self, customStage, rng)
83
+ local room = game:GetRoom()
84
+ local roomShape = room:GetRoomShape()
85
+ local floorEffect = spawnEffectWithSeed(
86
+ nil,
87
+ BACKDROP_EFFECT_VARIANT,
88
+ BackdropEntitySubType.FLOOR,
89
+ VectorZero,
90
+ 1
91
+ )
92
+ floorEffect:AddEntityFlags(EntityFlag.RENDER_FLOOR)
93
+ local sprite = floorEffect:GetSprite()
94
+ sprite:Load(ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH .. "/floor-backdrop.anm2", false)
95
+ local numFloorLayers = getNumFloorLayers(nil, roomShape)
96
+ if numFloorLayers ~= nil then
97
+ for ____, layerID in ipairs(erange(nil, 0, numFloorLayers)) do
98
+ local wallPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.WALL, rng)
99
+ sprite:ReplaceSpritesheet(layerID, wallPNGPath)
100
+ end
101
+ end
102
+ if isLRoom(nil, roomShape) then
103
+ for ____, layerID in ipairs({16, 17}) do
104
+ local LFloorPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.L_FLOOR, rng)
105
+ sprite:ReplaceSpritesheet(layerID, LFloorPNGPath)
106
+ end
107
+ end
108
+ if isNarrowRoom(nil, roomShape) then
109
+ for ____, layerID in ipairs({18, 19}) do
110
+ local NFloorPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.N_FLOOR, rng)
111
+ sprite:ReplaceSpritesheet(layerID, NFloorPNGPath)
112
+ end
113
+ end
114
+ local topLeftPos = room:GetTopLeftPos()
115
+ local renderPos = topLeftPos
116
+ local modifiedOffset = renderPos / 40 * 26
117
+ floorEffect.SpriteOffset = modifiedOffset
118
+ sprite:LoadGraphics()
119
+ local roomShapeName = RoomShape[roomShape]
120
+ local animation = trimPrefix(nil, roomShapeName, "SHAPE_")
121
+ sprite:Play(animation, true)
122
+ end
123
+ function getNumFloorLayers(self, roomShape)
124
+ repeat
125
+ local ____switch23 = roomShape
126
+ local ____cond23 = ____switch23 == RoomShape.SHAPE_1x1
127
+ if ____cond23 then
128
+ do
129
+ return 4
130
+ end
131
+ end
132
+ ____cond23 = ____cond23 or (____switch23 == RoomShape.SHAPE_1x2 or ____switch23 == RoomShape.SHAPE_2x1)
133
+ if ____cond23 then
134
+ do
135
+ return 8
136
+ end
137
+ end
138
+ ____cond23 = ____cond23 or ____switch23 == RoomShape.SHAPE_2x2
139
+ if ____cond23 then
140
+ do
141
+ return 16
142
+ end
143
+ end
144
+ do
145
+ do
146
+ return nil
147
+ end
148
+ end
149
+ until true
150
+ end
151
+ BackdropKind = BackdropKind or ({})
152
+ BackdropKind.N_FLOOR = "nFloors"
153
+ BackdropKind.L_FLOOR = "lFloors"
154
+ BackdropKind.WALL = "walls"
155
+ BackdropKind.CORNER = "corners"
156
+ BackdropEntitySubType = BackdropEntitySubType or ({})
157
+ BackdropEntitySubType.VANILLA_LADDER = 0
158
+ BackdropEntitySubType[BackdropEntitySubType.VANILLA_LADDER] = "VANILLA_LADDER"
159
+ BackdropEntitySubType.WALL = 1
160
+ BackdropEntitySubType[BackdropEntitySubType.WALL] = "WALL"
161
+ BackdropEntitySubType.WALL_EXTRA = 2
162
+ BackdropEntitySubType[BackdropEntitySubType.WALL_EXTRA] = "WALL_EXTRA"
163
+ BackdropEntitySubType.FLOOR = 3
164
+ BackdropEntitySubType[BackdropEntitySubType.FLOOR] = "FLOOR"
165
+ ROOM_SHAPE_WALL_ANM2_LAYERS = {
166
+ [RoomShape.SHAPE_1x1] = 44,
167
+ [RoomShape.IH] = 36,
168
+ [RoomShape.IV] = 28,
169
+ [RoomShape.SHAPE_1x2] = 58,
170
+ [RoomShape.IIV] = 42,
171
+ [RoomShape.SHAPE_2x1] = 63,
172
+ [RoomShape.IIH] = 62,
173
+ [RoomShape.SHAPE_2x2] = 63,
174
+ [RoomShape.LTL] = 63,
175
+ [RoomShape.LTR] = 63,
176
+ [RoomShape.LBL] = 63,
177
+ [RoomShape.LBR] = 63
178
+ }
179
+ ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS = {
180
+ [RoomShape.SHAPE_2x1] = 7,
181
+ [RoomShape.SHAPE_2x2] = 21,
182
+ [RoomShape.LTL] = 19,
183
+ [RoomShape.LTR] = 19,
184
+ [RoomShape.LBL] = 19,
185
+ [RoomShape.LBR] = 19
186
+ }
187
+ WALL_OFFSET = Vector(-80, -80)
188
+ BACKDROP_EFFECT_VARIANT = EffectVariant.LADDER
189
+ local BACKDROP_ROOM_TYPE_SET = __TS__New(Set, {RoomType.DEFAULT, RoomType.BOSS, RoomType.MINI_BOSS})
190
+ function ____exports.setBackdrop(self, customStage)
191
+ local room = game:GetRoom()
192
+ local roomType = room:GetType()
193
+ local decorationSeed = room:GetDecorationSeed()
194
+ local rng = newRNG(nil, decorationSeed)
195
+ if not BACKDROP_ROOM_TYPE_SET:has(roomType) then
196
+ return
197
+ end
198
+ spawnWallEntity(nil, customStage, rng, false)
199
+ spawnSecondWallEntity(nil, customStage, rng)
200
+ spawnFloorEntity(nil, customStage, rng)
201
+ end
202
+ return ____exports
@@ -0,0 +1 @@
1
+ export declare const ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH = "gfx/isaacscript-custom-stage";
@@ -0,0 +1,3 @@
1
+ local ____exports = {}
2
+ ____exports.ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH = "gfx/isaacscript-custom-stage"
3
+ return ____exports
@@ -1,3 +1,4 @@
1
+ import { EntityType } from "isaac-typescript-definitions";
1
2
  /**
2
3
  * Helper function to warp to a custom stage/level.
3
4
  *
@@ -5,3 +6,30 @@
5
6
  * more details: https://isaacscript.github.io/main/custom-stages/
6
7
  */
7
8
  export declare function setCustomStage(name: string, verbose?: boolean): void;
9
+ export declare function setCustomStageDebug(): void;
10
+ /**
11
+ * By default, unknown bosses will be drawn on the boss "versus" screen as "???". If your custom
12
+ * stage has custom bosses, you can use this function to register the corresponding graphic file
13
+ * files for them.
14
+ *
15
+ * For reference:
16
+ * - The vanilla name sprite for Monstro is located at "C:\Program Files
17
+ * (x86)\Steam\steamapps\common\The Binding of Isaac
18
+ * Rebirth\resources\gfx\ui\boss\bossname_20.0_monstro.png".
19
+ * - The vanilla portrait sprite for Monstro is located at "C:\Program Files
20
+ * (x86)\Steam\steamapps\common\The Binding of Isaac
21
+ * Rebirth\resources\gfx\ui\boss\portrait_20.0_monstro.png".
22
+ *
23
+ * (Note that boss metadata like this cannot be specified with the rest of the custom stage metadata
24
+ * in the "tsconfig.json" file because there is not a way to retrieve the name of an entity at
25
+ * run-time.)
26
+ *
27
+ * @param entityType The entity type of the custom boss.
28
+ * @param variant The variant of the custom boss.
29
+ * @param subType The sub-type of the custom boss.
30
+ * @param namePNGPath The full path to the PNG file that contains the name of the boss that will be
31
+ * displayed on the top of the boss "versus" screen.
32
+ * @param portraitPNGPath The full path to the PNG file that contains the portrait of the boss that
33
+ * will be displayed on the right side of the boss "versus" screen.
34
+ */
35
+ export declare function registerCustomBoss(entityType: EntityType, variant: int, subType: int, namePNGPath: string, portraitPNGPath: string): void;
@@ -1,6 +1,7 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local ____exports = {}
4
+ local postRoomTransition
4
5
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
5
6
  local Direction = ____isaac_2Dtypescript_2Ddefinitions.Direction
6
7
  local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
@@ -10,8 +11,15 @@ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
10
11
  local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
11
12
  local ____cachedClasses = require("cachedClasses")
12
13
  local game = ____cachedClasses.game
14
+ local ____reorderedCallbacks = require("callbacks.reorderedCallbacks")
15
+ local reorderedCallbacksSetStage = ____reorderedCallbacks.reorderedCallbacksSetStage
16
+ local ____entity = require("functions.entity")
17
+ local getEntityIDFromConstituents = ____entity.getEntityIDFromConstituents
13
18
  local ____log = require("functions.log")
19
+ local log = ____log.log
14
20
  local logError = ____log.logError
21
+ local ____playerCenter = require("functions.playerCenter")
22
+ local movePlayersToCenter = ____playerCenter.movePlayersToCenter
15
23
  local ____rng = require("functions.rng")
16
24
  local newRNG = ____rng.newRNG
17
25
  local ____roomData = require("functions.roomData")
@@ -21,11 +29,20 @@ local getRooms = ____rooms.getRooms
21
29
  local ____stage = require("functions.stage")
22
30
  local getGotoCommand = ____stage.getGotoCommand
23
31
  local setStage = ____stage.setStage
32
+ local ____runNextRoom = require("features.runNextRoom")
33
+ local runNextRoom = ____runNextRoom.runNextRoom
24
34
  local ____util = require("features.customStage.util")
25
35
  local getRandomCustomStageRoom = ____util.getRandomCustomStageRoom
26
36
  local ____v = require("features.customStage.v")
37
+ local v = ____v.default
38
+ local customBossPNGPaths = ____v.customBossPNGPaths
27
39
  local customStageCachedRoomData = ____v.customStageCachedRoomData
28
40
  local customStagesMap = ____v.customStagesMap
41
+ local ____versusScreen = require("features.customStage.versusScreen")
42
+ local playVersusScreenAnimation = ____versusScreen.playVersusScreenAnimation
43
+ function postRoomTransition(self)
44
+ movePlayersToCenter(nil)
45
+ end
29
46
  --- Helper function to warp to a custom stage/level.
30
47
  --
31
48
  -- Custom stages/levels must first be defined in the "tsconfig.json" file. See the documentation for
@@ -43,6 +60,7 @@ function ____exports.setCustomStage(self, name, verbose)
43
60
  local seeds = game:GetSeeds()
44
61
  local startSeed = seeds:GetStartSeed()
45
62
  local rng = newRNG(nil, startSeed)
63
+ v.run.currentCustomStage = customStage
46
64
  setStage(nil, customStage.baseStage, customStage.baseStageType)
47
65
  for ____, room in ipairs(getRooms(nil)) do
48
66
  do
@@ -88,7 +106,46 @@ function ____exports.setCustomStage(self, name, verbose)
88
106
  end
89
107
  ::__continue4::
90
108
  end
91
- level:SetStage(-1, StageType.ORIGINAL)
109
+ local stage = -1
110
+ local stageType = StageType.WRATH_OF_THE_LAMB
111
+ level:SetStage(stage, stageType)
112
+ reorderedCallbacksSetStage(nil, stage, stageType)
92
113
  game:StartRoomTransition(startingRoomGridIndex, Direction.NO_DIRECTION, RoomTransitionAnim.FADE)
114
+ runNextRoom(nil, postRoomTransition)
115
+ end
116
+ function ____exports.setCustomStageDebug(self)
117
+ local customStage = v.run.currentCustomStage
118
+ if customStage == nil then
119
+ log("No custom stage is currently loaded.")
120
+ return
121
+ end
122
+ playVersusScreenAnimation(nil, customStage, true)
123
+ end
124
+ --- By default, unknown bosses will be drawn on the boss "versus" screen as "???". If your custom
125
+ -- stage has custom bosses, you can use this function to register the corresponding graphic file
126
+ -- files for them.
127
+ --
128
+ -- For reference:
129
+ -- - The vanilla name sprite for Monstro is located at "C:\Program Files
130
+ -- (x86)\Steam\steamapps\common\The Binding of Isaac
131
+ -- Rebirth\resources\gfx\ui\boss\bossname_20.0_monstro.png".
132
+ -- - The vanilla portrait sprite for Monstro is located at "C:\Program Files
133
+ -- (x86)\Steam\steamapps\common\The Binding of Isaac
134
+ -- Rebirth\resources\gfx\ui\boss\portrait_20.0_monstro.png".
135
+ --
136
+ -- (Note that boss metadata like this cannot be specified with the rest of the custom stage metadata
137
+ -- in the "tsconfig.json" file because there is not a way to retrieve the name of an entity at
138
+ -- run-time.)
139
+ --
140
+ -- @param entityType The entity type of the custom boss.
141
+ -- @param variant The variant of the custom boss.
142
+ -- @param subType The sub-type of the custom boss.
143
+ -- @param namePNGPath The full path to the PNG file that contains the name of the boss that will be
144
+ -- displayed on the top of the boss "versus" screen.
145
+ -- @param portraitPNGPath The full path to the PNG file that contains the portrait of the boss that
146
+ -- will be displayed on the right side of the boss "versus" screen.
147
+ function ____exports.registerCustomBoss(self, entityType, variant, subType, namePNGPath, portraitPNGPath)
148
+ local entityID = getEntityIDFromConstituents(nil, entityType, variant, subType)
149
+ customBossPNGPaths:set(entityID, {namePNGPath, portraitPNGPath})
93
150
  end
94
151
  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;
@@ -3,12 +3,37 @@ local Map = ____lualib.Map
3
3
  local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
- local getRoomTypeMap
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
7
11
  local ____array = require("functions.array")
8
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
9
17
  local metadataJSON = require("features.customStage.metadata")
18
+ local ____streakText = require("features.customStage.streakText")
19
+ local streakTextPostRender = ____streakText.streakTextPostRender
10
20
  local ____v = require("features.customStage.v")
21
+ local v = ____v.default
11
22
  local customStagesMap = ____v.customStagesMap
23
+ local ____versusScreen = require("features.customStage.versusScreen")
24
+ local playVersusScreenAnimation = ____versusScreen.playVersusScreenAnimation
25
+ local versusScreenPostRender = ____versusScreen.versusScreenPostRender
26
+ function initRoomTypeMaps(self)
27
+ if not isArray(nil, metadataJSON) then
28
+ error("The IsaacScript standard library attempted to read the custom stage metadata from the \"metadata.lua\" file, but it was not an array.")
29
+ end
30
+ local customStagesLua = metadataJSON
31
+ for ____, customStageLua in ipairs(customStagesLua) do
32
+ local roomTypeMap = getRoomTypeMap(nil, customStageLua)
33
+ local customStage = __TS__ObjectAssign({}, customStageLua, {roomTypeMap = roomTypeMap})
34
+ customStagesMap:set(customStage.name, customStage)
35
+ end
36
+ end
12
37
  function getRoomTypeMap(self, customStageLua)
13
38
  local roomTypeMap = __TS__New(Map)
14
39
  for ____, roomMetadata in ipairs(customStageLua.roomsMetadata) do
@@ -34,15 +59,26 @@ function getRoomTypeMap(self, customStageLua)
34
59
  end
35
60
  return roomTypeMap
36
61
  end
37
- function ____exports.customStageInit(self)
38
- local customStagesLua = metadataJSON
39
- if not isArray(nil, customStagesLua) then
40
- error("The IsaacScript standard library attempted to read the custom stage metadata from the \"metadata.lua\" file, but it was not an array.")
62
+ function postRender(self)
63
+ local customStage = v.run.currentCustomStage
64
+ if customStage == nil then
65
+ return
41
66
  end
42
- for ____, customStageLua in ipairs(customStagesLua) do
43
- local roomTypeMap = getRoomTypeMap(nil, customStageLua)
44
- local customStage = __TS__ObjectAssign({}, customStageLua, {roomTypeMap = roomTypeMap})
45
- customStagesMap:set(customStage.name, customStage)
67
+ streakTextPostRender(nil, customStage)
68
+ versusScreenPostRender(nil)
69
+ end
70
+ function postNewRoomReordered(self)
71
+ local customStage = v.run.currentCustomStage
72
+ if customStage == nil then
73
+ return
46
74
  end
75
+ setBackdrop(nil, customStage)
76
+ playVersusScreenAnimation(nil, customStage)
77
+ end
78
+ function ____exports.customStageInit(self, mod)
79
+ saveDataManager(nil, "customStage", v)
80
+ initRoomTypeMaps(nil)
81
+ mod:AddCallback(ModCallback.POST_RENDER, postRender)
82
+ mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
47
83
  end
48
84
  return ____exports
@@ -0,0 +1,2 @@
1
+ import { CustomStage } from "../../interfaces/CustomStage";
2
+ export declare function streakTextPostRender(customStage: CustomStage): void;
@@ -0,0 +1,22 @@
1
+ local ____exports = {}
2
+ local ____cachedClasses = require("cachedClasses")
3
+ local fonts = ____cachedClasses.fonts
4
+ local ____constants = require("constants")
5
+ local KColorDefault = ____constants.KColorDefault
6
+ local ____ui = require("functions.ui")
7
+ local getScreenBottomCenterPos = ____ui.getScreenBottomCenterPos
8
+ local ____v = require("features.customStage.v")
9
+ local v = ____v.default
10
+ local STREAK_TEXT_BOTTOM_OFFSET = Vector(0, -60)
11
+ function ____exports.streakTextPostRender(self, customStage)
12
+ if not v.run.showingStreakText then
13
+ return
14
+ end
15
+ local font = fonts.upheaval
16
+ local length = font:GetStringWidthUTF8(customStage.name)
17
+ local bottomCenterPos = getScreenBottomCenterPos(nil)
18
+ local position = bottomCenterPos + STREAK_TEXT_BOTTOM_OFFSET
19
+ local adjustedX = position.X - length / 2
20
+ font:DrawString(customStage.name, adjustedX, position.Y, KColorDefault)
21
+ end
22
+ return ____exports
@@ -1,6 +1,16 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { CustomStage } from "../../interfaces/CustomStage";
3
+ declare const v: {
4
+ run: {
5
+ currentCustomStage: CustomStage | null;
6
+ showingStreakText: boolean;
7
+ showingBossVersusScreen: boolean;
8
+ };
9
+ };
10
+ export default v;
3
11
  /** Indexed by custom stage name. */
4
12
  export declare const customStagesMap: Map<string, CustomStage>;
5
13
  /** Indexed by room variant. */
6
14
  export declare const customStageCachedRoomData: Map<number, Readonly<RoomConfig>>;
15
+ /** Indexed by entity ID. */
16
+ export declare const customBossPNGPaths: Map<string, [namePNGPath: string, portraitPNGPath: string]>;