isaacscript-common 30.12.9 → 30.12.11
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.rollup.d.ts +24 -0
- package/dist/isaacscript-common.lua +53 -10
- package/dist/src/classes/features/other/CustomStages.d.ts +11 -0
- package/dist/src/classes/features/other/CustomStages.d.ts.map +1 -1
- package/dist/src/classes/features/other/CustomStages.lua +42 -9
- package/dist/src/functions/array.d.ts +12 -0
- package/dist/src/functions/array.d.ts.map +1 -1
- package/dist/src/functions/array.lua +19 -0
- package/package.json +2 -2
- package/src/classes/features/other/CustomStages.ts +60 -0
- package/src/functions/array.ts +27 -0
package/dist/index.rollup.d.ts
CHANGED
|
@@ -2174,6 +2174,7 @@ declare class CustomStages extends Feature {
|
|
|
2174
2174
|
private readonly customStagesMap;
|
|
2175
2175
|
/** Indexed by room variant. */
|
|
2176
2176
|
private readonly customStageCachedRoomData;
|
|
2177
|
+
private usingRedKey;
|
|
2177
2178
|
private readonly customGridEntities;
|
|
2178
2179
|
private readonly customTrapdoors;
|
|
2179
2180
|
private readonly disableAllSound;
|
|
@@ -2185,8 +2186,18 @@ declare class CustomStages extends Feature {
|
|
|
2185
2186
|
private initCustomTrapdoorDestination;
|
|
2186
2187
|
private readonly goToCustomStage;
|
|
2187
2188
|
private readonly postRender;
|
|
2189
|
+
/**
|
|
2190
|
+
* Fix the bug where Red Key will not work on custom floors (due to the stage being a bugged
|
|
2191
|
+
* value).
|
|
2192
|
+
*/
|
|
2193
|
+
private readonly postUseItemRedKey;
|
|
2188
2194
|
private readonly postCurseEval;
|
|
2189
2195
|
private readonly getShaderParams;
|
|
2196
|
+
/**
|
|
2197
|
+
* Fix the bug where Red Key will not work on custom floors (due to the stage being a bugged
|
|
2198
|
+
* value).
|
|
2199
|
+
*/
|
|
2200
|
+
private readonly preUseItemRedKey;
|
|
2190
2201
|
private readonly postGridEntityBrokenRockAlt;
|
|
2191
2202
|
private readonly postGridEntityInit;
|
|
2192
2203
|
private readonly postNewRoomReordered;
|
|
@@ -4199,6 +4210,19 @@ export declare function fillLevelWithRedRooms(): void;
|
|
|
4199
4210
|
*/
|
|
4200
4211
|
export declare function filter<T>(array: T[], func: (value: T, index: number, array: T[]) => boolean): T[];
|
|
4201
4212
|
|
|
4213
|
+
/**
|
|
4214
|
+
* Helper function to perform a map and a filter at the same time. Similar to `Array.map`, provide a
|
|
4215
|
+
* function that transforms a value, but return `undefined` if the value should be skipped. (Thus,
|
|
4216
|
+
* this function cannot be used in situations where `undefined` can be a valid array element.)
|
|
4217
|
+
*
|
|
4218
|
+
* This function is useful because a map will always produce an array with the same amount of
|
|
4219
|
+
* elements as the original array.
|
|
4220
|
+
*
|
|
4221
|
+
* This is named `filterMap` after the Rust function:
|
|
4222
|
+
* https://doc.rust-lang.org/std/iter/struct.FilterMap.html
|
|
4223
|
+
*/
|
|
4224
|
+
export declare function filterMap<OldT, NewT>(array: OldT[], func: (element: OldT) => NewT | undefined): NewT[];
|
|
4225
|
+
|
|
4202
4226
|
/**
|
|
4203
4227
|
* Helper function for non-TypeScript users to find an element in an array.
|
|
4204
4228
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 30.12.
|
|
3
|
+
isaacscript-common 30.12.11
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -16854,6 +16854,16 @@ end
|
|
|
16854
16854
|
function ____exports.emptyArray(self, array)
|
|
16855
16855
|
__TS__ArraySplice(array, 0, #array)
|
|
16856
16856
|
end
|
|
16857
|
+
function ____exports.filterMap(self, array, func)
|
|
16858
|
+
local newArray = {}
|
|
16859
|
+
for ____, element in ipairs(array) do
|
|
16860
|
+
local newElement = func(nil, element)
|
|
16861
|
+
if newElement ~= nil then
|
|
16862
|
+
newArray[#newArray + 1] = newElement
|
|
16863
|
+
end
|
|
16864
|
+
end
|
|
16865
|
+
return newArray
|
|
16866
|
+
end
|
|
16857
16867
|
function ____exports.getArrayCombinations(self, array, includeEmptyArray, min, max)
|
|
16858
16868
|
if min == nil or min <= 0 then
|
|
16859
16869
|
min = 1
|
|
@@ -44628,6 +44638,7 @@ local __TS__DecorateLegacy = ____lualib.__TS__DecorateLegacy
|
|
|
44628
44638
|
local ____exports = {}
|
|
44629
44639
|
local getRoomTypeMap
|
|
44630
44640
|
local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
|
|
44641
|
+
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
|
|
44631
44642
|
local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
|
|
44632
44643
|
local LevelCurse = ____isaac_2Dtypescript_2Ddefinitions.LevelCurse
|
|
44633
44644
|
local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
|
|
@@ -44733,6 +44744,7 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
44733
44744
|
self.v = v
|
|
44734
44745
|
self.customStagesMap = __TS__New(Map)
|
|
44735
44746
|
self.customStageCachedRoomData = __TS__New(Map)
|
|
44747
|
+
self.usingRedKey = false
|
|
44736
44748
|
self.goToCustomStage = function(____, destinationName, destinationStage, _destinationStageType)
|
|
44737
44749
|
if destinationName == nil then
|
|
44738
44750
|
error("Failed to go to a custom stage since the custom trapdoors feature did not pass a destination name to the logic function.")
|
|
@@ -44756,6 +44768,19 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
44756
44768
|
end
|
|
44757
44769
|
end
|
|
44758
44770
|
end
|
|
44771
|
+
self.postUseItemRedKey = function()
|
|
44772
|
+
local customStage = v.run.currentCustomStage
|
|
44773
|
+
if customStage == nil then
|
|
44774
|
+
return nil
|
|
44775
|
+
end
|
|
44776
|
+
if not self.usingRedKey then
|
|
44777
|
+
return
|
|
44778
|
+
end
|
|
44779
|
+
self.usingRedKey = false
|
|
44780
|
+
local level = game:GetLevel()
|
|
44781
|
+
level:SetStage(CUSTOM_FLOOR_STAGE, CUSTOM_FLOOR_STAGE_TYPE)
|
|
44782
|
+
return nil
|
|
44783
|
+
end
|
|
44759
44784
|
self.postCurseEval = function(____, curses)
|
|
44760
44785
|
local customStage = v.run.currentCustomStage
|
|
44761
44786
|
if customStage == nil then
|
|
@@ -44774,6 +44799,18 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
44774
44799
|
streakTextGetShaderParams(nil, customStage, shaderName)
|
|
44775
44800
|
return nil
|
|
44776
44801
|
end
|
|
44802
|
+
self.preUseItemRedKey = function()
|
|
44803
|
+
local customStage = v.run.currentCustomStage
|
|
44804
|
+
if customStage == nil then
|
|
44805
|
+
return nil
|
|
44806
|
+
end
|
|
44807
|
+
self.usingRedKey = true
|
|
44808
|
+
local level = game:GetLevel()
|
|
44809
|
+
local stage = customStage.baseStage or DEFAULT_BASE_STAGE
|
|
44810
|
+
local stageType = customStage.baseStageType or DEFAULT_BASE_STAGE_TYPE
|
|
44811
|
+
level:SetStage(stage, stageType)
|
|
44812
|
+
return nil
|
|
44813
|
+
end
|
|
44777
44814
|
self.postGridEntityBrokenRockAlt = function(____, gridEntity)
|
|
44778
44815
|
local customStage = v.run.currentCustomStage
|
|
44779
44816
|
if customStage == nil then
|
|
@@ -44834,7 +44871,13 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
44834
44871
|
ISCFeature.PAUSE,
|
|
44835
44872
|
ISCFeature.RUN_IN_N_FRAMES
|
|
44836
44873
|
}
|
|
44837
|
-
self.callbacksUsed = {
|
|
44874
|
+
self.callbacksUsed = {
|
|
44875
|
+
{ModCallback.POST_RENDER, self.postRender},
|
|
44876
|
+
{ModCallback.POST_USE_ITEM, self.postUseItemRedKey, {CollectibleType.RED_KEY}},
|
|
44877
|
+
{ModCallback.POST_CURSE_EVAL, self.postCurseEval},
|
|
44878
|
+
{ModCallback.GET_SHADER_PARAMS, self.getShaderParams},
|
|
44879
|
+
{ModCallback.PRE_USE_ITEM, self.preUseItemRedKey, {CollectibleType.RED_KEY}}
|
|
44880
|
+
}
|
|
44838
44881
|
self.customCallbacksUsed = {{ModCallbackCustom.POST_GRID_ENTITY_BROKEN, self.postGridEntityBrokenRockAlt, {GridEntityType.ROCK_ALT}}, {ModCallbackCustom.POST_GRID_ENTITY_INIT, self.postGridEntityInit}, {ModCallbackCustom.POST_NEW_ROOM_REORDERED, self.postNewRoomReordered}}
|
|
44839
44882
|
self.customGridEntities = customGridEntities
|
|
44840
44883
|
self.customTrapdoors = customTrapdoors
|
|
@@ -44868,10 +44911,10 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
44868
44911
|
for ____, room in ipairs(getRoomsInsideGrid(nil)) do
|
|
44869
44912
|
do
|
|
44870
44913
|
if room.SafeGridIndex == startingRoomGridIndex then
|
|
44871
|
-
goto
|
|
44914
|
+
goto __continue36
|
|
44872
44915
|
end
|
|
44873
44916
|
if room.Data == nil then
|
|
44874
|
-
goto
|
|
44917
|
+
goto __continue36
|
|
44875
44918
|
end
|
|
44876
44919
|
local roomType = room.Data.Type
|
|
44877
44920
|
local roomShapeMap = customStage.roomTypeMap:get(roomType)
|
|
@@ -44879,13 +44922,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
44879
44922
|
if roomType == RoomType.DEFAULT then
|
|
44880
44923
|
logError((((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") for custom stage: ") .. customStage.name)
|
|
44881
44924
|
end
|
|
44882
|
-
goto
|
|
44925
|
+
goto __continue36
|
|
44883
44926
|
end
|
|
44884
44927
|
local roomShape = room.Data.Shape
|
|
44885
44928
|
local roomDoorSlotFlagMap = roomShapeMap:get(roomShape)
|
|
44886
44929
|
if roomDoorSlotFlagMap == nil then
|
|
44887
44930
|
logError((((((((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. RoomShape[roomShape]) .. " (") .. tostring(roomShape)) .. ") for custom stage: ") .. customStage.name)
|
|
44888
|
-
goto
|
|
44931
|
+
goto __continue36
|
|
44889
44932
|
end
|
|
44890
44933
|
local doorSlotFlags = room.Data.Doors
|
|
44891
44934
|
local roomsMetadata = roomDoorSlotFlagMap:get(doorSlotFlags)
|
|
@@ -44895,13 +44938,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
44895
44938
|
roomsMetadata = roomDoorSlotFlagMap:get(allDoorSlotFlags)
|
|
44896
44939
|
if roomsMetadata == nil then
|
|
44897
44940
|
logError((((((((("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)
|
|
44898
|
-
goto
|
|
44941
|
+
goto __continue36
|
|
44899
44942
|
end
|
|
44900
44943
|
end
|
|
44901
44944
|
local randomRoom
|
|
44902
44945
|
if roomType == RoomType.BOSS then
|
|
44903
44946
|
if customStage.bossPool == nil then
|
|
44904
|
-
goto
|
|
44947
|
+
goto __continue36
|
|
44905
44948
|
end
|
|
44906
44949
|
randomRoom = getRandomBossRoomFromPool(
|
|
44907
44950
|
nil,
|
|
@@ -44924,13 +44967,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
44924
44967
|
)
|
|
44925
44968
|
if newRoomData == nil then
|
|
44926
44969
|
logError((("Failed to get the room data for room variant " .. tostring(randomRoom.variant)) .. " for custom stage: ") .. customStage.name)
|
|
44927
|
-
goto
|
|
44970
|
+
goto __continue36
|
|
44928
44971
|
end
|
|
44929
44972
|
self.customStageCachedRoomData:set(randomRoom.variant, newRoomData)
|
|
44930
44973
|
end
|
|
44931
44974
|
room.Data = newRoomData
|
|
44932
44975
|
end
|
|
44933
|
-
::
|
|
44976
|
+
::__continue36::
|
|
44934
44977
|
end
|
|
44935
44978
|
end
|
|
44936
44979
|
function CustomStages.prototype.setCustomStage(self, name, firstFloor, streakText, verbose)
|
|
@@ -4,6 +4,7 @@ export declare class CustomStages extends Feature {
|
|
|
4
4
|
private readonly customStagesMap;
|
|
5
5
|
/** Indexed by room variant. */
|
|
6
6
|
private readonly customStageCachedRoomData;
|
|
7
|
+
private usingRedKey;
|
|
7
8
|
private readonly customGridEntities;
|
|
8
9
|
private readonly customTrapdoors;
|
|
9
10
|
private readonly disableAllSound;
|
|
@@ -15,8 +16,18 @@ export declare class CustomStages extends Feature {
|
|
|
15
16
|
private initCustomTrapdoorDestination;
|
|
16
17
|
private readonly goToCustomStage;
|
|
17
18
|
private readonly postRender;
|
|
19
|
+
/**
|
|
20
|
+
* Fix the bug where Red Key will not work on custom floors (due to the stage being a bugged
|
|
21
|
+
* value).
|
|
22
|
+
*/
|
|
23
|
+
private readonly postUseItemRedKey;
|
|
18
24
|
private readonly postCurseEval;
|
|
19
25
|
private readonly getShaderParams;
|
|
26
|
+
/**
|
|
27
|
+
* Fix the bug where Red Key will not work on custom floors (due to the stage being a bugged
|
|
28
|
+
* value).
|
|
29
|
+
*/
|
|
30
|
+
private readonly preUseItemRedKey;
|
|
20
31
|
private readonly postGridEntityBrokenRockAlt;
|
|
21
32
|
private readonly postGridEntityInit;
|
|
22
33
|
private readonly postNewRoomReordered;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomStages.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomStages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomStages.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomStages.ts"],"names":[],"mappings":"AAyCA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AA2ChD,qBAAa,YAAa,SAAQ,OAAO;IAIvC,oCAAoC;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkC;IAElE,+BAA+B;IAC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____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
11
|
+
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
|
|
11
12
|
local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
|
|
12
13
|
local LevelCurse = ____isaac_2Dtypescript_2Ddefinitions.LevelCurse
|
|
13
14
|
local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
|
|
@@ -115,6 +116,7 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
115
116
|
self.v = v
|
|
116
117
|
self.customStagesMap = __TS__New(Map)
|
|
117
118
|
self.customStageCachedRoomData = __TS__New(Map)
|
|
119
|
+
self.usingRedKey = false
|
|
118
120
|
self.goToCustomStage = function(____, destinationName, destinationStage, _destinationStageType)
|
|
119
121
|
if destinationName == nil then
|
|
120
122
|
error("Failed to go to a custom stage since the custom trapdoors feature did not pass a destination name to the logic function.")
|
|
@@ -138,6 +140,19 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
138
140
|
end
|
|
139
141
|
end
|
|
140
142
|
end
|
|
143
|
+
self.postUseItemRedKey = function()
|
|
144
|
+
local customStage = v.run.currentCustomStage
|
|
145
|
+
if customStage == nil then
|
|
146
|
+
return nil
|
|
147
|
+
end
|
|
148
|
+
if not self.usingRedKey then
|
|
149
|
+
return
|
|
150
|
+
end
|
|
151
|
+
self.usingRedKey = false
|
|
152
|
+
local level = game:GetLevel()
|
|
153
|
+
level:SetStage(CUSTOM_FLOOR_STAGE, CUSTOM_FLOOR_STAGE_TYPE)
|
|
154
|
+
return nil
|
|
155
|
+
end
|
|
141
156
|
self.postCurseEval = function(____, curses)
|
|
142
157
|
local customStage = v.run.currentCustomStage
|
|
143
158
|
if customStage == nil then
|
|
@@ -156,6 +171,18 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
156
171
|
streakTextGetShaderParams(nil, customStage, shaderName)
|
|
157
172
|
return nil
|
|
158
173
|
end
|
|
174
|
+
self.preUseItemRedKey = function()
|
|
175
|
+
local customStage = v.run.currentCustomStage
|
|
176
|
+
if customStage == nil then
|
|
177
|
+
return nil
|
|
178
|
+
end
|
|
179
|
+
self.usingRedKey = true
|
|
180
|
+
local level = game:GetLevel()
|
|
181
|
+
local stage = customStage.baseStage or DEFAULT_BASE_STAGE
|
|
182
|
+
local stageType = customStage.baseStageType or DEFAULT_BASE_STAGE_TYPE
|
|
183
|
+
level:SetStage(stage, stageType)
|
|
184
|
+
return nil
|
|
185
|
+
end
|
|
159
186
|
self.postGridEntityBrokenRockAlt = function(____, gridEntity)
|
|
160
187
|
local customStage = v.run.currentCustomStage
|
|
161
188
|
if customStage == nil then
|
|
@@ -216,7 +243,13 @@ function CustomStages.prototype.____constructor(self, customGridEntities, custom
|
|
|
216
243
|
ISCFeature.PAUSE,
|
|
217
244
|
ISCFeature.RUN_IN_N_FRAMES
|
|
218
245
|
}
|
|
219
|
-
self.callbacksUsed = {
|
|
246
|
+
self.callbacksUsed = {
|
|
247
|
+
{ModCallback.POST_RENDER, self.postRender},
|
|
248
|
+
{ModCallback.POST_USE_ITEM, self.postUseItemRedKey, {CollectibleType.RED_KEY}},
|
|
249
|
+
{ModCallback.POST_CURSE_EVAL, self.postCurseEval},
|
|
250
|
+
{ModCallback.GET_SHADER_PARAMS, self.getShaderParams},
|
|
251
|
+
{ModCallback.PRE_USE_ITEM, self.preUseItemRedKey, {CollectibleType.RED_KEY}}
|
|
252
|
+
}
|
|
220
253
|
self.customCallbacksUsed = {{ModCallbackCustom.POST_GRID_ENTITY_BROKEN, self.postGridEntityBrokenRockAlt, {GridEntityType.ROCK_ALT}}, {ModCallbackCustom.POST_GRID_ENTITY_INIT, self.postGridEntityInit}, {ModCallbackCustom.POST_NEW_ROOM_REORDERED, self.postNewRoomReordered}}
|
|
221
254
|
self.customGridEntities = customGridEntities
|
|
222
255
|
self.customTrapdoors = customTrapdoors
|
|
@@ -250,10 +283,10 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
250
283
|
for ____, room in ipairs(getRoomsInsideGrid(nil)) do
|
|
251
284
|
do
|
|
252
285
|
if room.SafeGridIndex == startingRoomGridIndex then
|
|
253
|
-
goto
|
|
286
|
+
goto __continue36
|
|
254
287
|
end
|
|
255
288
|
if room.Data == nil then
|
|
256
|
-
goto
|
|
289
|
+
goto __continue36
|
|
257
290
|
end
|
|
258
291
|
local roomType = room.Data.Type
|
|
259
292
|
local roomShapeMap = customStage.roomTypeMap:get(roomType)
|
|
@@ -261,13 +294,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
261
294
|
if roomType == RoomType.DEFAULT then
|
|
262
295
|
logError((((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") for custom stage: ") .. customStage.name)
|
|
263
296
|
end
|
|
264
|
-
goto
|
|
297
|
+
goto __continue36
|
|
265
298
|
end
|
|
266
299
|
local roomShape = room.Data.Shape
|
|
267
300
|
local roomDoorSlotFlagMap = roomShapeMap:get(roomShape)
|
|
268
301
|
if roomDoorSlotFlagMap == nil then
|
|
269
302
|
logError((((((((("Failed to find any custom rooms for RoomType." .. RoomType[roomType]) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. RoomShape[roomShape]) .. " (") .. tostring(roomShape)) .. ") for custom stage: ") .. customStage.name)
|
|
270
|
-
goto
|
|
303
|
+
goto __continue36
|
|
271
304
|
end
|
|
272
305
|
local doorSlotFlags = room.Data.Doors
|
|
273
306
|
local roomsMetadata = roomDoorSlotFlagMap:get(doorSlotFlags)
|
|
@@ -277,13 +310,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
277
310
|
roomsMetadata = roomDoorSlotFlagMap:get(allDoorSlotFlags)
|
|
278
311
|
if roomsMetadata == nil then
|
|
279
312
|
logError((((((((("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)
|
|
280
|
-
goto
|
|
313
|
+
goto __continue36
|
|
281
314
|
end
|
|
282
315
|
end
|
|
283
316
|
local randomRoom
|
|
284
317
|
if roomType == RoomType.BOSS then
|
|
285
318
|
if customStage.bossPool == nil then
|
|
286
|
-
goto
|
|
319
|
+
goto __continue36
|
|
287
320
|
end
|
|
288
321
|
randomRoom = getRandomBossRoomFromPool(
|
|
289
322
|
nil,
|
|
@@ -306,13 +339,13 @@ function CustomStages.prototype.setStageRoomsData(self, customStage, rng, verbos
|
|
|
306
339
|
)
|
|
307
340
|
if newRoomData == nil then
|
|
308
341
|
logError((("Failed to get the room data for room variant " .. tostring(randomRoom.variant)) .. " for custom stage: ") .. customStage.name)
|
|
309
|
-
goto
|
|
342
|
+
goto __continue36
|
|
310
343
|
end
|
|
311
344
|
self.customStageCachedRoomData:set(randomRoom.variant, newRoomData)
|
|
312
345
|
end
|
|
313
346
|
room.Data = newRoomData
|
|
314
347
|
end
|
|
315
|
-
::
|
|
348
|
+
::__continue36::
|
|
316
349
|
end
|
|
317
350
|
end
|
|
318
351
|
function CustomStages.prototype.setCustomStage(self, name, firstFloor, streakText, verbose)
|
|
@@ -93,6 +93,18 @@ export declare function combineArrays<T>(...arrays: Array<T[] | readonly T[]>):
|
|
|
93
93
|
export declare function copyArray<T>(oldArray: T[] | readonly T[], numElements?: int): T[];
|
|
94
94
|
/** Helper function to remove all of the elements in an array in-place. */
|
|
95
95
|
export declare function emptyArray<T>(array: T[]): void;
|
|
96
|
+
/**
|
|
97
|
+
* Helper function to perform a map and a filter at the same time. Similar to `Array.map`, provide a
|
|
98
|
+
* function that transforms a value, but return `undefined` if the value should be skipped. (Thus,
|
|
99
|
+
* this function cannot be used in situations where `undefined` can be a valid array element.)
|
|
100
|
+
*
|
|
101
|
+
* This function is useful because a map will always produce an array with the same amount of
|
|
102
|
+
* elements as the original array.
|
|
103
|
+
*
|
|
104
|
+
* This is named `filterMap` after the Rust function:
|
|
105
|
+
* https://doc.rust-lang.org/std/iter/struct.FilterMap.html
|
|
106
|
+
*/
|
|
107
|
+
export declare function filterMap<OldT, NewT>(array: OldT[], func: (element: OldT) => NewT | undefined): NewT[];
|
|
96
108
|
/**
|
|
97
109
|
* Helper function to get all possible combinations of the given array. This includes the
|
|
98
110
|
* combination of an empty array.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/functions/array.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAC1B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GACzB,OAAO,CAST;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,CAAC,EAAE,CAIL;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,CAAC,EAAE,CAIL;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,KAAK,EAAE,CAAC,EAAE,EACV,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,OAAO,CAcT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,EAAE,EACV,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,OAAO,CAWT;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,aAAa,EAAE,CAA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QG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,CAAC,EAAE,CAKL;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,IAAI,CAWN;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3E"}
|
|
@@ -290,6 +290,25 @@ end
|
|
|
290
290
|
function ____exports.emptyArray(self, array)
|
|
291
291
|
__TS__ArraySplice(array, 0, #array)
|
|
292
292
|
end
|
|
293
|
+
--- Helper function to perform a map and a filter at the same time. Similar to `Array.map`, provide a
|
|
294
|
+
-- function that transforms a value, but return `undefined` if the value should be skipped. (Thus,
|
|
295
|
+
-- this function cannot be used in situations where `undefined` can be a valid array element.)
|
|
296
|
+
--
|
|
297
|
+
-- This function is useful because a map will always produce an array with the same amount of
|
|
298
|
+
-- elements as the original array.
|
|
299
|
+
--
|
|
300
|
+
-- This is named `filterMap` after the Rust function:
|
|
301
|
+
-- https://doc.rust-lang.org/std/iter/struct.FilterMap.html
|
|
302
|
+
function ____exports.filterMap(self, array, func)
|
|
303
|
+
local newArray = {}
|
|
304
|
+
for ____, element in ipairs(array) do
|
|
305
|
+
local newElement = func(nil, element)
|
|
306
|
+
if newElement ~= nil then
|
|
307
|
+
newArray[#newArray + 1] = newElement
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
return newArray
|
|
311
|
+
end
|
|
293
312
|
--- Helper function to get all possible combinations of the given array. This includes the
|
|
294
313
|
-- combination of an empty array.
|
|
295
314
|
--
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "30.12.
|
|
3
|
+
"version": "30.12.11",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"main": "dist/src/index",
|
|
26
26
|
"types": "dist/index.rollup.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^13.0.
|
|
28
|
+
"isaac-typescript-definitions": "^13.0.23"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DoorSlotFlag, Music } from "isaac-typescript-definitions";
|
|
2
2
|
import {
|
|
3
|
+
CollectibleType,
|
|
3
4
|
GridEntityType,
|
|
4
5
|
LevelCurse,
|
|
5
6
|
LevelStage,
|
|
@@ -91,6 +92,8 @@ export class CustomStages extends Feature {
|
|
|
91
92
|
/** Indexed by room variant. */
|
|
92
93
|
private readonly customStageCachedRoomData = new Map<int, RoomConfig>();
|
|
93
94
|
|
|
95
|
+
private usingRedKey = false;
|
|
96
|
+
|
|
94
97
|
private readonly customGridEntities: CustomGridEntities;
|
|
95
98
|
private readonly customTrapdoors: CustomTrapdoors;
|
|
96
99
|
private readonly disableAllSound: DisableAllSound;
|
|
@@ -122,11 +125,25 @@ export class CustomStages extends Feature {
|
|
|
122
125
|
// 2
|
|
123
126
|
[ModCallback.POST_RENDER, this.postRender],
|
|
124
127
|
|
|
128
|
+
// 3
|
|
129
|
+
[
|
|
130
|
+
ModCallback.POST_USE_ITEM,
|
|
131
|
+
this.postUseItemRedKey,
|
|
132
|
+
[CollectibleType.RED_KEY],
|
|
133
|
+
],
|
|
134
|
+
|
|
125
135
|
// 12
|
|
126
136
|
[ModCallback.POST_CURSE_EVAL, this.postCurseEval],
|
|
127
137
|
|
|
128
138
|
// 21
|
|
129
139
|
[ModCallback.GET_SHADER_PARAMS, this.getShaderParams],
|
|
140
|
+
|
|
141
|
+
// 23
|
|
142
|
+
[
|
|
143
|
+
ModCallback.PRE_USE_ITEM,
|
|
144
|
+
this.preUseItemRedKey,
|
|
145
|
+
[CollectibleType.RED_KEY],
|
|
146
|
+
],
|
|
130
147
|
];
|
|
131
148
|
|
|
132
149
|
this.customCallbacksUsed = [
|
|
@@ -216,6 +233,28 @@ export class CustomStages extends Feature {
|
|
|
216
233
|
}
|
|
217
234
|
};
|
|
218
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Fix the bug where Red Key will not work on custom floors (due to the stage being a bugged
|
|
238
|
+
* value).
|
|
239
|
+
*/
|
|
240
|
+
// ModCallback.POST_USE_ITEM (3)
|
|
241
|
+
private readonly postUseItemRedKey = (): boolean | undefined => {
|
|
242
|
+
const customStage = v.run.currentCustomStage;
|
|
243
|
+
if (customStage === null) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (!this.usingRedKey) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
this.usingRedKey = false;
|
|
251
|
+
|
|
252
|
+
const level = game.GetLevel();
|
|
253
|
+
level.SetStage(CUSTOM_FLOOR_STAGE, CUSTOM_FLOOR_STAGE_TYPE);
|
|
254
|
+
|
|
255
|
+
return undefined;
|
|
256
|
+
};
|
|
257
|
+
|
|
219
258
|
// ModCallback.POST_CURSE_EVAL (12)
|
|
220
259
|
private readonly postCurseEval = (
|
|
221
260
|
curses: BitFlags<LevelCurse>,
|
|
@@ -246,6 +285,27 @@ export class CustomStages extends Feature {
|
|
|
246
285
|
return undefined;
|
|
247
286
|
};
|
|
248
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Fix the bug where Red Key will not work on custom floors (due to the stage being a bugged
|
|
290
|
+
* value).
|
|
291
|
+
*/
|
|
292
|
+
// ModCallback.PRE_USE_ITEM (23)
|
|
293
|
+
private readonly preUseItemRedKey = (): boolean | undefined => {
|
|
294
|
+
const customStage = v.run.currentCustomStage;
|
|
295
|
+
if (customStage === null) {
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
this.usingRedKey = true;
|
|
300
|
+
|
|
301
|
+
const level = game.GetLevel();
|
|
302
|
+
const stage = customStage.baseStage ?? DEFAULT_BASE_STAGE;
|
|
303
|
+
const stageType = customStage.baseStageType ?? DEFAULT_BASE_STAGE_TYPE;
|
|
304
|
+
level.SetStage(stage, stageType); // eslint-disable-line isaacscript/strict-enums
|
|
305
|
+
|
|
306
|
+
return undefined;
|
|
307
|
+
};
|
|
308
|
+
|
|
249
309
|
// ModCallbackCustom.POST_GRID_ENTITY_BROKEN
|
|
250
310
|
// GridEntityType.ROCK_ALT
|
|
251
311
|
private readonly postGridEntityBrokenRockAlt = (gridEntity: GridEntity) => {
|
package/src/functions/array.ts
CHANGED
|
@@ -232,6 +232,33 @@ export function emptyArray<T>(array: T[]): void {
|
|
|
232
232
|
array.splice(0, array.length);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Helper function to perform a map and a filter at the same time. Similar to `Array.map`, provide a
|
|
237
|
+
* function that transforms a value, but return `undefined` if the value should be skipped. (Thus,
|
|
238
|
+
* this function cannot be used in situations where `undefined` can be a valid array element.)
|
|
239
|
+
*
|
|
240
|
+
* This function is useful because a map will always produce an array with the same amount of
|
|
241
|
+
* elements as the original array.
|
|
242
|
+
*
|
|
243
|
+
* This is named `filterMap` after the Rust function:
|
|
244
|
+
* https://doc.rust-lang.org/std/iter/struct.FilterMap.html
|
|
245
|
+
*/
|
|
246
|
+
export function filterMap<OldT, NewT>(
|
|
247
|
+
array: OldT[],
|
|
248
|
+
func: (element: OldT) => NewT | undefined,
|
|
249
|
+
): NewT[] {
|
|
250
|
+
const newArray: NewT[] = [];
|
|
251
|
+
|
|
252
|
+
for (const element of array) {
|
|
253
|
+
const newElement = func(element);
|
|
254
|
+
if (newElement !== undefined) {
|
|
255
|
+
newArray.push(newElement);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return newArray;
|
|
260
|
+
}
|
|
261
|
+
|
|
235
262
|
/**
|
|
236
263
|
* Helper function to get all possible combinations of the given array. This includes the
|
|
237
264
|
* combination of an empty array.
|