isaacscript-common 6.2.1 → 6.5.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 (109) 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/enums/DecorationVariant.d.ts +9 -0
  10. package/enums/DecorationVariant.lua +7 -0
  11. package/enums/RockAltType.d.ts +7 -0
  12. package/enums/RockAltType.lua +13 -0
  13. package/features/customGridEntity.d.ts +2 -2
  14. package/features/customGridEntity.lua +7 -5
  15. package/features/customStage/backdrop.d.ts +2 -0
  16. package/features/customStage/backdrop.lua +211 -0
  17. package/features/customStage/customStageConstants.d.ts +1 -0
  18. package/features/customStage/customStageConstants.lua +3 -0
  19. package/features/customStage/exports.d.ts +28 -0
  20. package/features/customStage/exports.lua +58 -1
  21. package/features/customStage/gridEntities.d.ts +18 -0
  22. package/features/customStage/gridEntities.lua +215 -0
  23. package/features/customStage/init.d.ts +2 -1
  24. package/features/customStage/init.lua +71 -9
  25. package/features/customStage/streakText.d.ts +2 -0
  26. package/features/customStage/streakText.lua +22 -0
  27. package/features/customStage/v.d.ts +10 -0
  28. package/features/customStage/v.lua +4 -0
  29. package/features/customStage/versusScreen.d.ts +3 -0
  30. package/features/customStage/versusScreen.lua +201 -0
  31. package/features/debugDisplay/debugDisplay.lua +2 -0
  32. package/features/debugDisplay/exports.d.ts +108 -0
  33. package/features/debugDisplay/exports.lua +145 -0
  34. package/features/debugDisplay/v.d.ts +2 -0
  35. package/features/debugDisplay/v.lua +9 -0
  36. package/features/deployJSONRoom.lua +6 -2
  37. package/features/extraConsoleCommands/init.lua +10 -1
  38. package/features/extraConsoleCommands/listCommands.d.ts +21 -6
  39. package/features/extraConsoleCommands/listCommands.lua +50 -19
  40. package/features/extraConsoleCommands/v.d.ts +1 -0
  41. package/features/extraConsoleCommands/v.lua +2 -1
  42. package/features/pause.d.ts +11 -0
  43. package/features/pause.lua +71 -0
  44. package/features/runNextRoom.d.ts +8 -0
  45. package/features/runNextRoom.lua +40 -0
  46. package/features/saveDataManager/exports.lua +2 -2
  47. package/features/saveDataManager/load.lua +3 -3
  48. package/features/saveDataManager/main.lua +3 -3
  49. package/features/saveDataManager/merge.lua +2 -2
  50. package/features/saveDataManager/save.lua +3 -3
  51. package/features/saveDataManager/{constants.d.ts → saveDataManagerConstants.d.ts} +0 -0
  52. package/features/saveDataManager/{constants.lua → saveDataManagerConstants.lua} +0 -0
  53. package/functions/chargeBar.lua +4 -6
  54. package/functions/color.d.ts +0 -2
  55. package/functions/color.lua +0 -4
  56. package/functions/deepCopy.lua +2 -2
  57. package/functions/direction.d.ts +1 -1
  58. package/functions/doors.d.ts +12 -7
  59. package/functions/doors.lua +14 -11
  60. package/functions/entity.d.ts +5 -0
  61. package/functions/entity.lua +13 -0
  62. package/functions/gridEntity.d.ts +39 -0
  63. package/functions/gridEntity.lua +83 -2
  64. package/functions/kColor.d.ts +0 -2
  65. package/functions/kColor.lua +0 -4
  66. package/functions/log.lua +2 -1
  67. package/functions/pickups.d.ts +9 -9
  68. package/functions/playerCenter.lua +4 -5
  69. package/functions/playerIndex.d.ts +3 -0
  70. package/functions/playerIndex.lua +3 -0
  71. package/functions/roomShape.d.ts +10 -4
  72. package/functions/roomShape.lua +15 -2
  73. package/functions/run.d.ts +7 -0
  74. package/functions/run.lua +16 -4
  75. package/functions/sprite.d.ts +1 -1
  76. package/functions/sprite.lua +1 -1
  77. package/functions/ui.d.ts +2 -0
  78. package/functions/ui.lua +8 -0
  79. package/functions/utils.d.ts +6 -4
  80. package/functions/utils.lua +6 -4
  81. package/index.d.ts +1 -1
  82. package/index.lua +2 -0
  83. package/initFeatures.lua +7 -1
  84. package/interfaces/Corner.d.ts +6 -0
  85. package/interfaces/Corner.lua +2 -0
  86. package/interfaces/CustomStageLua.d.ts +236 -63
  87. package/objects/backdropTypeToRockAltType.d.ts +6 -0
  88. package/objects/backdropTypeToRockAltType.lua +69 -0
  89. package/objects/bossNamePNGFileNames.d.ts +5 -0
  90. package/objects/bossNamePNGFileNames.lua +108 -0
  91. package/objects/bossPortraitPNGFileNames.d.ts +5 -0
  92. package/objects/bossPortraitPNGFileNames.lua +108 -0
  93. package/objects/colors.d.ts +15 -8
  94. package/objects/colors.lua +9 -2
  95. package/objects/playerNamePNGFileNames.d.ts +5 -0
  96. package/objects/playerNamePNGFileNames.lua +49 -0
  97. package/objects/playerPortraitPNGFileNames.d.ts +5 -0
  98. package/objects/playerPortraitPNGFileNames.lua +49 -0
  99. package/objects/roomShapeCorners.d.ts +6 -0
  100. package/objects/roomShapeCorners.lua +259 -0
  101. package/objects/roomShapeToBottomRightPosition.d.ts +1 -1
  102. package/objects/roomShapeToTopLeftPosition.d.ts +1 -1
  103. package/objects/versusScreenBackgroundColors.d.ts +5 -0
  104. package/objects/versusScreenBackgroundColors.lua +38 -0
  105. package/objects/versusScreenDirtSpotColors.d.ts +5 -0
  106. package/objects/versusScreenDirtSpotColors.lua +38 -0
  107. package/package.json +2 -2
  108. package/sets/narrowRoomShapesSet.d.ts +2 -0
  109. 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,9 @@
