isaacscript-common 6.10.2 → 6.11.2

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 (169) hide show
  1. package/dist/callbacks/postFlip.lua +2 -2
  2. package/dist/callbacks/postPlayerFatalDamage.lua +1 -1
  3. package/dist/callbacks/postPlayerInitFirst.d.ts +2 -0
  4. package/dist/callbacks/postPlayerInitFirst.d.ts.map +1 -0
  5. package/dist/callbacks/postPlayerInitFirst.lua +42 -0
  6. package/dist/callbacks/postPlayerInitLate.lua +5 -5
  7. package/dist/callbacks/postPlayerReorderedCallbacks.d.ts +2 -0
  8. package/dist/callbacks/postPlayerReorderedCallbacks.d.ts.map +1 -0
  9. package/dist/callbacks/{postPlayerReordered.lua → postPlayerReorderedCallbacks.lua} +11 -37
  10. package/dist/callbacks/subscriptions/postFirstFlip.d.ts +1 -1
  11. package/dist/callbacks/subscriptions/postFirstFlip.d.ts.map +1 -1
  12. package/dist/callbacks/subscriptions/postFirstFlip.lua +2 -2
  13. package/dist/callbacks/subscriptions/postFlip.d.ts +1 -1
  14. package/dist/callbacks/subscriptions/postFlip.d.ts.map +1 -1
  15. package/dist/callbacks/subscriptions/postFlip.lua +2 -2
  16. package/dist/callbacks/subscriptions/{postPlayerInitReordered.d.ts → postPlayerInitFirst.d.ts} +2 -2
  17. package/dist/callbacks/subscriptions/postPlayerInitFirst.d.ts.map +1 -0
  18. package/dist/callbacks/subscriptions/{postPlayerInitReordered.lua → postPlayerInitFirst.lua} +3 -3
  19. package/dist/enums/ModCallbackCustom.d.ts +19 -17
  20. package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
  21. package/dist/enums/ModCallbackCustom.lua +3 -3
  22. package/dist/enums/private/StageTravelState.d.ts +9 -0
  23. package/dist/enums/private/StageTravelState.d.ts.map +1 -0
  24. package/dist/enums/private/StageTravelState.lua +15 -0
  25. package/dist/enums/private/TrapdoorAnimation.d.ts +6 -0
  26. package/dist/enums/private/TrapdoorAnimation.d.ts.map +1 -0
  27. package/dist/enums/private/TrapdoorAnimation.lua +6 -0
  28. package/dist/features/customGridEntity.d.ts +8 -5
  29. package/dist/features/customGridEntity.d.ts.map +1 -1
  30. package/dist/features/customGridEntity.lua +66 -17
  31. package/dist/features/customStage/exports.d.ts.map +1 -1
  32. package/dist/features/customStage/exports.lua +0 -13
  33. package/dist/features/customStage/init.d.ts.map +1 -1
  34. package/dist/features/customStage/init.lua +24 -2
  35. package/dist/features/customStage/streakText.d.ts +6 -0
  36. package/dist/features/customStage/streakText.d.ts.map +1 -1
  37. package/dist/features/customStage/streakText.lua +16 -12
  38. package/dist/features/customStage/versusScreen.d.ts +6 -0
  39. package/dist/features/customStage/versusScreen.d.ts.map +1 -1
  40. package/dist/features/customStage/versusScreen.lua +10 -5
  41. package/dist/features/customTrapdoor/blackSprite.d.ts +2 -0
  42. package/dist/features/customTrapdoor/blackSprite.d.ts.map +1 -0
  43. package/dist/features/customTrapdoor/blackSprite.lua +19 -0
  44. package/dist/features/customTrapdoor/customTrapdoorConstants.d.ts +15 -0
  45. package/dist/features/customTrapdoor/customTrapdoorConstants.d.ts.map +1 -0
  46. package/dist/features/customTrapdoor/customTrapdoorConstants.lua +16 -0
  47. package/dist/features/customTrapdoor/exports.d.ts +29 -0
  48. package/dist/features/customTrapdoor/exports.d.ts.map +1 -0
  49. package/dist/features/customTrapdoor/exports.lua +93 -0
  50. package/dist/features/customTrapdoor/init.d.ts +3 -0
  51. package/dist/features/customTrapdoor/init.d.ts.map +1 -0
  52. package/dist/features/customTrapdoor/init.lua +173 -0
  53. package/dist/features/customTrapdoor/openClose.d.ts +5 -0
  54. package/dist/features/customTrapdoor/openClose.d.ts.map +1 -0
  55. package/dist/features/customTrapdoor/openClose.lua +60 -0
  56. package/dist/features/customTrapdoor/touched.d.ts +4 -0
  57. package/dist/features/customTrapdoor/touched.d.ts.map +1 -0
  58. package/dist/features/customTrapdoor/touched.lua +141 -0
  59. package/dist/features/customTrapdoor/v.d.ts +18 -0
  60. package/dist/features/customTrapdoor/v.d.ts.map +1 -0
  61. package/dist/features/customTrapdoor/v.lua +17 -0
  62. package/dist/features/deployJSONRoom.d.ts.map +1 -1
  63. package/dist/features/deployJSONRoom.lua +1 -1
  64. package/dist/features/extraConsoleCommands/init.d.ts.map +1 -1
  65. package/dist/features/extraConsoleCommands/init.lua +3 -1
  66. package/dist/features/extraConsoleCommands/listCommands.lua +2 -2
  67. package/dist/features/taintedLazarusPlayers.d.ts.map +1 -1
  68. package/dist/features/taintedLazarusPlayers.lua +13 -21
  69. package/dist/functions/{character.d.ts → characters.d.ts} +3 -1
  70. package/dist/functions/characters.d.ts.map +1 -0
  71. package/dist/functions/{character.lua → characters.lua} +12 -0
  72. package/dist/functions/deepCopyTests.lua +35 -45
  73. package/dist/functions/jsonHelpers.d.ts +6 -0
  74. package/dist/functions/jsonHelpers.d.ts.map +1 -1
  75. package/dist/functions/jsonHelpers.lua +9 -3
  76. package/dist/functions/log.lua +3 -3
  77. package/dist/functions/playerIndex.d.ts +11 -2
  78. package/dist/functions/playerIndex.d.ts.map +1 -1
  79. package/dist/functions/playerIndex.lua +20 -8
  80. package/dist/functions/players.lua +4 -4
  81. package/dist/functions/revive.lua +2 -2
  82. package/dist/functions/table.d.ts +1 -1
  83. package/dist/functions/table.d.ts.map +1 -1
  84. package/dist/index.d.ts +3 -2
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.lua +10 -2
  87. package/dist/initCustomCallbacks.d.ts.map +1 -1
  88. package/dist/initCustomCallbacks.lua +5 -2
  89. package/dist/initFeatures.d.ts +1 -2
  90. package/dist/initFeatures.d.ts.map +1 -1
  91. package/dist/initFeatures.lua +10 -2
  92. package/dist/interfaces/AddCallbackParameterCustom.d.ts +2 -2
  93. package/dist/interfaces/AddCallbackParameterCustom.d.ts.map +1 -1
  94. package/dist/interfaces/CustomGridEntityData.d.ts +6 -2
  95. package/dist/interfaces/CustomGridEntityData.d.ts.map +1 -1
  96. package/dist/interfaces/private/CustomTrapdoorDescription.d.ts +7 -0
  97. package/dist/interfaces/private/CustomTrapdoorDescription.d.ts.map +1 -0
  98. package/dist/interfaces/private/CustomTrapdoorDescription.lua +2 -0
  99. package/dist/lib/jsonLua.lua +390 -0
  100. package/dist/objects/callbackRegisterFunctions.d.ts.map +1 -1
  101. package/dist/objects/callbackRegisterFunctions.lua +3 -3
  102. package/dist/objects/characterDamageMultipliers.d.ts +6 -0
  103. package/dist/objects/characterDamageMultipliers.d.ts.map +1 -0
  104. package/dist/objects/characterDamageMultipliers.lua +49 -0
  105. package/dist/upgradeMod.d.ts.map +1 -1
  106. package/dist/upgradeMod.lua +2 -4
  107. package/package.json +2 -2
  108. package/src/callbacks/customRevive.ts +3 -3
  109. package/src/callbacks/itemPickup.ts +3 -3
  110. package/src/callbacks/postAmbush.ts +3 -3
  111. package/src/callbacks/postEsauJr.ts +3 -3
  112. package/src/callbacks/postFlip.ts +6 -5
  113. package/src/callbacks/postGridEntity.ts +5 -5
  114. package/src/callbacks/postPlayerCollectible.ts +2 -2
  115. package/src/callbacks/postPlayerFatalDamage.ts +5 -0
  116. package/src/callbacks/postPlayerInitFirst.ts +57 -0
  117. package/src/callbacks/postPlayerInitLate.ts +9 -5
  118. package/src/callbacks/{postPlayerReordered.ts → postPlayerReorderedCallbacks.ts} +9 -29
  119. package/src/callbacks/postSlotInitUpdate.ts +5 -2
  120. package/src/callbacks/postSlotRender.ts +2 -2
  121. package/src/callbacks/reorderedCallbacks.ts +1 -1
  122. package/src/callbacks/subscriptions/postFirstFlip.ts +6 -3
  123. package/src/callbacks/subscriptions/postFlip.ts +6 -3
  124. package/src/callbacks/subscriptions/{postPlayerInitReordered.ts → postPlayerInitFirst.ts} +6 -6
  125. package/src/enums/ModCallbackCustom.ts +19 -17
  126. package/src/enums/private/StageTravelState.ts +8 -0
  127. package/src/enums/private/TrapdoorAnimation.ts +5 -0
  128. package/src/features/customGridEntity.ts +93 -12
  129. package/src/features/customStage/exports.ts +3 -22
  130. package/src/features/customStage/init.ts +30 -1
  131. package/src/features/customStage/streakText.ts +13 -5
  132. package/src/features/customStage/versusScreen.ts +20 -12
  133. package/src/features/customTrapdoor/blackSprite.ts +16 -0
  134. package/src/features/customTrapdoor/customTrapdoorConstants.ts +23 -0
  135. package/src/features/customTrapdoor/exports.ts +99 -0
  136. package/src/features/customTrapdoor/init.ts +215 -0
  137. package/src/features/customTrapdoor/openClose.ts +103 -0
  138. package/src/features/customTrapdoor/touched.ts +175 -0
  139. package/src/features/customTrapdoor/v.ts +26 -0
  140. package/src/features/deployJSONRoom.ts +6 -1
  141. package/src/features/extraConsoleCommands/init.ts +5 -2
  142. package/src/features/extraConsoleCommands/listCommands.ts +1 -1
  143. package/src/features/saveDataManager/main.ts +1 -1
  144. package/src/features/taintedLazarusPlayers.ts +32 -31
  145. package/src/functions/{character.ts → characters.ts} +13 -0
  146. package/src/functions/deepCopy.ts +2 -2
  147. package/src/functions/deepCopyTests.ts +44 -48
  148. package/src/functions/entities.ts +1 -1
  149. package/src/functions/jsonHelpers.ts +9 -3
  150. package/src/functions/playerIndex.ts +18 -2
  151. package/src/functions/players.ts +1 -1
  152. package/src/functions/revive.ts +1 -1
  153. package/src/functions/rng.ts +1 -1
  154. package/src/functions/table.ts +2 -2
  155. package/src/index.ts +6 -2
  156. package/src/initCustomCallbacks.ts +3 -1
  157. package/src/initFeatures.ts +9 -2
  158. package/src/interfaces/AddCallbackParameterCustom.ts +2 -2
  159. package/src/interfaces/CustomGridEntityData.ts +7 -2
  160. package/src/interfaces/private/CustomTrapdoorDescription.ts +7 -0
  161. package/src/lib/jsonLua.d.ts +10 -0
  162. package/src/lib/jsonLua.lua +390 -0
  163. package/src/objects/callbackRegisterFunctions.ts +2 -3
  164. package/src/objects/characterDamageMultipliers.ts +49 -0
  165. package/src/upgradeMod.ts +2 -3
  166. package/dist/callbacks/postPlayerReordered.d.ts +0 -2
  167. package/dist/callbacks/postPlayerReordered.d.ts.map +0 -1
  168. package/dist/callbacks/subscriptions/postPlayerInitReordered.d.ts.map +0 -1
  169. package/dist/functions/character.d.ts.map +0 -1
