isaacscript-common 20.11.3 → 20.11.5
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.
- package/dist/index.d.ts +2 -1
- package/dist/isaacscript-common.lua +34 -14
- package/dist/src/classes/features/other/CustomStages.d.ts.map +1 -1
- package/dist/src/classes/features/other/CustomStages.lua +13 -10
- package/dist/src/classes/features/other/CustomTrapdoors.d.ts +2 -1
- package/dist/src/classes/features/other/CustomTrapdoors.d.ts.map +1 -1
- package/dist/src/classes/features/other/CustomTrapdoors.lua +20 -3
- package/package.json +1 -1
- package/src/classes/features/other/CustomStages.ts +8 -1
- package/src/classes/features/other/CustomTrapdoors.ts +33 -3
package/dist/index.d.ts
CHANGED
|
@@ -2494,6 +2494,7 @@ declare class CustomTrapdoors extends Feature {
|
|
|
2494
2494
|
private postPEffectUpdateReordered;
|
|
2495
2495
|
private checkJumpComplete;
|
|
2496
2496
|
private shouldTrapdoorSpawnOpen;
|
|
2497
|
+
private logStateChanged;
|
|
2497
2498
|
/**
|
|
2498
2499
|
* Helper function to specify where your custom trapdoor should take the player. Call this once at
|
|
2499
2500
|
* the beginning of your mod for each kind of custom trapdoor that you want to have. The provided
|
|
@@ -2513,7 +2514,7 @@ declare class CustomTrapdoors extends Feature {
|
|
|
2513
2514
|
* Inside this function, use the `setStage` or `setCustomStage` helper
|
|
2514
2515
|
* functions, or do something completely custom.
|
|
2515
2516
|
*/
|
|
2516
|
-
registerCustomTrapdoorDestination(destinationName: string, destinationFunc: (destinationStage: LevelStage, destinationStageType: StageType) => void): void;
|
|
2517
|
+
registerCustomTrapdoorDestination(destinationName: string, destinationFunc: (destinationName: string | undefined, destinationStage: LevelStage, destinationStageType: StageType) => void): void;
|
|
2517
2518
|
/**
|
|
2518
2519
|
* Helper function to spawn a trapdoor grid entity that will take a player to a vanilla stage or
|
|
2519
2520
|
* custom location.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 20.11.
|
|
3
|
+
isaacscript-common 20.11.5
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -39206,6 +39206,8 @@ local ____TrapdoorAnimation = require("src.enums.private.TrapdoorAnimation")
|
|
|
39206
39206
|
local TrapdoorAnimation = ____TrapdoorAnimation.TrapdoorAnimation
|
|
39207
39207
|
local ____easing = require("src.functions.easing")
|
|
39208
39208
|
local easeOutSine = ____easing.easeOutSine
|
|
39209
|
+
local ____log = require("src.functions.log")
|
|
39210
|
+
local log = ____log.log
|
|
39209
39211
|
local ____playerCenter = require("src.functions.playerCenter")
|
|
39210
39212
|
local movePlayersToCenter = ____playerCenter.movePlayersToCenter
|
|
39211
39213
|
local ____playerIndex = require("src.functions.playerIndex")
|
|
@@ -39269,15 +39271,16 @@ function dropTaintedForgotten(self, player)
|
|
|
39269
39271
|
end
|
|
39270
39272
|
end
|
|
39271
39273
|
end
|
|
39272
|
-
function goToVanillaStage(self, destinationStage, destinationStageType)
|
|
39274
|
+
function goToVanillaStage(self, _destinationName, destinationStage, destinationStageType)
|
|
39273
39275
|
setStage(nil, destinationStage, destinationStageType)
|
|
39274
39276
|
end
|
|
39277
|
+
local DEBUG = false
|
|
39275
39278
|
local TRAPDOOR_OPEN_DISTANCE = 60
|
|
39276
39279
|
local TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = TRAPDOOR_OPEN_DISTANCE * 2.5
|
|
39277
39280
|
local TRAPDOOR_BOSS_REACTION_FRAMES = 30
|
|
39278
39281
|
local TRAPDOOR_TOUCH_DISTANCE = 16.5
|
|
39279
39282
|
ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL = __TS__New(Set, {"Death", "Happy", "Sad", "Jump"})
|
|
39280
|
-
local PIXELATION_TO_BLACK_FRAMES =
|
|
39283
|
+
local PIXELATION_TO_BLACK_FRAMES = 60
|
|
39281
39284
|
local OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES = 6
|
|
39282
39285
|
local OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES = 5
|
|
39283
39286
|
____exports.CustomTrapdoors = __TS__Class()
|
|
@@ -39346,6 +39349,7 @@ function CustomTrapdoors.prototype.checkAllPlayersJumpComplete(self)
|
|
|
39346
39349
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
39347
39350
|
self.v.run.state = StageTravelState.PIXELATION_TO_BLACK
|
|
39348
39351
|
self.v.run.stateRenderFrame = renderFrameCount
|
|
39352
|
+
self:logStateChanged()
|
|
39349
39353
|
teleport(nil, roomGridIndex, Direction.NO_DIRECTION, RoomTransitionAnim.PIXELATION)
|
|
39350
39354
|
end
|
|
39351
39355
|
function CustomTrapdoors.prototype.checkPixelationToBlackComplete(self)
|
|
@@ -39359,6 +39363,7 @@ function CustomTrapdoors.prototype.checkPixelationToBlackComplete(self)
|
|
|
39359
39363
|
return
|
|
39360
39364
|
end
|
|
39361
39365
|
self.v.run.state = StageTravelState.WAITING_FOR_FIRST_PIXELATION_TO_END
|
|
39366
|
+
self:logStateChanged()
|
|
39362
39367
|
hud:SetVisible(false)
|
|
39363
39368
|
self.runInNFrames:runNextGameFrame(function()
|
|
39364
39369
|
local level = game:GetLevel()
|
|
@@ -39381,7 +39386,7 @@ function CustomTrapdoors.prototype.goToCustomTrapdoorDestination(self)
|
|
|
39381
39386
|
}
|
|
39382
39387
|
end
|
|
39383
39388
|
local destinationFunc = self:getDestinationFunc(self.v.run.customTrapdoorActivated)
|
|
39384
|
-
destinationFunc(nil, self.v.run.customTrapdoorActivated.destinationStage, self.v.run.customTrapdoorActivated.destinationStageType)
|
|
39389
|
+
destinationFunc(nil, self.v.run.customTrapdoorActivated.destinationName, self.v.run.customTrapdoorActivated.destinationStage, self.v.run.customTrapdoorActivated.destinationStageType)
|
|
39385
39390
|
end
|
|
39386
39391
|
function CustomTrapdoors.prototype.getDestinationFunc(self, customTrapdoorDescription)
|
|
39387
39392
|
if customTrapdoorDescription.destinationName == nil then
|
|
@@ -39404,9 +39409,11 @@ function CustomTrapdoors.prototype.checkSecondPixelationHalfWay(self)
|
|
|
39404
39409
|
return
|
|
39405
39410
|
end
|
|
39406
39411
|
self.v.run.state = StageTravelState.PIXELATION_TO_ROOM
|
|
39412
|
+
self:logStateChanged()
|
|
39407
39413
|
hud:SetVisible(true)
|
|
39408
39414
|
self.runNextRoom:runNextRoom(function()
|
|
39409
39415
|
self.v.run.state = StageTravelState.PLAYERS_LAYING_DOWN
|
|
39416
|
+
self:logStateChanged()
|
|
39410
39417
|
movePlayersToCenter(nil)
|
|
39411
39418
|
for ____, player in ipairs(getAllPlayers(nil)) do
|
|
39412
39419
|
player:AnimateAppear()
|
|
@@ -39423,6 +39430,7 @@ function CustomTrapdoors.prototype.checkAllPlayersLayingDownComplete(self)
|
|
|
39423
39430
|
return
|
|
39424
39431
|
end
|
|
39425
39432
|
self.v.run.state = StageTravelState.NONE
|
|
39433
|
+
self:logStateChanged()
|
|
39426
39434
|
local tstlClassName = getTSTLClassName(nil, self)
|
|
39427
39435
|
if tstlClassName == nil then
|
|
39428
39436
|
error("Failed to find get the class name for the custom trapdoor feature.")
|
|
@@ -39488,6 +39496,7 @@ end
|
|
|
39488
39496
|
function CustomTrapdoors.prototype.playerTouchedCustomTrapdoor(self, gridEntity, trapdoorDescription, player)
|
|
39489
39497
|
self.v.run.state = StageTravelState.PLAYERS_JUMPING_DOWN
|
|
39490
39498
|
self.v.run.customTrapdoorActivated = trapdoorDescription
|
|
39499
|
+
self:logStateChanged()
|
|
39491
39500
|
local tstlClassName = getTSTLClassName(nil, self)
|
|
39492
39501
|
if tstlClassName == nil then
|
|
39493
39502
|
error("Failed to find get the class name for the custom trapdoor feature.")
|
|
@@ -39580,6 +39589,14 @@ function CustomTrapdoors.prototype.shouldTrapdoorSpawnOpen(self, gridEntity, fir
|
|
|
39580
39589
|
end
|
|
39581
39590
|
return self:shouldTrapdoorOpen(gridEntity, firstSpawn)
|
|
39582
39591
|
end
|
|
39592
|
+
function CustomTrapdoors.prototype.logStateChanged(self)
|
|
39593
|
+
if DEBUG then
|
|
39594
|
+
log(
|
|
39595
|
+
nil,
|
|
39596
|
+
((("Custom trapdoors state changed: " .. StageTravelState[self.v.run.state]) .. " (") .. tostring(self.v.run.state)) .. ")"
|
|
39597
|
+
)
|
|
39598
|
+
end
|
|
39599
|
+
end
|
|
39583
39600
|
function CustomTrapdoors.prototype.registerCustomTrapdoorDestination(self, destinationName, destinationFunc)
|
|
39584
39601
|
if self.destinationFuncMap:has(destinationName) then
|
|
39585
39602
|
error(("Failed to register a custom trapdoor type of " .. destinationName) .. " since this custom trapdoor type has already been registered.")
|
|
@@ -42263,9 +42280,12 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
42263
42280
|
}}
|
|
42264
42281
|
self.customStagesMap = __TS__New(Map)
|
|
42265
42282
|
self.customStageCachedRoomData = __TS__New(Map)
|
|
42266
|
-
self.goToCustomStage = function(____, destinationStage, _destinationStageType)
|
|
42283
|
+
self.goToCustomStage = function(____, destinationName, destinationStage, _destinationStageType)
|
|
42284
|
+
if destinationName == nil then
|
|
42285
|
+
error("Failed to go to a custom stage since the custom trapdoors feature did not pass a destination name to the logic function.")
|
|
42286
|
+
end
|
|
42267
42287
|
local firstFloor = destinationStage == LevelStage.BASEMENT_1
|
|
42268
|
-
self:setCustomStage(
|
|
42288
|
+
self:setCustomStage(destinationName, firstFloor)
|
|
42269
42289
|
end
|
|
42270
42290
|
self.postRender = function()
|
|
42271
42291
|
local customStage = self.v.run.currentCustomStage
|
|
@@ -42381,10 +42401,10 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
42381
42401
|
for ____, room in ipairs(getRoomsInsideGrid(nil)) do
|
|
42382
42402
|
do
|
|
42383
42403
|
if room.SafeGridIndex == startingRoomGridIndex then
|
|
42384
|
-
goto
|
|
42404
|
+
goto __continue27
|
|
42385
42405
|
end
|
|
42386
42406
|
if room.Data == nil then
|
|
42387
|
-
goto
|
|
42407
|
+
goto __continue27
|
|
42388
42408
|
end
|
|
42389
42409
|
local roomType = room.Data.Type
|
|
42390
42410
|
local roomShapeMap = customStage.roomTypeMap:get(roomType)
|
|
@@ -42395,7 +42415,7 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
42395
42415
|
(((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") for custom stage: ") .. customStage.name
|
|
42396
42416
|
)
|
|
42397
42417
|
end
|
|
42398
|
-
goto
|
|
42418
|
+
goto __continue27
|
|
42399
42419
|
end
|
|
42400
42420
|
local roomShape = room.Data.Shape
|
|
42401
42421
|
local roomDoorSlotFlagMap = roomShapeMap:get(roomShape)
|
|
@@ -42404,7 +42424,7 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
42404
42424
|
nil,
|
|
42405
42425
|
(((((((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. RoomShape[roomShape]) .. " (") .. tostring(roomShape)) .. ") for custom stage: ") .. customStage.name
|
|
42406
42426
|
)
|
|
42407
|
-
goto
|
|
42427
|
+
goto __continue27
|
|
42408
42428
|
end
|
|
42409
42429
|
local doorSlotFlags = room.Data.Doors
|
|
42410
42430
|
local roomsMetadata = roomDoorSlotFlagMap:get(doorSlotFlags)
|
|
@@ -42417,13 +42437,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
42417
42437
|
nil,
|
|
42418
42438
|
(((((((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. RoomShape[roomShape]) .. " (") .. tostring(roomShape)) .. ") + all doors enabled for custom stage: ") .. customStage.name
|
|
42419
42439
|
)
|
|
42420
|
-
goto
|
|
42440
|
+
goto __continue27
|
|
42421
42441
|
end
|
|
42422
42442
|
end
|
|
42423
42443
|
local randomRoom
|
|
42424
42444
|
if roomType == RoomType.BOSS then
|
|
42425
42445
|
if customStage.bossPool == nil then
|
|
42426
|
-
goto
|
|
42446
|
+
goto __continue27
|
|
42427
42447
|
end
|
|
42428
42448
|
randomRoom = getRandomBossRoomFromPool(
|
|
42429
42449
|
nil,
|
|
@@ -42443,13 +42463,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
42443
42463
|
nil,
|
|
42444
42464
|
(("Failed to get the room data for room variant " .. tostring(randomRoom.variant)) .. " for custom stage: ") .. customStage.name
|
|
42445
42465
|
)
|
|
42446
|
-
goto
|
|
42466
|
+
goto __continue27
|
|
42447
42467
|
end
|
|
42448
42468
|
self.customStageCachedRoomData:set(randomRoom.variant, newRoomData)
|
|
42449
42469
|
end
|
|
42450
42470
|
room.Data = newRoomData
|
|
42451
42471
|
end
|
|
42452
|
-
::
|
|
42472
|
+
::__continue27::
|
|
42453
42473
|
end
|
|
42454
42474
|
end
|
|
42455
42475
|
function CustomStages.prototype.setCustomStage(self, name, firstFloor, streakText, verbose)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomStages.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomStages.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAoChD,qBAAa,YAAa,SAAQ,OAAO;IA8BvC,oCAAoC;IACpC,OAAO,CAAC,eAAe,CAAkC;IAEzD,+BAA+B;IAC/B,OAAO,CAAC,yBAAyB,CAAwC;IAEzE,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,sBAAsB,CAAyB;IACvD,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAAe;IAqDnC,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,6BAA6B;IAOrC,OAAO,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"CustomStages.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomStages.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAoChD,qBAAa,YAAa,SAAQ,OAAO;IA8BvC,oCAAoC;IACpC,OAAO,CAAC,eAAe,CAAkC;IAEzD,+BAA+B;IAC/B,OAAO,CAAC,yBAAyB,CAAwC;IAEzE,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,sBAAsB,CAAyB;IACvD,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAAe;IAqDnC,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,6BAA6B;IAOrC,OAAO,CAAC,eAAe,CAarB;IAGF,OAAO,CAAC,UAAU,CAQhB;IAGF,OAAO,CAAC,aAAa,CAcnB;IAGF,OAAO,CAAC,eAAe,CAUrB;IAIF,OAAO,CAAC,2BAA2B,CAejC;IAGF,OAAO,CAAC,kBAAkB,CAqBxB;IAGF,OAAO,CAAC,oBAAoB,CAe1B;IAEF,gDAAgD;IAChD,OAAO,CAAC,iBAAiB;IA+FzB;;;;;;;;;;;;;;;;OAgBG;IAEI,cAAc,CACnB,IAAI,EAAE,MAAM,EACZ,UAAU,UAAO,EACjB,UAAU,UAAO,EACjB,OAAO,UAAQ,GACd,IAAI;IAoEP;;;;;OAKG;IAEI,kBAAkB,IAAI,IAAI;CAGlC"}
|
|
@@ -116,9 +116,12 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
116
116
|
}}
|
|
117
117
|
self.customStagesMap = __TS__New(Map)
|
|
118
118
|
self.customStageCachedRoomData = __TS__New(Map)
|
|
119
|
-
self.goToCustomStage = function(____, destinationStage, _destinationStageType)
|
|
119
|
+
self.goToCustomStage = function(____, destinationName, destinationStage, _destinationStageType)
|
|
120
|
+
if destinationName == nil then
|
|
121
|
+
error("Failed to go to a custom stage since the custom trapdoors feature did not pass a destination name to the logic function.")
|
|
122
|
+
end
|
|
120
123
|
local firstFloor = destinationStage == LevelStage.BASEMENT_1
|
|
121
|
-
self:setCustomStage(
|
|
124
|
+
self:setCustomStage(destinationName, firstFloor)
|
|
122
125
|
end
|
|
123
126
|
self.postRender = function()
|
|
124
127
|
local customStage = self.v.run.currentCustomStage
|
|
@@ -234,10 +237,10 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
234
237
|
for ____, room in ipairs(getRoomsInsideGrid(nil)) do
|
|
235
238
|
do
|
|
236
239
|
if room.SafeGridIndex == startingRoomGridIndex then
|
|
237
|
-
goto
|
|
240
|
+
goto __continue27
|
|
238
241
|
end
|
|
239
242
|
if room.Data == nil then
|
|
240
|
-
goto
|
|
243
|
+
goto __continue27
|
|
241
244
|
end
|
|
242
245
|
local roomType = room.Data.Type
|
|
243
246
|
local roomShapeMap = customStage.roomTypeMap:get(roomType)
|
|
@@ -248,7 +251,7 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
248
251
|
(((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") for custom stage: ") .. customStage.name
|
|
249
252
|
)
|
|
250
253
|
end
|
|
251
|
-
goto
|
|
254
|
+
goto __continue27
|
|
252
255
|
end
|
|
253
256
|
local roomShape = room.Data.Shape
|
|
254
257
|
local roomDoorSlotFlagMap = roomShapeMap:get(roomShape)
|
|
@@ -257,7 +260,7 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
257
260
|
nil,
|
|
258
261
|
(((((((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. RoomShape[roomShape]) .. " (") .. tostring(roomShape)) .. ") for custom stage: ") .. customStage.name
|
|
259
262
|
)
|
|
260
|
-
goto
|
|
263
|
+
goto __continue27
|
|
261
264
|
end
|
|
262
265
|
local doorSlotFlags = room.Data.Doors
|
|
263
266
|
local roomsMetadata = roomDoorSlotFlagMap:get(doorSlotFlags)
|
|
@@ -270,13 +273,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
270
273
|
nil,
|
|
271
274
|
(((((((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. RoomShape[roomShape]) .. " (") .. tostring(roomShape)) .. ") + all doors enabled for custom stage: ") .. customStage.name
|
|
272
275
|
)
|
|
273
|
-
goto
|
|
276
|
+
goto __continue27
|
|
274
277
|
end
|
|
275
278
|
end
|
|
276
279
|
local randomRoom
|
|
277
280
|
if roomType == RoomType.BOSS then
|
|
278
281
|
if customStage.bossPool == nil then
|
|
279
|
-
goto
|
|
282
|
+
goto __continue27
|
|
280
283
|
end
|
|
281
284
|
randomRoom = getRandomBossRoomFromPool(
|
|
282
285
|
nil,
|
|
@@ -296,13 +299,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
296
299
|
nil,
|
|
297
300
|
(("Failed to get the room data for room variant " .. tostring(randomRoom.variant)) .. " for custom stage: ") .. customStage.name
|
|
298
301
|
)
|
|
299
|
-
goto
|
|
302
|
+
goto __continue27
|
|
300
303
|
end
|
|
301
304
|
self.customStageCachedRoomData:set(randomRoom.variant, newRoomData)
|
|
302
305
|
end
|
|
303
306
|
room.Data = newRoomData
|
|
304
307
|
end
|
|
305
|
-
::
|
|
308
|
+
::__continue27::
|
|
306
309
|
end
|
|
307
310
|
end
|
|
308
311
|
function CustomStages.prototype.setCustomStage(self, name, firstFloor, streakText, verbose)
|
|
@@ -36,6 +36,7 @@ export declare class CustomTrapdoors extends Feature {
|
|
|
36
36
|
private postPEffectUpdateReordered;
|
|
37
37
|
private checkJumpComplete;
|
|
38
38
|
private shouldTrapdoorSpawnOpen;
|
|
39
|
+
private logStateChanged;
|
|
39
40
|
/**
|
|
40
41
|
* Helper function to specify where your custom trapdoor should take the player. Call this once at
|
|
41
42
|
* the beginning of your mod for each kind of custom trapdoor that you want to have. The provided
|
|
@@ -55,7 +56,7 @@ export declare class CustomTrapdoors extends Feature {
|
|
|
55
56
|
* Inside this function, use the `setStage` or `setCustomStage` helper
|
|
56
57
|
* functions, or do something completely custom.
|
|
57
58
|
*/
|
|
58
|
-
registerCustomTrapdoorDestination(destinationName: string, destinationFunc: (destinationStage: LevelStage, destinationStageType: StageType) => void): void;
|
|
59
|
+
registerCustomTrapdoorDestination(destinationName: string, destinationFunc: (destinationName: string | undefined, destinationStage: LevelStage, destinationStageType: StageType) => void): void;
|
|
59
60
|
/**
|
|
60
61
|
* Helper function to spawn a trapdoor grid entity that will take a player to a vanilla stage or
|
|
61
62
|
* custom location.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTrapdoors.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomTrapdoors.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,UAAU,EAKV,SAAS,EACV,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomTrapdoors.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomTrapdoors.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,UAAU,EAKV,SAAS,EACV,MAAM,8BAA8B,CAAC;AA6BtC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AA+BhD,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,qCAAqC;IACrC,OAAO,CAAC,kBAAkB,CAOtB;IAqBJ;;;;;OAKG;IACH,OAAO,CAAC,WAAW,CAAY;IAE/B,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,YAAY,CAAe;IAmDnC,OAAO,CAAC,UAAU,CAMhB;IAEF,OAAO,CAAC,2BAA2B;IA+BnC,OAAO,CAAC,8BAA8B;IAmDtC,OAAO,CAAC,6BAA6B;IAsBrC,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,4BAA4B;IAyCpC,OAAO,CAAC,iCAAiC;IAsBzC,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,kCAAkC,CAaxC;IAEF,OAAO,CAAC,4BAA4B;IAcpC,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,sBAAsB;IAmB9B,OAAO,CAAC,gCAAgC;IAuCxC,OAAO,CAAC,2BAA2B;IAqCnC,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,8BAA8B;IAmDtC,OAAO,CAAC,0BAA0B,CAEhC;IAEF,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,uBAAuB;IA4B/B,OAAO,CAAC,eAAe;IAUvB;;;;;;;;;;;;;;;;;;OAkBG;IAEI,iCAAiC,CACtC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,CACf,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,gBAAgB,EAAE,UAAU,EAC5B,oBAAoB,EAAE,SAAS,KAC5B,IAAI,GACR,IAAI;IAUP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IAEI,mBAAmB,CACxB,mBAAmB,EAAE,GAAG,GAAG,MAAM,EACjC,eAAe,CAAC,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,UAAU,EAC7B,oBAAoB,CAAC,EAAE,SAAS,EAChC,QAAQ,SAAmC,EAC3C,SAAS,CAAC,EAAE,OAAO,GAClB,UAAU;CA0Dd"}
|
|
@@ -40,6 +40,8 @@ local ____TrapdoorAnimation = require("src.enums.private.TrapdoorAnimation")
|
|
|
40
40
|
local TrapdoorAnimation = ____TrapdoorAnimation.TrapdoorAnimation
|
|
41
41
|
local ____easing = require("src.functions.easing")
|
|
42
42
|
local easeOutSine = ____easing.easeOutSine
|
|
43
|
+
local ____log = require("src.functions.log")
|
|
44
|
+
local log = ____log.log
|
|
43
45
|
local ____playerCenter = require("src.functions.playerCenter")
|
|
44
46
|
local movePlayersToCenter = ____playerCenter.movePlayersToCenter
|
|
45
47
|
local ____playerIndex = require("src.functions.playerIndex")
|
|
@@ -103,16 +105,17 @@ function dropTaintedForgotten(self, player)
|
|
|
103
105
|
end
|
|
104
106
|
end
|
|
105
107
|
end
|
|
106
|
-
function goToVanillaStage(self, destinationStage, destinationStageType)
|
|
108
|
+
function goToVanillaStage(self, _destinationName, destinationStage, destinationStageType)
|
|
107
109
|
setStage(nil, destinationStage, destinationStageType)
|
|
108
110
|
end
|
|
111
|
+
local DEBUG = false
|
|
109
112
|
--- This also applies to crawl spaces. The value was determined through trial and error.
|
|
110
113
|
local TRAPDOOR_OPEN_DISTANCE = 60
|
|
111
114
|
local TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = TRAPDOOR_OPEN_DISTANCE * 2.5
|
|
112
115
|
local TRAPDOOR_BOSS_REACTION_FRAMES = 30
|
|
113
116
|
local TRAPDOOR_TOUCH_DISTANCE = 16.5
|
|
114
117
|
ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL = __TS__New(Set, {"Death", "Happy", "Sad", "Jump"})
|
|
115
|
-
local PIXELATION_TO_BLACK_FRAMES =
|
|
118
|
+
local PIXELATION_TO_BLACK_FRAMES = 60
|
|
116
119
|
local OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES = 6
|
|
117
120
|
local OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES = 5
|
|
118
121
|
____exports.CustomTrapdoors = __TS__Class()
|
|
@@ -181,6 +184,7 @@ function CustomTrapdoors.prototype.checkAllPlayersJumpComplete(self)
|
|
|
181
184
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
182
185
|
self.v.run.state = StageTravelState.PIXELATION_TO_BLACK
|
|
183
186
|
self.v.run.stateRenderFrame = renderFrameCount
|
|
187
|
+
self:logStateChanged()
|
|
184
188
|
teleport(nil, roomGridIndex, Direction.NO_DIRECTION, RoomTransitionAnim.PIXELATION)
|
|
185
189
|
end
|
|
186
190
|
function CustomTrapdoors.prototype.checkPixelationToBlackComplete(self)
|
|
@@ -194,6 +198,7 @@ function CustomTrapdoors.prototype.checkPixelationToBlackComplete(self)
|
|
|
194
198
|
return
|
|
195
199
|
end
|
|
196
200
|
self.v.run.state = StageTravelState.WAITING_FOR_FIRST_PIXELATION_TO_END
|
|
201
|
+
self:logStateChanged()
|
|
197
202
|
hud:SetVisible(false)
|
|
198
203
|
self.runInNFrames:runNextGameFrame(function()
|
|
199
204
|
local level = game:GetLevel()
|
|
@@ -216,7 +221,7 @@ function CustomTrapdoors.prototype.goToCustomTrapdoorDestination(self)
|
|
|
216
221
|
}
|
|
217
222
|
end
|
|
218
223
|
local destinationFunc = self:getDestinationFunc(self.v.run.customTrapdoorActivated)
|
|
219
|
-
destinationFunc(nil, self.v.run.customTrapdoorActivated.destinationStage, self.v.run.customTrapdoorActivated.destinationStageType)
|
|
224
|
+
destinationFunc(nil, self.v.run.customTrapdoorActivated.destinationName, self.v.run.customTrapdoorActivated.destinationStage, self.v.run.customTrapdoorActivated.destinationStageType)
|
|
220
225
|
end
|
|
221
226
|
function CustomTrapdoors.prototype.getDestinationFunc(self, customTrapdoorDescription)
|
|
222
227
|
if customTrapdoorDescription.destinationName == nil then
|
|
@@ -239,9 +244,11 @@ function CustomTrapdoors.prototype.checkSecondPixelationHalfWay(self)
|
|
|
239
244
|
return
|
|
240
245
|
end
|
|
241
246
|
self.v.run.state = StageTravelState.PIXELATION_TO_ROOM
|
|
247
|
+
self:logStateChanged()
|
|
242
248
|
hud:SetVisible(true)
|
|
243
249
|
self.runNextRoom:runNextRoom(function()
|
|
244
250
|
self.v.run.state = StageTravelState.PLAYERS_LAYING_DOWN
|
|
251
|
+
self:logStateChanged()
|
|
245
252
|
movePlayersToCenter(nil)
|
|
246
253
|
for ____, player in ipairs(getAllPlayers(nil)) do
|
|
247
254
|
player:AnimateAppear()
|
|
@@ -258,6 +265,7 @@ function CustomTrapdoors.prototype.checkAllPlayersLayingDownComplete(self)
|
|
|
258
265
|
return
|
|
259
266
|
end
|
|
260
267
|
self.v.run.state = StageTravelState.NONE
|
|
268
|
+
self:logStateChanged()
|
|
261
269
|
local tstlClassName = getTSTLClassName(nil, self)
|
|
262
270
|
if tstlClassName == nil then
|
|
263
271
|
error("Failed to find get the class name for the custom trapdoor feature.")
|
|
@@ -323,6 +331,7 @@ end
|
|
|
323
331
|
function CustomTrapdoors.prototype.playerTouchedCustomTrapdoor(self, gridEntity, trapdoorDescription, player)
|
|
324
332
|
self.v.run.state = StageTravelState.PLAYERS_JUMPING_DOWN
|
|
325
333
|
self.v.run.customTrapdoorActivated = trapdoorDescription
|
|
334
|
+
self:logStateChanged()
|
|
326
335
|
local tstlClassName = getTSTLClassName(nil, self)
|
|
327
336
|
if tstlClassName == nil then
|
|
328
337
|
error("Failed to find get the class name for the custom trapdoor feature.")
|
|
@@ -415,6 +424,14 @@ function CustomTrapdoors.prototype.shouldTrapdoorSpawnOpen(self, gridEntity, fir
|
|
|
415
424
|
end
|
|
416
425
|
return self:shouldTrapdoorOpen(gridEntity, firstSpawn)
|
|
417
426
|
end
|
|
427
|
+
function CustomTrapdoors.prototype.logStateChanged(self)
|
|
428
|
+
if DEBUG then
|
|
429
|
+
log(
|
|
430
|
+
nil,
|
|
431
|
+
((("Custom trapdoors state changed: " .. StageTravelState[self.v.run.state]) .. " (") .. tostring(self.v.run.state)) .. ")"
|
|
432
|
+
)
|
|
433
|
+
end
|
|
434
|
+
end
|
|
418
435
|
function CustomTrapdoors.prototype.registerCustomTrapdoorDestination(self, destinationName, destinationFunc)
|
|
419
436
|
if self.destinationFuncMap:has(destinationName) then
|
|
420
437
|
error(("Failed to register a custom trapdoor type of " .. destinationName) .. " since this custom trapdoor type has already been registered.")
|
package/package.json
CHANGED
|
@@ -199,11 +199,18 @@ export class CustomStages extends Feature {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
private goToCustomStage = (
|
|
202
|
+
destinationName: string | undefined,
|
|
202
203
|
destinationStage: LevelStage,
|
|
203
204
|
_destinationStageType: StageType,
|
|
204
205
|
) => {
|
|
206
|
+
if (destinationName === undefined) {
|
|
207
|
+
error(
|
|
208
|
+
"Failed to go to a custom stage since the custom trapdoors feature did not pass a destination name to the logic function.",
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
205
212
|
const firstFloor = destinationStage === LevelStage.BASEMENT_1;
|
|
206
|
-
this.setCustomStage(
|
|
213
|
+
this.setCustomStage(destinationName, firstFloor);
|
|
207
214
|
};
|
|
208
215
|
|
|
209
216
|
// ModCallback.POST_RENDER (2)
|
|
@@ -21,6 +21,7 @@ import { GridEntityTypeCustom } from "../../../enums/private/GridEntityTypeCusto
|
|
|
21
21
|
import { StageTravelState } from "../../../enums/private/StageTravelState";
|
|
22
22
|
import { TrapdoorAnimation } from "../../../enums/private/TrapdoorAnimation";
|
|
23
23
|
import { easeOutSine } from "../../../functions/easing";
|
|
24
|
+
import { log } from "../../../functions/log";
|
|
24
25
|
import { movePlayersToCenter } from "../../../functions/playerCenter";
|
|
25
26
|
import {
|
|
26
27
|
getAllPlayers,
|
|
@@ -48,6 +49,8 @@ import { RunInNFrames } from "./RunInNFrames";
|
|
|
48
49
|
import { RunNextRoom } from "./RunNextRoom";
|
|
49
50
|
import { StageHistory } from "./StageHistory";
|
|
50
51
|
|
|
52
|
+
const DEBUG = false as boolean;
|
|
53
|
+
|
|
51
54
|
/** This also applies to crawl spaces. The value was determined through trial and error. */
|
|
52
55
|
const TRAPDOOR_OPEN_DISTANCE = 60;
|
|
53
56
|
|
|
@@ -63,7 +66,7 @@ const ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL: ReadonlySet<string> = new Set([
|
|
|
63
66
|
"Jump",
|
|
64
67
|
]);
|
|
65
68
|
|
|
66
|
-
const PIXELATION_TO_BLACK_FRAMES =
|
|
69
|
+
const PIXELATION_TO_BLACK_FRAMES = 60;
|
|
67
70
|
|
|
68
71
|
const OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES = 6;
|
|
69
72
|
const OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES = 5;
|
|
@@ -72,7 +75,11 @@ export class CustomTrapdoors extends Feature {
|
|
|
72
75
|
/** Indexed by custom trapdoor ID. */
|
|
73
76
|
private destinationFuncMap = new Map<
|
|
74
77
|
string,
|
|
75
|
-
(
|
|
78
|
+
(
|
|
79
|
+
destinationName: string | undefined,
|
|
80
|
+
destinationStage: LevelStage,
|
|
81
|
+
destinationStageType: StageType,
|
|
82
|
+
) => void
|
|
76
83
|
>();
|
|
77
84
|
|
|
78
85
|
/** @internal */
|
|
@@ -181,6 +188,7 @@ export class CustomTrapdoors extends Feature {
|
|
|
181
188
|
|
|
182
189
|
this.v.run.state = StageTravelState.PIXELATION_TO_BLACK;
|
|
183
190
|
this.v.run.stateRenderFrame = renderFrameCount;
|
|
191
|
+
this.logStateChanged();
|
|
184
192
|
|
|
185
193
|
// In order to display the pixelation effect that should happen when we go to a new floor, we
|
|
186
194
|
// need to start a room transition. We arbitrarily pick the current room for this purpose. (We
|
|
@@ -215,6 +223,7 @@ export class CustomTrapdoors extends Feature {
|
|
|
215
223
|
}
|
|
216
224
|
|
|
217
225
|
this.v.run.state = StageTravelState.WAITING_FOR_FIRST_PIXELATION_TO_END;
|
|
226
|
+
this.logStateChanged();
|
|
218
227
|
|
|
219
228
|
// Now, we display a black sprite on top of the pixelation effect, to prevent showing the rest
|
|
220
229
|
// of the animation.
|
|
@@ -263,6 +272,7 @@ export class CustomTrapdoors extends Feature {
|
|
|
263
272
|
this.v.run.customTrapdoorActivated,
|
|
264
273
|
);
|
|
265
274
|
destinationFunc(
|
|
275
|
+
this.v.run.customTrapdoorActivated.destinationName,
|
|
266
276
|
this.v.run.customTrapdoorActivated.destinationStage,
|
|
267
277
|
this.v.run.customTrapdoorActivated.destinationStageType,
|
|
268
278
|
);
|
|
@@ -270,7 +280,11 @@ export class CustomTrapdoors extends Feature {
|
|
|
270
280
|
|
|
271
281
|
private getDestinationFunc(
|
|
272
282
|
customTrapdoorDescription: CustomTrapdoorDescription,
|
|
273
|
-
): (
|
|
283
|
+
): (
|
|
284
|
+
destinationName: string | undefined,
|
|
285
|
+
destinationStage: LevelStage,
|
|
286
|
+
destinationStageType: StageType,
|
|
287
|
+
) => void {
|
|
274
288
|
if (customTrapdoorDescription.destinationName === undefined) {
|
|
275
289
|
return goToVanillaStage;
|
|
276
290
|
}
|
|
@@ -304,11 +318,13 @@ export class CustomTrapdoors extends Feature {
|
|
|
304
318
|
}
|
|
305
319
|
|
|
306
320
|
this.v.run.state = StageTravelState.PIXELATION_TO_ROOM;
|
|
321
|
+
this.logStateChanged();
|
|
307
322
|
|
|
308
323
|
hud.SetVisible(true);
|
|
309
324
|
|
|
310
325
|
this.runNextRoom.runNextRoom(() => {
|
|
311
326
|
this.v.run.state = StageTravelState.PLAYERS_LAYING_DOWN;
|
|
327
|
+
this.logStateChanged();
|
|
312
328
|
|
|
313
329
|
// After the room transition, the players will be placed next to a door, but they should be in
|
|
314
330
|
// the center of the room to emulate what happens on a vanilla stage.
|
|
@@ -334,6 +350,7 @@ export class CustomTrapdoors extends Feature {
|
|
|
334
350
|
}
|
|
335
351
|
|
|
336
352
|
this.v.run.state = StageTravelState.NONE;
|
|
353
|
+
this.logStateChanged();
|
|
337
354
|
|
|
338
355
|
const tstlClassName = getTSTLClassName(this);
|
|
339
356
|
if (tstlClassName === undefined) {
|
|
@@ -474,6 +491,7 @@ export class CustomTrapdoors extends Feature {
|
|
|
474
491
|
) {
|
|
475
492
|
this.v.run.state = StageTravelState.PLAYERS_JUMPING_DOWN;
|
|
476
493
|
this.v.run.customTrapdoorActivated = trapdoorDescription;
|
|
494
|
+
this.logStateChanged();
|
|
477
495
|
|
|
478
496
|
const tstlClassName = getTSTLClassName(this);
|
|
479
497
|
if (tstlClassName === undefined) {
|
|
@@ -621,6 +639,16 @@ export class CustomTrapdoors extends Feature {
|
|
|
621
639
|
return this.shouldTrapdoorOpen(gridEntity, firstSpawn);
|
|
622
640
|
}
|
|
623
641
|
|
|
642
|
+
private logStateChanged(): void {
|
|
643
|
+
if (DEBUG) {
|
|
644
|
+
log(
|
|
645
|
+
`Custom trapdoors state changed: ${
|
|
646
|
+
StageTravelState[this.v.run.state]
|
|
647
|
+
} (${this.v.run.state})`,
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
624
652
|
/**
|
|
625
653
|
* Helper function to specify where your custom trapdoor should take the player. Call this once at
|
|
626
654
|
* the beginning of your mod for each kind of custom trapdoor that you want to have. The provided
|
|
@@ -644,6 +672,7 @@ export class CustomTrapdoors extends Feature {
|
|
|
644
672
|
public registerCustomTrapdoorDestination(
|
|
645
673
|
destinationName: string,
|
|
646
674
|
destinationFunc: (
|
|
675
|
+
destinationName: string | undefined,
|
|
647
676
|
destinationStage: LevelStage,
|
|
648
677
|
destinationStageType: StageType,
|
|
649
678
|
) => void,
|
|
@@ -827,6 +856,7 @@ function dropTaintedForgotten(player: EntityPlayer) {
|
|
|
827
856
|
|
|
828
857
|
/** The default `destinationFunc` for a custom trapdoor. */
|
|
829
858
|
function goToVanillaStage(
|
|
859
|
+
_destinationName: string | undefined,
|
|
830
860
|
destinationStage: LevelStage,
|
|
831
861
|
destinationStageType: StageType,
|
|
832
862
|
) {
|