1
+ export declare enum DecorationVariant {
2
+ VANILLA_DECORATION = 0,
3
+ /**
4
+ * The vanilla game does not support any custom grid entities. Under the hood, IsaacScript allows
5
+ * for custom grid entities by using decorations with this variant to represent custom grid
6
+ * entities.
7
+ */
8
+ CUSTOM_GRID_ENTITY = 1
9
+ }
@@ -0,0 +1,7 @@
1
+ local ____exports = {}
2
+ ____exports.DecorationVariant = {}
3
+ ____exports.DecorationVariant.VANILLA_DECORATION = 0
4
+ ____exports.DecorationVariant[____exports.DecorationVariant.VANILLA_DECORATION] = "VANILLA_DECORATION"
5
+ ____exports.DecorationVariant.CUSTOM_GRID_ENTITY = 1
6
+ ____exports.DecorationVariant[____exports.DecorationVariant.CUSTOM_GRID_ENTITY] = "CUSTOM_GRID_ENTITY"
7
+ return ____exports
@@ -0,0 +1,7 @@
1
+ export declare enum RockAltType {
2
+ URN = 0,
3
+ MUSHROOM = 1,
4
+ SKULL = 2,
5
+ POLYP = 3,
6
+ BUCKET = 4
7
+ }
@@ -0,0 +1,13 @@
1
+ local ____exports = {}
2
+ ____exports.RockAltType = {}
3
+ ____exports.RockAltType.URN = 0
4
+ ____exports.RockAltType[____exports.RockAltType.URN] = "URN"
5
+ ____exports.RockAltType.MUSHROOM = 1
6
+ ____exports.RockAltType[____exports.RockAltType.MUSHROOM] = "MUSHROOM"
7
+ ____exports.RockAltType.SKULL = 2
8
+ ____exports.RockAltType[____exports.RockAltType.SKULL] = "SKULL"
9
+ ____exports.RockAltType.POLYP = 3
10
+ ____exports.RockAltType[____exports.RockAltType.POLYP] = "POLYP"
11
+ ____exports.RockAltType.BUCKET = 4
12
+ ____exports.RockAltType[____exports.RockAltType.BUCKET] = "BUCKET"
13
+ return ____exports
@@ -3,8 +3,8 @@ import { GridCollisionClass, GridEntityType } from "isaac-typescript-definitions
3
3
  * Helper function to spawn a custom grid entity.