@@ -3,9 +3,12 @@ local Map = ____lualib.Map
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local __TS__Iterator = ____lualib.__TS__Iterator
5
5
  local ____exports = {}
6
- local postNewRoomReordered, v
6
+ local preUseItemWeNeedToGoDeeper, postNewRoomReordered, v
7
7
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
8
+ local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
9
+ local GridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.GridCollisionClass
8
10
  local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
11
+ local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
9
12
  local ____cachedClasses = require("cachedClasses")
10
13
  local game = ____cachedClasses.game
11
14
  local ____DefaultMap = require("classes.DefaultMap")
@@ -23,8 +26,45 @@ local ____roomData = require("functions.roomData")
23
26
  local getRoomListIndex = ____roomData.getRoomListIndex
24
27
  local ____vector = require("functions.vector")
25
28
  local isVector = ____vector.isVector
29
+ local ____runInNFrames = require("features.runInNFrames")
30
+ local runNextGameFrame = ____runInNFrames.runNextGameFrame
26
31
  local ____exports = require("features.saveDataManager.exports")
27
32
  local saveDataManager = ____exports.saveDataManager
33
+ function preUseItemWeNeedToGoDeeper(self, _collectibleType, _rng, player, _useFlags, _activeSlot, _customVarData)
34
+ local room = game:GetRoom()
35
+ local roomListIndex = getRoomListIndex(nil)
36
+ local roomCustomGridEntities = v.level.customGridEntities:get(roomListIndex)
37
+ if roomCustomGridEntities == nil then
38
+ return nil
39
+ end
40
+ local gridIndex = room:GetGridIndex(player.Position)
41
+ local customGridEntity = roomCustomGridEntities:get(gridIndex)
42
+ if customGridEntity == nil then
43
+ return nil
44
+ end
45
+ if customGridEntity.gridCollisionClass ~= GridCollisionClass.NONE then
46
+ return nil
47
+ end
48
+ removeGridEntity(nil, customGridEntity.gridIndex, false)
49
+ local playerPtr = EntityPtr(player)
50
+ runNextGameFrame(
51
+ nil,
52
+ function()
53
+ local futureEntity = playerPtr.Ref
54
+ if futureEntity == nil then
55
+ return
56
+ end
57
+ local futurePlayer = futureEntity:ToPlayer()
58
+ if futurePlayer == nil then
59
+ return
60
+ end
61
+ v.room.manuallyUsingShovel = true
62
+ futurePlayer:UseActiveItem(CollectibleType.WE_NEED_TO_GO_DEEPER)
63
+ v.room.manuallyUsingShovel = false
64
+ end
65
+ )
66
+ return true
67
+ end
28
68
  function postNewRoomReordered(self)
29
69
  local roomListIndex = getRoomListIndex(nil)
30
70
  local roomCustomGridEntities = v.level.customGridEntities:get(roomListIndex)
@@ -39,27 +79,34 @@ function postNewRoomReordered(self)
39
79
  local decoration = room:GetGridEntity(gridIndex)
40
80
  if decoration == nil then
41
81
  roomCustomGridEntities:delete(gridIndex)
42
- goto __continue6
82
+ goto __continue13
43
83
  end
44
84
  local sprite = decoration:GetSprite()
45
- sprite:Load(data.anm2, true)
46
- sprite:Play(data.defaultAnimation, true)
85
+ sprite:Load(data.anm2Path, true)
86
+ local animationToPlay = data.defaultAnimation == nil and sprite:GetDefaultAnimation() or data.defaultAnimation
87
+ sprite:Play(animationToPlay, true)
47
88
  end
48
- ::__continue6::
89
+ ::__continue13::
49
90
  end
50
91
  end
51
92
  local FEATURE_NAME = "customGridEntity"
52
- v = {level = {customGridEntities = __TS__New(
53
- DefaultMap,
54
- function() return __TS__New(Map) end
55
- )}}
93
+ v = {
94
+ level = {customGridEntities = __TS__New(
95
+ DefaultMap,
96
+ function() return __TS__New(Map) end
97
+ )},
98
+ room = {manuallyUsingShovel = false}
99
+ }
56
100
  ---
57
101
  -- @internal
58
102
  function ____exports.customGridEntityInit(self, mod)
59
103
  saveDataManager(nil, FEATURE_NAME, v)
104
+ mod:AddCallback(ModCallback.PRE_USE_ITEM, preUseItemWeNeedToGoDeeper, CollectibleType.WE_NEED_TO_GO_DEEPER)
60
105
  mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
61
106
  end
62
- --- Helper function to spawn a custom grid entity.
107
+ --- Helper function to spawn a custom grid entity. Custom grid entities are persistent in that they
108
+ -- will reappear if the player leaves and re-enters the room. (It will be manually respawned in the
109
+ -- `POST_NEW_ROOM` callback.)
63
110
  --
64
111
  -- This is an IsaacScript feature because the vanilla game does not support any custom grid
65
112
  -- entities. Under the hood, IsaacScript accomplishes this by using decorations with an arbitrary
@@ -76,11 +123,12 @@ end
76
123
  -- @param gridIndexOrPosition The grid index or position in the room that you want to spawn the grid
77
124
  -- entity at. If a position is specified, the closest grid index will be
78
125
  -- used.