4
4
  *
5
5
  * This is an IsaacScript feature because the vanilla game does not support any custom grid
6
- * entities. Under the hood, IsaacScript accomplishes this by using decorations to represent custom
7
- * grid entities.
6
+ * entities. Under the hood, IsaacScript accomplishes this by using decorations with an arbitrary
7
+ * non-zero variant to represent custom grid entities.
8
8
  *
9
9
  * Once a custom grid entity is spawned, you can take advantage of the custom grid callbacks such as
10
10
  * `POST_GRID_ENTITY_CUSTOM_UPDATE`.
@@ -10,13 +10,15 @@ local ____cachedClasses = require("cachedClasses")
10
10
  local game = ____cachedClasses.game
11
11
  local ____DefaultMap = require("classes.DefaultMap")
12
12
  local DefaultMap = ____DefaultMap.DefaultMap
13
+ local ____DecorationVariant = require("enums.DecorationVariant")
14
+ local DecorationVariant = ____DecorationVariant.DecorationVariant
13
15
  local ____ModCallbackCustom = require("enums.ModCallbackCustom")
14
16
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
15
17
  local ____featuresInitialized = require("featuresInitialized")
16
18
  local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
17
19
  local ____gridEntity = require("functions.gridEntity")
18
20
  local removeGrid = ____gridEntity.removeGrid
19
- local spawnGrid = ____gridEntity.spawnGrid
21
+ local spawnGridWithVariant = ____gridEntity.spawnGridWithVariant
20
22
  local ____roomData = require("functions.roomData")
21
23
  local getRoomListIndex = ____roomData.getRoomListIndex
22
24
  local ____vector = require("functions.vector")
@@ -60,8 +62,8 @@ end
60
62
  --- Helper function to spawn a custom grid entity.
61
63
  --
62
64
  -- This is an IsaacScript feature because the vanilla game does not support any custom grid
63
- -- entities. Under the hood, IsaacScript accomplishes this by using decorations to represent custom
64
- -- grid entities.
65
+ -- entities. Under the hood, IsaacScript accomplishes this by using decorations with an arbitrary
66
+ -- non-zero variant to represent custom grid entities.
65
67
  --
66
68
  -- Once a custom grid entity is spawned, you can take advantage of the custom grid callbacks such as
67
69
  -- `POST_GRID_ENTITY_CUSTOM_UPDATE`.