79
- -- @param anm2 The path to the ANM2 file to use for the sprite.
80
- -- @param defaultAnimation The name of the animation to play after the sprite is initialized and
81
- -- after the player re-enters a room with this grid entity in it.
82
126
  -- @param gridCollisionClass The collision class that you want the custom grid entity to have.
83
- function ____exports.spawnCustomGrid(self, gridEntityTypeCustom, gridIndexOrPosition, anm2, defaultAnimation, gridCollisionClass)
127
+ -- @param anm2Path The path to the ANM2 file to use for the sprite.
128
+ -- @param defaultAnimation Optional. The name of the animation to play after the sprite is
129
+ -- initialized and after the player re-enters a room with this grid entity
130
+ -- in it. If not specified, the default animation in the anm2 will be used.
131
+ function ____exports.spawnCustomGridEntity(self, gridEntityTypeCustom, gridIndexOrPosition, gridCollisionClass, anm2Path, defaultAnimation)
84
132
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
85
133
  local room = game:GetRoom()
86
134
  local roomListIndex = getRoomListIndex(nil)
@@ -92,13 +140,14 @@ function ____exports.spawnCustomGrid(self, gridEntityTypeCustom, gridIndexOrPosi
92
140
  error("Failed to spawn a decoration for a custom grid entity.")
93
141
  end
94
142
  local sprite = decoration:GetSprite()
95
- sprite:Load(anm2, true)
96
- sprite:Play(defaultAnimation, true)
143
+ sprite:Load(anm2Path, true)
144
+ local animationToPlay = defaultAnimation == nil and sprite:GetDefaultAnimation() or defaultAnimation
145
+ sprite:Play(animationToPlay, true)
97
146
  local customGridEntityData = {
98
147
  gridEntityTypeCustom = gridEntityTypeCustom,
99
148
  roomListIndex = roomListIndex,
100
149
  gridIndex = gridIndex,
101
- anm2 = anm2,
150
+ anm2Path = anm2Path,
102
151
  defaultAnimation = defaultAnimation,
103
152
  gridCollisionClass = gridCollisionClass
104
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAOX,MAAM,8BAA8B,CAAC;AAsBtC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,IAAI,CA+GlE;AAUD,wBAAgB,mBAAmB,IAAI,IAAI,CAQ1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACtB,IAAI,CAGN"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAMX,MAAM,8BAA8B,CAAC;AAoBtC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,IAAI,CAwGlE;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAQ1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACtB,IAAI,CAGN"}
@@ -1,13 +1,10 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local ____exports = {}
4
- local postRoomTransition
5
4
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
- local Direction = ____isaac_2Dtypescript_2Ddefinitions.Direction
7
5
  local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
8
6
  local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
9
7
  local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
10
- local RoomTransitionAnim = ____isaac_2Dtypescript_2Ddefinitions.RoomTransitionAnim
11
8
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
12
9
  local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
13
10
  local ____cachedClasses = require("cachedClasses")
@@ -19,8 +16,6 @@ local getEntityIDFromConstituents = ____entities.getEntityIDFromConstituents
19
16
  local ____log = require("functions.log")
20
17
  local log = ____log.log
21
18
  local logError = ____log.logError
22
- local ____playerCenter = require("functions.playerCenter")
23
- local movePlayersToCenter = ____playerCenter.movePlayersToCenter
24
19
  local ____rng = require("functions.rng")
25
20
  local newRNG = ____rng.newRNG
26
21
  local ____roomData = require("functions.roomData")
@@ -30,8 +25,6 @@ local getRooms = ____rooms.getRooms
30
25
  local ____stage = require("functions.stage")
31
26
  local getGotoCommand = ____stage.getGotoCommand
32
27
  local setStage = ____stage.setStage
33
- local ____runNextRoom = require("features.runNextRoom")
34
- local runNextRoom = ____runNextRoom.runNextRoom
35
28
  local ____customStageUtils = require("features.customStage.customStageUtils")
36
29
  local getRandomCustomStageRoom = ____customStageUtils.getRandomCustomStageRoom
37
30
  local ____streakText = require("features.customStage.streakText")
@@ -41,10 +34,6 @@ local v = ____v.default
41
34
  local customBossPNGPaths = ____v.customBossPNGPaths
42
35
  local customStageCachedRoomData = ____v.customStageCachedRoomData
43
36
  local customStagesMap = ____v.customStagesMap
44
- function postRoomTransition(self)
45
- movePlayersToCenter(nil)
46
- topStreakTextStart(nil)
47
- end
48
37
  local DEFAULT_BASE_STAGE = LevelStage.BASEMENT_2
49
38
  local DEFAULT_BASE_STAGE_TYPE = StageType.ORIGINAL
50
39
  --- Helper function to warp to a custom stage/level.
@@ -116,8 +105,6 @@ function ____exports.setCustomStage(self, name, verbose)
116
105
  local stageType = StageType.WRATH_OF_THE_LAMB
117
106
  level:SetStage(stage, stageType)
118
107
  reorderedCallbacksSetStage(nil, stage, stageType)
119
- game:StartRoomTransition(startingRoomGridIndex, Direction.NO_DIRECTION, RoomTransitionAnim.FADE)
120
- runNextRoom(nil, postRoomTransition)
121
108
  end
122
109
  function ____exports.setCustomStageDebug(self)
123
110
  local customStage = v.run.currentCustomStage
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/init.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AA8BxD,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAoBtD"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/init.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAiCxD,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CA4BtD"}
@@ -3,14 +3,18 @@ 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 initRoomTypeMaps, getRoomTypeMap, postRender, postGameStarted, getShaderParams, postGridEntityBrokenRockAlt, postGridEntityBrokenInit, postNewRoomReordered
6
+ local initRoomTypeMaps, getRoomTypeMap, postRender, postCurseEval, postGameStarted, getShaderParams, postGridEntityBrokenRockAlt, postGridEntityBrokenInit, postNewRoomReordered
7
7
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
8
8
  local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
9
+ local LevelCurse = ____isaac_2Dtypescript_2Ddefinitions.LevelCurse
9
10
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
10
11
  local ____ModCallbackCustom = require("enums.ModCallbackCustom")
11
12
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
12
13
  local ____array = require("functions.array")
13
14
  local isArray = ____array.isArray
15
+ local ____flag = require("functions.flag")
16
+ local hasFlag = ____flag.hasFlag
17
+ local removeFlag = ____flag.removeFlag
14
18
  local ____exports = require("features.saveDataManager.exports")
15
19
  local saveDataManager = ____exports.saveDataManager
16
20
  local ____backdrop = require("features.customStage.backdrop")
@@ -26,6 +30,7 @@ local ____shadows = require("features.customStage.shadows")
26
30
  local setShadows = ____shadows.setShadows
27
31
  local ____streakText = require("features.customStage.streakText")
28
32
  local streakTextGetShaderParams = ____streakText.streakTextGetShaderParams
33
+ local streakTextInit = ____streakText.streakTextInit
29
34
  local streakTextPostGameStarted = ____streakText.streakTextPostGameStarted
30
35
  local streakTextPostRender = ____streakText.streakTextPostRender
31
36
  local ____v = require("features.customStage.v")
@@ -33,6 +38,7 @@ local v = ____v.default
33
38
  local customStagesMap = ____v.customStagesMap
34
39
  local ____versusScreen = require("features.customStage.versusScreen")
35
40
  local playVersusScreenAnimation = ____versusScreen.playVersusScreenAnimation
41
+ local versusScreenInit = ____versusScreen.versusScreenInit
36
42
  local versusScreenPostRender = ____versusScreen.versusScreenPostRender
37
43
  function initRoomTypeMaps(self)
38
44
  if not isArray(nil, metadataJSON) then
@@ -78,6 +84,16 @@ function postRender(self)
78
84
  streakTextPostRender(nil)
79
85
  versusScreenPostRender(nil)
80
86
  end
87
+ function postCurseEval(self, curses)
88
+ local customStage = v.run.currentCustomStage
89
+ if customStage == nil then
90
+ return nil
91
+ end
92
+ if hasFlag(nil, curses, LevelCurse.MAZE) then
93
+ return removeFlag(nil, curses, LevelCurse.MAZE)
94
+ end
95
+ return nil
96
+ end
81
97
  function postGameStarted(self)
82
98
  streakTextPostGameStarted(nil)
83
99
  end
@@ -116,9 +132,15 @@ function postNewRoomReordered(self)
116
132
  playVersusScreenAnimation(nil, customStage)
117
133
  end
118
134
  function ____exports.customStageInit(self, mod)
119
- saveDataManager(nil, "customStage", v)
120
135
  initRoomTypeMaps(nil)
136
+ if customStagesMap.size == 0 then
137
+ return
138
+ end
139
+ saveDataManager(nil, "customStage", v)
140
+ streakTextInit(nil)
141
+ versusScreenInit(nil)
121
142
  mod:AddCallback(ModCallback.POST_RENDER, postRender)
143
+ mod:AddCallback(ModCallback.POST_CURSE_EVAL, postCurseEval)
122
144
  mod:AddCallback(ModCallback.POST_GAME_STARTED, postGameStarted)
123
145
  mod:AddCallback(ModCallback.GET_SHADER_PARAMS, getShaderParams)
124
146
  mod:AddCallbackCustom(ModCallbackCustom.POST_GRID_ENTITY_BROKEN, postGridEntityBrokenRockAlt, GridEntityType.ROCK_ALT)
@@ -1,4 +1,10 @@
1
1
  import { CustomStage } from "../../interfaces/CustomStage";
2
+ /**
3
+ * We must load the sprites in an init function to prevent issues with mods that replace the vanilla
4
+ * files. (For some reason, loading the sprites will cause the overwrite to no longer apply on the
5
+ * second and subsequent runs.)
6
+ */
7
+ export declare function streakTextInit(): void;
2
8
  export declare function streakTextPostRender(): void;
3
9
  export declare function streakTextPostGameStarted(): void;
4
10
  export declare function streakTextGetShaderParams(customStage: CustomStage, shaderName: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"streakText.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/streakText.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA+F3D,wBAAgB,oBAAoB,IAAI,IAAI,CAS3C;AAmFD,wBAAgB,yBAAyB,IAAI,IAAI,CAGhD;AAGD,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,GACjB,IAAI,CAYN;AAiFD,wBAAgB,kBAAkB,IAAI,IAAI,CAUzC"}
1
+ {"version":3,"file":"streakText.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/streakText.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA0F3D;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAMrC;AAGD,wBAAgB,oBAAoB,IAAI,IAAI,CAS3C;AAmFD,wBAAgB,yBAAyB,IAAI,IAAI,CAGhD;AAGD,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,GACjB,IAAI,CAYN;AAgFD,wBAAgB,kBAAkB,IAAI,IAAI,CAUzC"}
@@ -88,9 +88,9 @@ function renderSprite(self, customStage, sprite, position)
88
88
  local adjustment = 0
89
89
  local scale = VectorOne
90
90
  repeat
91
- local ____switch26 = animation
92
- local ____cond26 = ____switch26 == UIStreakAnimation.TEXT
93
- if ____cond26 then
91
+ local ____switch27 = animation
92
+ local ____cond27 = ____switch27 == UIStreakAnimation.TEXT
93
+ if ____cond27 then
94
94
  do
95
95
  if frame < TEXT_STAY_FRAME then
96
96
  adjustment = TEXT_IN_ADJUSTMENTS[frame + 1] or 0
@@ -103,16 +103,16 @@ function renderSprite(self, customStage, sprite, position)
103
103
  break
104
104
  end
105
105
  end
106
- ____cond26 = ____cond26 or ____switch26 == UIStreakAnimation.TEXT_IN
107
- if ____cond26 then
106
+ ____cond27 = ____cond27 or ____switch27 == UIStreakAnimation.TEXT_IN
107
+ if ____cond27 then
108
108
  do