@@ -84,8 +86,8 @@ function ____exports.spawnCustomGrid(self, gridEntityTypeCustom, gridIndexOrPosi
84
86
  local roomListIndex = getRoomListIndex(nil)
85
87
  local gridIndex = isVector(nil, gridIndexOrPosition) and room:GetGridIndex(gridIndexOrPosition) or gridIndexOrPosition
86
88
  local existingGridEntity = room:GetGridEntity(gridIndex)
87
- local isExistingDecoration = existingGridEntity ~= nil and existingGridEntity:GetType() == GridEntityType.DECORATION
88
- local decoration = isExistingDecoration and existingGridEntity or spawnGrid(nil, GridEntityType.DECORATION, gridIndexOrPosition)
89
+ local isExistingDecoration = existingGridEntity ~= nil and existingGridEntity:GetType() == GridEntityType.DECORATION and existingGridEntity:GetVariant() == DecorationVariant.CUSTOM_GRID_ENTITY
90
+ local decoration = isExistingDecoration and existingGridEntity or spawnGridWithVariant(nil, GridEntityType.DECORATION, DecorationVariant.CUSTOM_GRID_ENTITY, gridIndexOrPosition)
89
91
  if decoration == nil then
90
92
  error("Failed to spawn a decoration for a custom grid entity.")
91
93
  end
@@ -0,0 +1,2 @@
1
+ import { CustomStage } from "../../interfaces/CustomStage";
2
+ export declare function setBackdrop(customStage: CustomStage): void;
@@ -0,0 +1,211 @@
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, DEFAULT_BACKDROP, 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 backdrop = customStage.backdrop == nil and DEFAULT_BACKDROP or customStage.backdrop
33
+ local pathArray = backdrop[backdropKind]
34
+ local path = getRandomArrayElement(nil, pathArray, rng)
35
+ return (backdrop.prefix .. path) .. backdrop.suffix
36
+ end
37
+ function spawnWallEntity(self, customStage, rng, isExtraWall)
38
+ local room = game:GetRoom()
39
+ local roomShape = room:GetRoomShape()
40
+ local subType = isExtraWall and BackdropEntitySubType.WALL_EXTRA or BackdropEntitySubType.WALL
41
+ local wallEffect = spawnEffectWithSeed(
42
+ nil,
43
+ BACKDROP_EFFECT_VARIANT,
44
+ subType,
45
+ VectorZero,
46
+ 1
47
+ )
48
+ wallEffect:AddEntityFlags(EntityFlag.RENDER_WALL)
49
+ local sprite = wallEffect:GetSprite()
50
+ sprite:Load(ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH .. "/wall-backdrop.anm2", false)
51
+ local wallLayersArray = isExtraWall and ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS or ROOM_SHAPE_WALL_ANM2_LAYERS
52
+ local numWallLayers = wallLayersArray[roomShape]
53
+ if numWallLayers == nil then
54
+ error("Failed to get the layers when creating the backdrop for custom stage: " .. customStage.name)
55
+ end
56
+ if isLRoom(nil, roomShape) then
57
+ local cornerPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.CORNER, rng)
58
+ sprite:ReplaceSpritesheet(0, cornerPNGPath)
59
+ end
60
+ for ____, layerID in ipairs(irange(nil, 1, numWallLayers)) do
61
+ local wallPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.WALL, rng)
62
+ sprite:ReplaceSpritesheet(layerID, wallPNGPath)
63
+ end
64
+ local topLeftPos = room:GetTopLeftPos()
65
+ local renderPos = topLeftPos + WALL_OFFSET
66
+ local modifiedOffset = renderPos / 40 * 26
67
+ wallEffect.SpriteOffset = modifiedOffset
68
+ sprite:LoadGraphics()
69
+ local roomShapeName = RoomShape[roomShape]
70
+ local animation = trimPrefix(nil, roomShapeName, "SHAPE_")
71
+ local modifiedAnimation = isExtraWall and animation .. "X" or animation
72
+ sprite:Play(modifiedAnimation, true)
73
+ end
74
+ function spawnSecondWallEntity(self, customStage, rng)
75
+ local room = game:GetRoom()
76
+ local roomShape = room:GetRoomShape()
77
+ local extraLayers = ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS[roomShape]
78
+ local roomShapeHasExtraLayers = extraLayers ~= nil
79
+ if roomShapeHasExtraLayers then
80
+ spawnWallEntity(nil, customStage, rng, true)
81
+ end
82
+ end
83
+ function spawnFloorEntity(self, customStage, rng)
84
+ local room = game:GetRoom()
85
+ local roomShape = room:GetRoomShape()
86
+ local floorEffect = spawnEffectWithSeed(
87
+ nil,
88
+ BACKDROP_EFFECT_VARIANT,
89
+ BackdropEntitySubType.FLOOR,
90
+ VectorZero,
91
+ 1
92
+ )
93
+ floorEffect:AddEntityFlags(EntityFlag.RENDER_FLOOR)
94
+ local sprite = floorEffect:GetSprite()
95
+ sprite:Load(ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH .. "/floor-backdrop.anm2", false)
96
+ local numFloorLayers = getNumFloorLayers(nil, roomShape)
97
+ if numFloorLayers ~= nil then
98
+ for ____, layerID in ipairs(erange(nil, 0, numFloorLayers)) do
99
+ local wallPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.WALL, rng)
100
+ sprite:ReplaceSpritesheet(layerID, wallPNGPath)
101
+ end
102
+ end
103
+ if isLRoom(nil, roomShape) then
104
+ for ____, layerID in ipairs({16, 17}) do
105
+ local LFloorPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.L_FLOOR, rng)
106
+ sprite:ReplaceSpritesheet(layerID, LFloorPNGPath)
107
+ end
108
+ end
109
+ if isNarrowRoom(nil, roomShape) then
110
+ for ____, layerID in ipairs({18, 19}) do
111
+ local NFloorPNGPath = getBackdropPNGPath(nil, customStage, BackdropKind.N_FLOOR, rng)
112
+ sprite:ReplaceSpritesheet(layerID, NFloorPNGPath)
113
+ end
114
+ end
115
+ local topLeftPos = room:GetTopLeftPos()
116
+ local renderPos = topLeftPos
117
+ local modifiedOffset = renderPos / 40 * 26
118
+ floorEffect.SpriteOffset = modifiedOffset
119
+ sprite:LoadGraphics()
120
+ local roomShapeName = RoomShape[roomShape]
121
+ local animation = trimPrefix(nil, roomShapeName, "SHAPE_")
122
+ sprite:Play(animation, true)
123
+ end
124
+ function getNumFloorLayers(self, roomShape)
125
+ repeat
126
+ local ____switch23 = roomShape
127
+ local ____cond23 = ____switch23 == RoomShape.SHAPE_1x1
128
+ if ____cond23 then
129
+ do
130
+ return 4
131
+ end
132
+ end
133
+ ____cond23 = ____cond23 or (____switch23 == RoomShape.SHAPE_1x2 or ____switch23 == RoomShape.SHAPE_2x1)
134
+ if ____cond23 then
135
+ do
136
+ return 8
137
+ end
138
+ end
139
+ ____cond23 = ____cond23 or ____switch23 == RoomShape.SHAPE_2x2
140
+ if ____cond23 then
141
+ do
142
+ return 16
143
+ end
144
+ end
145
+ do
146
+ do
147
+ return nil
148
+ end
149
+ end
150
+ until true
151
+ end
152
+ BackdropKind = BackdropKind or ({})
153
+ BackdropKind.N_FLOOR = "nFloors"
154
+ BackdropKind.L_FLOOR = "lFloors"
155
+ BackdropKind.WALL = "walls"
156
+ BackdropKind.CORNER = "corners"
157
+ BackdropEntitySubType = BackdropEntitySubType or ({})
158
+ BackdropEntitySubType.VANILLA_LADDER = 0
159
+ BackdropEntitySubType[BackdropEntitySubType.VANILLA_LADDER] = "VANILLA_LADDER"
160
+ BackdropEntitySubType.WALL = 1
161
+ BackdropEntitySubType[BackdropEntitySubType.WALL] = "WALL"
162
+ BackdropEntitySubType.WALL_EXTRA = 2
163
+ BackdropEntitySubType[BackdropEntitySubType.WALL_EXTRA] = "WALL_EXTRA"
164
+ BackdropEntitySubType.FLOOR = 3
165
+ BackdropEntitySubType[BackdropEntitySubType.FLOOR] = "FLOOR"
166
+ DEFAULT_BACKDROP = {
167
+ prefix = ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH .. "/backdrop",
168
+ suffix = ".png",
169
+ nFloors = {"nfloor"},
170
+ lFloors = {"lfloor"},
171
+ walls = {"wall"},
172
+ corners = {"corner"}
173
+ }
174
+ ROOM_SHAPE_WALL_ANM2_LAYERS = {
175
+ [RoomShape.SHAPE_1x1] = 44,
176
+ [RoomShape.IH] = 36,
177
+ [RoomShape.IV] = 28,
178
+ [RoomShape.SHAPE_1x2] = 58,
179
+ [RoomShape.IIV] = 42,
180
+ [RoomShape.SHAPE_2x1] = 63,
181
+ [RoomShape.IIH] = 62,
182
+ [RoomShape.SHAPE_2x2] = 63,
183
+ [RoomShape.LTL] = 63,
184
+ [RoomShape.LTR] = 63,
185
+ [RoomShape.LBL] = 63,
186
+ [RoomShape.LBR] = 63
187
+ }
188
+ ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS = {
189
+ [RoomShape.SHAPE_2x1] = 7,
190
+ [RoomShape.SHAPE_2x2] = 21,
191
+ [RoomShape.LTL] = 19,
192
+ [RoomShape.LTR] = 19,
193
+ [RoomShape.LBL] = 19,
194
+ [RoomShape.LBR] = 19
195
+ }
196
+ WALL_OFFSET = Vector(-80, -80)
197
+ BACKDROP_EFFECT_VARIANT = EffectVariant.LADDER
198
+ local BACKDROP_ROOM_TYPE_SET = __TS__New(Set, {RoomType.DEFAULT, RoomType.BOSS, RoomType.MINI_BOSS})
199
+ function ____exports.setBackdrop(self, customStage)
200
+ local room = game:GetRoom()
201
+ local roomType = room:GetType()
202
+ local decorationSeed = room:GetDecorationSeed()
203
+ local rng = newRNG(nil, decorationSeed)
204
+ if not BACKDROP_ROOM_TYPE_SET:has(roomType) then
205
+ return
206
+ end
207
+ spawnWallEntity(nil, customStage, rng, false)
208
+ spawnSecondWallEntity(nil, customStage, rng)
209
+ spawnFloorEntity(nil, customStage, rng)
210
+ end
211
+ 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
@@ -0,0 +1,18 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ import { CustomStage } from "../../interfaces/CustomStage";
3
+ /** For `GridEntityType.DECORATION` (1) */
4
+ export declare function setCustomDecorationGraphics(customStage: CustomStage, gridEntity: GridEntity): void;
5
+ /** For `GridEntityType.ROCK` (2) */
6
+ export declare function setCustomRockGraphics(customStage: CustomStage, gridEntity: GridEntity): void;
7
+ /** For `GridEntityType.PIT` (7) */
8
+ export declare function setCustomPitGraphics(customStage: CustomStage, gridEntity: GridEntity): void;
9
+ /** For GridEntityType.DOOR (16) */
10
+ export declare function setCustomDoorGraphics(customStage: CustomStage, gridEntity: GridEntity): void;
11
+ /**
12
+ * The rewards are based on the ones from the wiki:
13
+ * https://bindingofisaacrebirth.fandom.com/wiki/Rocks#Urns
14
+ *
15
+ * On the bugged stage of -1, only urns will spawn, so we do not have to handle the case of mushroom
16
+ * rewards, skull rewards, and so on.
17
+ */
18
+ export declare function removeUrnRewards(customStage: CustomStage, gridEntity: GridEntity): void;