109
109
  adjustment = TEXT_IN_ADJUSTMENTS[frame + 1] or 0
110
110
  scale = TEXT_IN_SCALES[frame + 1] or VectorOne
111
111
  break
112
112
  end
113
113
  end
114
- ____cond26 = ____cond26 or ____switch26 == UIStreakAnimation.TEXT_OUT
115
- if ____cond26 then
114
+ ____cond27 = ____cond27 or ____switch27 == UIStreakAnimation.TEXT_OUT
115
+ if ____cond27 then
116
116
  do
117
117
  adjustment = TEXT_OUT_ADJUSTMENTS[frame + 1] or 0
118
118
  scale = TEXT_OUT_SCALES[frame + 1] or VectorOne
@@ -127,7 +127,6 @@ function renderSprite(self, customStage, sprite, position)
127
127
  until true
128
128
  local adjustedX = centeredX + adjustment
129
129
  local adjustedY = position.Y + STREAK_TEXT_BOTTOM_Y_OFFSET
130
- sprite:RenderLayer(0, position)
131
130
  font:DrawStringScaled(
132
131
  name,
133
132
  adjustedX,
@@ -203,11 +202,16 @@ TEXT_OUT_SCALES = {
203
202
  Vector(3, 0.2)
204
203
  }
205
204
  topStreakSprite = Sprite()
206
- topStreakSprite:Load("resources/gfx/ui/ui_streak.anm2", false)
207
- topStreakSprite.PlaybackSpeed = TEXT_PLAYBACK_SPEED
208
205
  bottomStreakSprite = Sprite()
209
- bottomStreakSprite:Load("resources/gfx/ui/ui_streak.anm2", false)
210
- bottomStreakSprite.PlaybackSpeed = TEXT_PLAYBACK_SPEED
206
+ --- We must load the sprites in an init function to prevent issues with mods that replace the vanilla
207
+ -- files. (For some reason, loading the sprites will cause the overwrite to no longer apply on the
208
+ -- second and subsequent runs.)
209
+ function ____exports.streakTextInit(self)
210
+ topStreakSprite:Load("resources/gfx/ui/ui_streak.anm2", false)
211
+ topStreakSprite.PlaybackSpeed = TEXT_PLAYBACK_SPEED
212
+ bottomStreakSprite:Load("resources/gfx/ui/ui_streak.anm2", false)
213
+ bottomStreakSprite.PlaybackSpeed = TEXT_PLAYBACK_SPEED
214
+ end
211
215
  function ____exports.streakTextPostRender(self)
212
216
  checkEndTopStreakText(nil)
213
217
  trackMapInputPressed(nil)
@@ -1,4 +1,10 @@
1
1
  import { CustomStage } from "../../interfaces/CustomStage";
2
+ /**
3
+ * We must load the sprites in an init function to prevent issues with mods that replace the vanilla
4
+ * files. (For some reason, loading the sprites will cause the overwrite to no longer apply on the
5
+ * second and subsequent runs.)
6
+ */
7
+ export declare function versusScreenInit(): void;
2
8
  export declare function playVersusScreenAnimation(customStage: CustomStage): void;
3
9
  export declare function versusScreenPostRender(): void;
4
10
  //# sourceMappingURL=versusScreen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"versusScreen.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/versusScreen.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAiF3D,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAuDxE;AA+ED,wBAAgB,sBAAsB,IAAI,IAAI,CAoC7C"}
1
+ {"version":3,"file":"versusScreen.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/versusScreen.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAqE3D;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAavC;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAuDxE;AA+ED,wBAAgB,sBAAsB,IAAI,IAAI,CAoC7C"}
@@ -107,17 +107,22 @@ PNG_PATH_PREFIX = "gfx/ui/boss"
107
107
  PLAYER_PORTRAIT_PNG_PATH_PREFIX = "gfx/ui/stage"
108
108
  local VANILLA_VERSUS_PLAYBACK_SPEED = 0.5
109
109
  local versusScreenSprite = Sprite()
110
- versusScreenSprite:Load("gfx/ui/boss/versusscreen.anm2", false)
111
- versusScreenSprite:ReplaceSpritesheet(OVERLAY_ANM2_LAYER, ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH .. "/overlay.png")
112
- versusScreenSprite:LoadGraphics()
113
110
  --- Unfortunately, we must split the background layer into an entirely different sprite so that we
114
111
  -- can color it with the `Color` property.
115
112
  local versusScreenBackgroundSprite = Sprite()
116
- versusScreenBackgroundSprite:Load("gfx/ui/boss/versusscreen.anm2", true)
117
113
  --- Unfortunately, we must split the dirt layer into an entirely different sprite so that we can
118
114
  -- color it with the `Color` property.
119
115
  local versusScreenDirtSpotSprite = Sprite()
120
- versusScreenDirtSpotSprite:Load("gfx/ui/boss/versusscreen.anm2", true)
116
+ --- We must load the sprites in an init function to prevent issues with mods that replace the vanilla
117
+ -- files. (For some reason, loading the sprites will cause the overwrite to no longer apply on the
118
+ -- second and subsequent runs.)
119
+ function ____exports.versusScreenInit(self)
120
+ versusScreenSprite:Load("gfx/ui/boss/versusscreen.anm2", false)
121
+ versusScreenSprite:ReplaceSpritesheet(OVERLAY_ANM2_LAYER, ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH .. "/overlay.png")
122
+ versusScreenSprite:LoadGraphics()
123
+ versusScreenBackgroundSprite:Load("gfx/ui/boss/versusscreen.anm2", true)
124
+ versusScreenDirtSpotSprite:Load("gfx/ui/boss/versusscreen.anm2", true)
125
+ end
121
126
  function ____exports.playVersusScreenAnimation(self, customStage)
122
127
  local room = game:GetRoom()
123
128
  local roomType = room:GetType()
@@ -0,0 +1,2 @@
1
+ export declare function drawBlackSprite(): void;
2
+ //# sourceMappingURL=blackSprite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blackSprite.d.ts","sourceRoot":"","sources":["../../../src/features/customTrapdoor/blackSprite.ts"],"names":[],"mappings":"AASA,wBAAgB,eAAe,IAAI,IAAI,CAMtC"}
@@ -0,0 +1,19 @@
1
+ local ____exports = {}
2
+ local ____constants = require("constants")
3
+ local VectorZero = ____constants.VectorZero
4
+ local ____StageTravelState = require("enums.private.StageTravelState")
5
+ local StageTravelState = ____StageTravelState.StageTravelState
6
+ local ____customStageConstants = require("features.customStage.customStageConstants")
7
+ local ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH = ____customStageConstants.ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH
8
+ local ____v = require("features.customTrapdoor.v")
9
+ local v = ____v.default
10
+ local sprite = Sprite()
11
+ sprite:Load(ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH .. "/black.anm2", true)
12
+ sprite:SetFrame("Default", 0)
13
+ function ____exports.drawBlackSprite(self)
14
+ if v.run.state ~= StageTravelState.PAUSING_ON_BLACK then
15
+ return
16
+ end
17
+ sprite:RenderLayer(0, VectorZero)
18
+ end
19
+ return ____exports
@@ -0,0 +1,15 @@
1
+ import { GridEntityType } from "isaac-typescript-definitions";
2
+ export declare const CUSTOM_TRAPDOOR_FEATURE_NAME = "customTrapdoor";
3
+ export declare const GridEntityTypeCustom: {
4
+ readonly TRAPDOOR_CUSTOM: GridEntityType;
5
+ };
6
+ /** This also applies to crawl spaces. The value was determined through trial and error. */
7
+ export declare const TRAPDOOR_OPEN_DISTANCE = 60;
8
+ export declare const TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS: number;
9
+ export declare const TRAPDOOR_BOSS_REACTION_FRAMES = 30;
10
+ export declare const TRAPDOOR_TOUCH_DISTANCE = 16.5;
11
+ export declare const ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL: ReadonlySet<string>;
12
+ export declare const PIXELATION_TO_BLACK_FRAMES = 52;
13
+ export declare const OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES = 10;
14
+ export declare const OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES = 8;
15
+ //# sourceMappingURL=customTrapdoorConstants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customTrapdoorConstants.d.ts","sourceRoot":"","sources":["../../../src/features/customTrapdoor/customTrapdoorConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,eAAO,MAAM,4BAA4B,mBAAmB,CAAC;AAE7D,eAAO,MAAM,oBAAoB;;CAEvB,CAAC;AAEX,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,eAAO,MAAM,iCAAiC,QAA+B,CAAC;AAC9E,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,eAAO,MAAM,oCAAoC,EAAE,WAAW,CAAC,MAAM,CAClC,CAAC;AAEpC,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,eAAO,MAAM,4CAA4C,KAAK,CAAC;AAC/D,eAAO,MAAM,+CAA+C,IAAI,CAAC"}
@@ -0,0 +1,16 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ ____exports.CUSTOM_TRAPDOOR_FEATURE_NAME = "customTrapdoor"
6
+ ____exports.GridEntityTypeCustom = {TRAPDOOR_CUSTOM = 1000}
7
+ --- This also applies to crawl spaces. The value was determined through trial and error.
8
+ ____exports.TRAPDOOR_OPEN_DISTANCE = 60
9
+ ____exports.TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = ____exports.TRAPDOOR_OPEN_DISTANCE * 2.5
10
+ ____exports.TRAPDOOR_BOSS_REACTION_FRAMES = 30
11
+ ____exports.TRAPDOOR_TOUCH_DISTANCE = 16.5
12
+ ____exports.ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL = __TS__New(Set, {"Happy", "Sad", "Jump"})
13
+ ____exports.PIXELATION_TO_BLACK_FRAMES = 52
14
+ ____exports.OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES = 10
15
+ ____exports.OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES = 8
16
+ return ____exports
@@ -0,0 +1,29 @@
1
+ import { LevelStage, StageType } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to spawn a trapdoor grid entity that will have one or more of the following
4
+ * attributes:
5
+ *
6
+ * - custom destination (or custom logic for after the player enters)
7
+ * - custom graphics
8
+ * - custom logic for opening/closing
9
+ * - TODO: player jumping animation?
10
+ *
11
+ * You can use this function to take the player to your custom stage.
12
+ *
13
+ * Under the hood, the custom trapdoor is represented by a decoration grid entity and is manually
14
+ * respawned every time the player re-enters the room.
15
+ *
16
+ * @param gridIndexOrPosition The location in the room to spawn the trapdoor.
17
+ * @param destination Optional. Used to specify where the player will go after jumping into the
18
+ * trapdoor. Can either be a tuple containing the stage and stage type, or a
19
+ * string containing the name of a custom stage. If not specified at all, then
20
+ * the "normal" destination corresponding to the current stage and room will be
21
+ * used (e.g. the next floor).
22
+ * @param anm2Path Optional. The path to the anm2 file to use. By default, the vanilla trapdoor anm2
23
+ * of "gfx/grid/door_11_trapdoor.anm2" will be used. The specified anm2 file must
24
+ * have animations called "Opened", "Closed", and "Open Animation".
25
+ * @param spawnOpen Optional. Whether or not to spawn the trapdoor in an open state. By default,
26
+ * behavior will be used that emulates a vanilla trapdoor.
27
+ */
28
+ export declare function spawnCustomTrapdoor(gridIndexOrPosition: int | Vector, destination?: [stage: LevelStage, stageType: StageType] | string, anm2Path?: string, spawnOpen?: boolean): GridEntity;
29
+ //# sourceMappingURL=exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/customTrapdoor/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,SAAS,EACV,MAAM,8BAA8B,CAAC;AAgBtC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CACjC,mBAAmB,EAAE,GAAG,GAAG,MAAM,EACjC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,MAAM,EAChE,QAAQ,SAAmC,EAC3C,SAAS,CAAC,EAAE,OAAO,GAClB,UAAU,CAwCZ"}
@@ -0,0 +1,93 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local ____exports = {}
4
+ local getDefaultDestination
5
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
+ local GridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.GridCollisionClass
7
+ local ____cachedClasses = require("cachedClasses")
8
+ local game = ____cachedClasses.game
9
+ local ____TrapdoorAnimation = require("enums.private.TrapdoorAnimation")
10
+ local TrapdoorAnimation = ____TrapdoorAnimation.TrapdoorAnimation
11
+ local ____featuresInitialized = require("featuresInitialized")
12
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
13
+ local ____nextStage = require("functions.nextStage")
14
+ local getNextStage = ____nextStage.getNextStage
15
+ local getNextStageType = ____nextStage.getNextStageType
16
+ local ____roomData = require("functions.roomData")
17
+ local getRoomListIndex = ____roomData.getRoomListIndex
18
+ local ____vector = require("functions.vector")
19
+ local isVector = ____vector.isVector
20
+ local ____customGridEntity = require("features.customGridEntity")
21
+ local spawnCustomGridEntity = ____customGridEntity.spawnCustomGridEntity
22
+ local ____customTrapdoorConstants = require("features.customTrapdoor.customTrapdoorConstants")
23
+ local CUSTOM_TRAPDOOR_FEATURE_NAME = ____customTrapdoorConstants.CUSTOM_TRAPDOOR_FEATURE_NAME
24
+ local GridEntityTypeCustom = ____customTrapdoorConstants.GridEntityTypeCustom
25
+ local ____openClose = require("features.customTrapdoor.openClose")
26
+ local shouldTrapdoorSpawnOpen = ____openClose.shouldTrapdoorSpawnOpen
27
+ local ____v = require("features.customTrapdoor.v")
28
+ local v = ____v.default
29
+ function getDefaultDestination(self)
30
+ local nextStage = getNextStage(nil)
31
+ local nextStageType = getNextStageType(nil)
32
+ return {nextStage, nextStageType}
33
+ end
34
+ --- Helper function to spawn a trapdoor grid entity that will have one or more of the following
35
+ -- attributes:
36
+ --
37
+ -- - custom destination (or custom logic for after the player enters)
38
+ -- - custom graphics
39
+ -- - custom logic for opening/closing
40
+ -- - TODO: player jumping animation?
41
+ --
42
+ -- You can use this function to take the player to your custom stage.
43
+ --
44
+ -- Under the hood, the custom trapdoor is represented by a decoration grid entity and is manually
45
+ -- respawned every time the player re-enters the room.
46
+ --
47
+ -- @param gridIndexOrPosition The location in the room to spawn the trapdoor.
48
+ -- @param destination Optional. Used to specify where the player will go after jumping into the
49
+ -- trapdoor. Can either be a tuple containing the stage and stage type, or a
50
+ -- string containing the name of a custom stage. If not specified at all, then
51
+ -- the "normal" destination corresponding to the current stage and room will be
52
+ -- used (e.g. the next floor).
53
+ -- @param anm2Path Optional. The path to the anm2 file to use. By default, the vanilla trapdoor anm2
54
+ -- of "gfx/grid/door_11_trapdoor.anm2" will be used. The specified anm2 file must
55
+ -- have animations called "Opened", "Closed", and "Open Animation".
56
+ -- @param spawnOpen Optional. Whether or not to spawn the trapdoor in an open state. By default,
57
+ -- behavior will be used that emulates a vanilla trapdoor.
58
+ function ____exports.spawnCustomTrapdoor(self, gridIndexOrPosition, destination, anm2Path, spawnOpen)
59
+ if anm2Path == nil then
60
+ anm2Path = "gfx/grid/door_11_trapdoor.anm2"
61
+ end
62
+ errorIfFeaturesNotInitialized(nil, CUSTOM_TRAPDOOR_FEATURE_NAME)
63
+ local room = game:GetRoom()
64
+ local roomFrameCount = room:GetFrameCount()
65
+ local roomListIndex = getRoomListIndex(nil)
66
+ local gridIndex = isVector(nil, gridIndexOrPosition) and room:GetGridIndex(gridIndexOrPosition) or gridIndexOrPosition
67
+ local gridEntity = spawnCustomGridEntity(
68
+ nil,
69
+ GridEntityTypeCustom.TRAPDOOR_CUSTOM,
70
+ gridIndexOrPosition,
71
+ GridCollisionClass.NONE,
72
+ anm2Path,
73
+ TrapdoorAnimation.OPENED
74
+ )
75
+ local firstSpawn = roomFrameCount ~= 0
76
+ local ____temp_0
77
+ if spawnOpen == nil then
78
+ ____temp_0 = shouldTrapdoorSpawnOpen(nil, gridEntity, firstSpawn)
79
+ else
80
+ ____temp_0 = spawnOpen
81
+ end
82
+ local open = ____temp_0
83
+ local destinationToUse = destination == nil and getDefaultDestination(nil) or destination
84
+ local roomTrapdoorMap = v.level.trapdoors:getAndSetDefault(roomListIndex)
85
+ local customTrapdoorDescription = {open = open, destination = destinationToUse, firstSpawn = firstSpawn}
86
+ roomTrapdoorMap:set(gridIndex, customTrapdoorDescription)
87
+ if not open then
88
+ local sprite = gridEntity:GetSprite()
89
+ sprite:Play(TrapdoorAnimation.CLOSED, true)
90
+ end
91
+ return gridEntity
92
+ end
93
+ return ____exports
@@ -0,0 +1,3 @@
1
+ import { ModUpgraded } from "../../classes/ModUpgraded";
2
+ export declare function customTrapdoorInit(mod: ModUpgraded): void;
3
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/features/customTrapdoor/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAuBxD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CASzD"}