isaacscript-common 7.5.0 → 7.6.1
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/classes/DefaultMap.d.ts +3 -2
- package/dist/classes/DefaultMap.d.ts.map +1 -1
- package/dist/classes/DefaultMap.lua +2 -1
- package/dist/features/customGridEntity.d.ts +6 -3
- package/dist/features/customGridEntity.d.ts.map +1 -1
- package/dist/features/customGridEntity.lua +20 -11
- package/dist/features/customStage/customStageConstants.d.ts +1 -0
- package/dist/features/customStage/customStageConstants.d.ts.map +1 -1
- package/dist/features/customStage/customStageConstants.lua +1 -0
- package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -1
- package/dist/features/customStage/customStageGridEntities.lua +9 -5
- package/dist/features/customStage/customStageUtils.d.ts +2 -1
- package/dist/features/customStage/customStageUtils.d.ts.map +1 -1
- package/dist/features/customStage/customStageUtils.lua +40 -1
- package/dist/features/customStage/exports.d.ts +1 -25
- package/dist/features/customStage/exports.d.ts.map +1 -1
- package/dist/features/customStage/exports.lua +28 -29
- package/dist/features/customStage/init.d.ts.map +1 -1
- package/dist/features/customStage/init.lua +3 -1
- package/dist/features/customStage/v.d.ts +0 -2
- package/dist/features/customStage/v.d.ts.map +1 -1
- package/dist/features/customStage/v.lua +0 -2
- package/dist/features/customStage/versusScreen.d.ts.map +1 -1
- package/dist/features/customStage/versusScreen.lua +80 -60
- package/dist/features/customTrapdoor/exports.d.ts +28 -16
- package/dist/features/customTrapdoor/exports.d.ts.map +1 -1
- package/dist/features/customTrapdoor/exports.lua +45 -61
- package/dist/features/customTrapdoor/init.d.ts.map +1 -1
- package/dist/features/customTrapdoor/init.lua +12 -10
- package/dist/features/customTrapdoor/spawn.d.ts +6 -0
- package/dist/features/customTrapdoor/spawn.d.ts.map +1 -0
- package/dist/features/customTrapdoor/spawn.lua +51 -0
- package/dist/features/customTrapdoor/v.d.ts +2 -2
- package/dist/features/customTrapdoor/v.d.ts.map +1 -1
- package/dist/functions/doors.d.ts +6 -5
- package/dist/functions/doors.d.ts.map +1 -1
- package/dist/functions/doors.lua +25 -12
- package/dist/functions/enums.d.ts +3 -3
- package/dist/functions/enums.lua +3 -3
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/players.lua +3 -2
- package/dist/index.d.ts +172 -11145
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +4 -4
- package/dist/interfaces/{CustomStageLua.d.ts → CustomStageTSConfig.d.ts} +87 -61
- package/dist/interfaces/CustomStageTSConfig.d.ts.map +1 -0
- package/dist/interfaces/{CustomStageLua.lua → CustomStageTSConfig.lua} +0 -0
- package/dist/interfaces/GridEntityCustomData.d.ts +2 -2
- package/dist/interfaces/GridEntityCustomData.d.ts.map +1 -1
- package/dist/interfaces/JSONRoomsFile.d.ts +6 -5
- package/dist/interfaces/JSONRoomsFile.d.ts.map +1 -1
- package/dist/interfaces/private/CustomStage.d.ts +1 -1
- package/dist/interfaces/private/CustomStage.d.ts.map +1 -1
- package/dist/interfaces/private/CustomTrapdoorDescription.d.ts +2 -2
- package/dist/interfaces/private/CustomTrapdoorDescription.d.ts.map +1 -1
- package/dist/interfaces/private/CustomTrapdoorDestination.d.ts +14 -0
- package/dist/interfaces/private/CustomTrapdoorDestination.d.ts.map +1 -0
- package/dist/{types/TrapdoorDestination.lua → interfaces/private/CustomTrapdoorDestination.lua} +0 -0
- package/package.json +1 -1
- package/src/classes/DefaultMap.ts +3 -2
- package/src/features/customGridEntity.ts +30 -20
- package/src/features/customStage/customStageConstants.ts +2 -0
- package/src/features/customStage/customStageGridEntities.ts +20 -16
- package/src/features/customStage/customStageUtils.ts +52 -1
- package/src/features/customStage/exports.ts +33 -45
- package/src/features/customStage/init.ts +3 -2
- package/src/features/customStage/v.ts +0 -6
- package/src/features/customStage/versusScreen.ts +78 -57
- package/src/features/customTrapdoor/exports.ts +60 -66
- package/src/features/customTrapdoor/init.ts +12 -11
- package/src/features/customTrapdoor/spawn.ts +53 -0
- package/src/features/customTrapdoor/v.ts +2 -2
- package/src/functions/doors.ts +37 -21
- package/src/functions/enums.ts +3 -3
- package/src/functions/players.ts +7 -3
- package/src/index.ts +3 -4
- package/src/interfaces/{CustomStageLua.ts → CustomStageTSConfig.ts} +108 -42
- package/src/interfaces/GridEntityCustomData.ts +2 -2
- package/src/interfaces/JSONRoomsFile.ts +6 -5
- package/src/interfaces/private/CustomStage.ts +4 -1
- package/src/interfaces/private/CustomTrapdoorDescription.ts +2 -2
- package/src/interfaces/private/CustomTrapdoorDestination.ts +14 -0
- package/dist/interfaces/CustomStageLua.d.ts.map +0 -1
- package/dist/types/TrapdoorDestination.d.ts +0 -6
- package/dist/types/TrapdoorDestination.d.ts.map +0 -1
- package/src/types/TrapdoorDestination.ts +0 -8
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `DefaultMap` is a data structure that makes working with default values easier.
|
|
2
|
+
* `DefaultMap` is a data structure that makes working with default values easier. It extends a
|
|
3
|
+
* `Map` and adds additional methods.
|
|
3
4
|
*
|
|
4
5
|
* It is a common pattern to look up a value in a `Map`, and then, if the value does not exist, set
|
|
5
6
|
* a default value for the key, and then return the default value. `DefaultMap` abstracts this
|
|
@@ -83,7 +84,7 @@ export declare class DefaultMap<Key, Value, Args extends unknown[] = []> extends
|
|
|
83
84
|
private defaultValueFactory;
|
|
84
85
|
/**
|
|
85
86
|
* See the main `DefaultMap` documentation:
|
|
86
|
-
* https://isaacscript.github.io/isaacscript-common/classes/
|
|
87
|
+
* https://isaacscript.github.io/isaacscript-common/other/classes/DefaultMap
|
|
87
88
|
*/
|
|
88
89
|
constructor(defaultValueOrFactoryFunction: Value | FactoryFunction<Value, Args>, initializerArray?: Iterable<[Key, Value]>);
|
|
89
90
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultMap.d.ts","sourceRoot":"","sources":["../../src/classes/DefaultMap.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"DefaultMap.d.ts","sourceRoot":"","sources":["../../src/classes/DefaultMap.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,qBAAa,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,SAAS,OAAO,EAAE,GAAG,EAAE,CAAE,SAAQ,GAAG,CAC1E,GAAG,EACH,KAAK,CACN;IACC,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,mBAAmB,CAA2C;IAEtE;;;OAGG;gBAED,6BAA6B,EAAE,KAAK,GAAG,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,EACnE,gBAAgB,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAqB3C;;;OAGG;IACH,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK;IAWhD;;;OAGG;IACH,eAAe,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK;IAYrC;;;OAGG;IACH,iBAAiB,IAAI,KAAK,GAAG,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC;CAW1D;AAGD;;;GAGG;AACH,oBAAY,eAAe,CAAC,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC"}
|
|
@@ -8,7 +8,8 @@ local ____exports = {}
|
|
|
8
8
|
local ____types = require("functions.types")
|
|
9
9
|
local isFunction = ____types.isFunction
|
|
10
10
|
local isPrimitive = ____types.isPrimitive
|
|
11
|
-
--- `DefaultMap` is a data structure that makes working with default values easier.
|
|
11
|
+
--- `DefaultMap` is a data structure that makes working with default values easier. It extends a
|
|
12
|
+
-- `Map` and adds additional methods.
|
|
12
13
|
--
|
|
13
14
|
-- It is a common pattern to look up a value in a `Map`, and then, if the value does not exist, set
|
|
14
15
|
-- a default value for the key, and then return the default value. `DefaultMap` abstracts this
|
|
@@ -28,8 +28,11 @@ export declare function customGridEntityInit(mod: ModUpgraded): void;
|
|
|
28
28
|
* @param gridIndexOrPosition The grid index or position in the room that you want to spawn the grid
|
|
29
29
|
* entity at. If a position is specified, the closest grid index will be
|
|
30
30
|
* used.
|
|
31
|
-
* @param gridCollisionClass The collision class that you want the custom grid entity to
|
|
32
|
-
*
|
|
31
|
+
* @param gridCollisionClass Optional. The collision class that you want the custom grid entity to
|
|
32
|
+
* have. If not specified, the grid collision class from the base grid
|
|
33
|
+
* entity will be used.
|
|
34
|
+
* @param anm2Path Optional. The path to the ANM2 file to use for the sprite. If not specified, the
|
|
35
|
+
* normal sprite from the base grid entity will be used.
|
|
33
36
|
* @param defaultAnimation Optional. The name of the animation to play after the sprite is
|
|
34
37
|
* initialized and after the player re-enters a room with this grid entity
|
|
35
38
|
* in it. If not specified, the default animation in the anm2 will be used.
|
|
@@ -38,7 +41,7 @@ export declare function customGridEntityInit(mod: ModUpgraded): void;
|
|
|
38
41
|
* @param baseGridEntityVariant Optional. The variant of the grid entity to use as a "base" for this
|
|
39
42
|
* custom grid entity. Default is 0.
|
|
40
43
|
*/
|
|
41
|
-
export declare function spawnCustomGridEntity(gridEntityTypeCustom: GridEntityType, gridIndexOrPosition: int | Vector, gridCollisionClass
|
|
44
|
+
export declare function spawnCustomGridEntity(gridEntityTypeCustom: GridEntityType, gridIndexOrPosition: int | Vector, gridCollisionClass?: GridCollisionClass, anm2Path?: string, defaultAnimation?: string, baseGridEntityType?: GridEntityType, baseGridEntityVariant?: number): GridEntity;
|
|
42
45
|
/**
|
|
43
46
|
* Helper function to remove a custom grid entity created by the `spawnCustomGrid` function.
|
|
44
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customGridEntity.d.ts","sourceRoot":"","sources":["../../src/features/customGridEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,kBAAkB,EAClB,cAAc,EAGf,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAerD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAoB1E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAmB3D;
|
|
1
|
+
{"version":3,"file":"customGridEntity.d.ts","sourceRoot":"","sources":["../../src/features/customGridEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,kBAAkB,EAClB,cAAc,EAGf,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAerD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAoB1E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAmB3D;AAoID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,qBAAqB,CACnC,oBAAoB,EAAE,cAAc,EACpC,mBAAmB,EAAE,GAAG,GAAG,MAAM,EACjC,kBAAkB,CAAC,EAAE,kBAAkB,EACvC,QAAQ,CAAC,EAAE,MAAM,EACjB,gBAAgB,CAAC,EAAE,MAAM,EACzB,kBAAkB,iBAA4B,EAC9C,qBAAqB,SAAI,GACxB,UAAU,CA8CZ;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,+BAA+B,EAAE,GAAG,GAAG,MAAM,GAAG,UAAU,EAC1D,UAAU,UAAO,GAChB,UAAU,GAAG,SAAS,CAuCxB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,KAAK,CAC5C;IAAC,UAAU,EAAE,UAAU;IAAE,IAAI,EAAE,oBAAoB;CAAC,CACrD,CAqBA;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,qBAAqB,EAAE,UAAU,GAAG,GAAG,GACtC,cAAc,GAAG,SAAS,CAsB5B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,qBAAqB,EAAE,UAAU,GAAG,GAAG,GACtC,OAAO,CAOT"}
|
|
@@ -115,10 +115,12 @@ function postNewRoomReordered(self)
|
|
|
115
115
|
roomCustomGridEntities:delete(gridIndex)
|
|
116
116
|
goto __continue19
|
|
117
117
|
end
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
if data.anm2Path ~= nil then
|
|
119
|
+
local sprite = decoration:GetSprite()
|
|
120
|
+
sprite:Load(data.anm2Path, true)
|
|
121
|
+
local animationToPlay = data.defaultAnimation == nil and sprite:GetDefaultAnimation() or data.defaultAnimation
|
|
122
|
+
sprite:Play(animationToPlay, true)
|
|
123
|
+
end
|
|
122
124
|
end
|
|
123
125
|
::__continue19::
|
|
124
126
|
end
|
|
@@ -165,8 +167,11 @@ end
|
|
|
165
167
|
-- @param gridIndexOrPosition The grid index or position in the room that you want to spawn the grid
|
|
166
168
|
-- entity at. If a position is specified, the closest grid index will be
|
|
167
169
|
-- used.
|
|
168
|
-
-- @param gridCollisionClass The collision class that you want the custom grid entity to
|
|
169
|
-
--
|
|
170
|
+
-- @param gridCollisionClass Optional. The collision class that you want the custom grid entity to
|
|
171
|
+
-- have. If not specified, the grid collision class from the base grid
|
|
172
|
+
-- entity will be used.
|
|
173
|
+
-- @param anm2Path Optional. The path to the ANM2 file to use for the sprite. If not specified, the
|
|
174
|
+
-- normal sprite from the base grid entity will be used.
|
|
170
175
|
-- @param defaultAnimation Optional. The name of the animation to play after the sprite is
|
|
171
176
|
-- initialized and after the player re-enters a room with this grid entity
|
|
172
177
|
-- in it. If not specified, the default animation in the anm2 will be used.
|
|
@@ -189,11 +194,15 @@ function ____exports.spawnCustomGridEntity(self, gridEntityTypeCustom, gridIndex
|
|
|
189
194
|
if customGridEntity == nil then
|
|
190
195
|
error("Failed to spawn a custom grid entity.")
|
|
191
196
|
end
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
if gridCollisionClass ~= nil then
|
|
198
|
+
customGridEntity.CollisionClass = gridCollisionClass
|
|
199
|
+
end
|
|
200
|
+
if anm2Path ~= nil then
|
|
201
|
+
local sprite = customGridEntity:GetSprite()
|
|
202
|
+
sprite:Load(anm2Path, true)
|
|
203
|
+
local animationToPlay = defaultAnimation == nil and sprite:GetDefaultAnimation() or defaultAnimation
|
|
204
|
+
sprite:Play(animationToPlay, true)
|
|
205
|
+
end
|
|
197
206
|
local customGridEntityData = {
|
|
198
207
|
gridEntityTypeCustom = gridEntityTypeCustom,
|
|
199
208
|
roomListIndex = roomListIndex,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
export declare const CUSTOM_STAGE_FEATURE_NAME = "customStage";
|
|
2
3
|
export declare const ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH = "gfx/isaacscript-custom-stage";
|
|
3
4
|
/** Corresponds to "ui_streak.anm2". */
|
|
4
5
|
export declare enum UIStreakAnimation {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customStageConstants.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/customStageConstants.ts"],"names":[],"mappings":";AAAA,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAEhF,uCAAuC;AACvC,oBAAY,iBAAiB;IAC3B,IAAI,IAAA;IACJ,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED,uCAAuC;AACvC,eAAO,MAAM,8BAA8B,EAAE;IAC3C,QAAQ,EAAE,GAAG,IAAI,iBAAiB,GAAG,GAAG;CAKhC,CAAC"}
|
|
1
|
+
{"version":3,"file":"customStageConstants.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/customStageConstants.ts"],"names":[],"mappings":";AAAA,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AAEvD,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAEhF,uCAAuC;AACvC,oBAAY,iBAAiB;IAC3B,IAAI,IAAA;IACJ,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED,uCAAuC;AACvC,eAAO,MAAM,8BAA8B,EAAE;IAC3C,QAAQ,EAAE,GAAG,IAAI,iBAAiB,GAAG,GAAG;CAKhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customStageGridEntities.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/customStageGridEntities.ts"],"names":[],"mappings":";AAiBA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"customStageGridEntities.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/customStageGridEntities.ts"],"names":[],"mappings":";AAiBA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AASnE,0CAA0C;AAC1C,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACrB,IAAI,CAuBN;AAED,oCAAoC;AACpC,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACrB,IAAI,CAyBN;AAED,mCAAmC;AACnC,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACrB,IAAI,CAsBN;AAED,mCAAmC;AACnC,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACrB,IAAI,CAuBN;AAuDD,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACrB,IAAI,CAwBN;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACrB,IAAI,CAsBN"}
|
|
@@ -25,6 +25,7 @@ local ____customGridEntity = require("features.customGridEntity")
|
|
|
25
25
|
local isCustomGridEntity = ____customGridEntity.isCustomGridEntity
|
|
26
26
|
local ____exports = require("features.customTrapdoor.exports")
|
|
27
27
|
local spawnCustomTrapdoor = ____exports.spawnCustomTrapdoor
|
|
28
|
+
local spawnCustomTrapdoorToVanilla = ____exports.spawnCustomTrapdoorToVanilla
|
|
28
29
|
local ____exports = require("features.customStage.exports")
|
|
29
30
|
local DEFAULT_BASE_STAGE = ____exports.DEFAULT_BASE_STAGE
|
|
30
31
|
local ____v = require("features.customStage.v")
|
|
@@ -238,11 +239,14 @@ function ____exports.convertVanillaTrapdoors(self, customStage, gridEntity)
|
|
|
238
239
|
return
|
|
239
240
|
end
|
|
240
241
|
removeGridEntity(nil, gridEntity, true)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
if v.run.firstFloor then
|
|
243
|
+
spawnCustomTrapdoor(nil, gridEntity.Position, customStage.name, 2)
|
|
244
|
+
else
|
|
245
|
+
local baseStage = customStage.baseStage == nil and DEFAULT_BASE_STAGE or customStage.baseStage
|
|
246
|
+
local stage = baseStage + 2
|
|
247
|
+
local stageType = calculateStageType(nil, stage)
|
|
248
|
+
spawnCustomTrapdoorToVanilla(nil, gridEntity.Position, stage, stageType)
|
|
249
|
+
end
|
|
246
250
|
end
|
|
247
251
|
--- The rewards are based on the ones from the wiki:
|
|
248
252
|
-- https://bindingofisaacrebirth.fandom.com/wiki/Rocks#Urns
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
-
import { CustomStageRoomMetadata } from "../../interfaces/
|
|
3
|
+
import { CustomStageBossPoolEntry, CustomStageRoomMetadata } from "../../interfaces/CustomStageTSConfig";
|
|
4
4
|
/**
|
|
5
5
|
* Helper function to get a random custom stage room from an array of custom stage rooms.
|
|
6
6
|
*
|
|
@@ -9,4 +9,5 @@ import { CustomStageRoomMetadata } from "../../interfaces/CustomStageLua";
|
|
|
9
9
|
* https://stackoverflow.com/questions/1761626/weighted-random-numbers
|
|
10
10
|
*/
|
|
11
11
|
export declare function getRandomCustomStageRoom(roomsMetadata: readonly CustomStageRoomMetadata[], seedOrRNG?: Seed | RNG, verbose?: boolean): CustomStageRoomMetadata;
|
|
12
|
+
export declare function getRandomBossRoomFromPool(roomsMetadata: readonly CustomStageRoomMetadata[], bossPool: readonly CustomStageBossPoolEntry[], seedOrRNG?: Seed | RNG, verbose?: boolean): CustomStageRoomMetadata;
|
|
12
13
|
//# sourceMappingURL=customStageUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customStageUtils.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/customStageUtils.ts"],"names":[],"mappings":";;AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"customStageUtils.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/customStageUtils.ts"],"names":[],"mappings":";;AAIA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,sCAAsC,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,SAAS,uBAAuB,EAAE,EACjD,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,uBAAuB,CAYzB;AA0BD,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,SAAS,uBAAuB,EAAE,EACjD,QAAQ,EAAE,SAAS,wBAAwB,EAAE,EAC7C,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,uBAAuB,CAiBzB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
3
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
3
4
|
local ____exports = {}
|
|
4
|
-
local getTotalWeightOfCustomStageRooms, getCustomStageRoomWithChosenWeight
|
|
5
|
+
local getTotalWeightOfCustomStageRooms, getCustomStageRoomWithChosenWeight, getTotalWeightOfBossPool, getBossEntryWithChosenWeight
|
|
5
6
|
local ____array = require("functions.array")
|
|
6
7
|
local sumArray = ____array.sumArray
|
|
7
8
|
local ____log = require("functions.log")
|
|
@@ -26,6 +27,22 @@ function getCustomStageRoomWithChosenWeight(self, roomsMetadata, chosenWeight)
|
|
|
26
27
|
end
|
|
27
28
|
error("Failed to get a custom stage room with chosen weight: " .. tostring(chosenWeight))
|
|
28
29
|
end
|
|
30
|
+
function getTotalWeightOfBossPool(self, bossPool)
|
|
31
|
+
local weights = __TS__ArrayMap(
|
|
32
|
+
bossPool,
|
|
33
|
+
function(____, bossEntry) return bossEntry.weight end
|
|
34
|
+
)
|
|
35
|
+
return sumArray(nil, weights)
|
|
36
|
+
end
|
|
37
|
+
function getBossEntryWithChosenWeight(self, bossPool, chosenWeight)
|
|
38
|
+
for ____, bossEntry in ipairs(bossPool) do
|
|
39
|
+
if chosenWeight < bossEntry.weight then
|
|
40
|
+
return bossEntry
|
|
41
|
+
end
|
|
42
|
+
chosenWeight = chosenWeight - bossEntry.weight
|
|
43
|
+
end
|
|
44
|
+
error("Failed to get a custom stage boss entry with chosen weight: " .. tostring(chosenWeight))
|
|
45
|
+
end
|
|
29
46
|
--- Helper function to get a random custom stage room from an array of custom stage rooms.
|
|
30
47
|
--
|
|
31
48
|
-- Note that this function does not simply choose a random element in the provided array; it will
|
|
@@ -48,4 +65,26 @@ function ____exports.getRandomCustomStageRoom(self, roomsMetadata, seedOrRNG, ve
|
|
|
48
65
|
end
|
|
49
66
|
return getCustomStageRoomWithChosenWeight(nil, roomsMetadata, chosenWeight)
|
|
50
67
|
end
|
|
68
|
+
function ____exports.getRandomBossRoomFromPool(self, roomsMetadata, bossPool, seedOrRNG, verbose)
|
|
69
|
+
if seedOrRNG == nil then
|
|
70
|
+
seedOrRNG = getRandomSeed(nil)
|
|
71
|
+
end
|
|
72
|
+
if verbose == nil then
|
|
73
|
+
verbose = false
|
|
74
|
+
end
|
|
75
|
+
local totalWeight = getTotalWeightOfBossPool(nil, bossPool)
|
|
76
|
+
if verbose then
|
|
77
|
+
log("Total weight of the custom stage boss pool provided: " .. tostring(totalWeight))
|
|
78
|
+
end
|
|
79
|
+
local chosenWeight = getRandomFloat(nil, 0, totalWeight, seedOrRNG)
|
|
80
|
+
if verbose then
|
|
81
|
+
log("Randomly chose weight for custom stage boss pool: " .. tostring(chosenWeight))
|
|
82
|
+
end
|
|
83
|
+
local bossEntry = getBossEntryWithChosenWeight(nil, bossPool, chosenWeight)
|
|
84
|
+
local roomsMetadataForBoss = __TS__ArrayFilter(
|
|
85
|
+
roomsMetadata,
|
|
86
|
+
function(____, roomMetadata) return roomMetadata.subType == bossEntry.subType end
|
|
87
|
+
)
|
|
88
|
+
return ____exports.getRandomCustomStageRoom(nil, roomsMetadataForBoss, seedOrRNG, verbose)
|
|
89
|
+
end
|
|
51
90
|
return ____exports
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { LevelStage, StageType } from "isaac-typescript-definitions";
|
|
9
9
|
export declare const DEFAULT_BASE_STAGE = LevelStage.BASEMENT_2;
|
|
10
10
|
export declare const DEFAULT_BASE_STAGE_TYPE = StageType.ORIGINAL;
|
|
11
11
|
export declare const INVALID_STAGE_VALUE: LevelStage;
|
|
@@ -23,30 +23,6 @@ export declare const INVALID_STAGE_VALUE: LevelStage;
|
|
|
23
23
|
* Default is false.
|
|
24
24
|
*/
|
|
25
25
|
export declare function setCustomStage(name: string, firstFloor?: boolean, verbose?: boolean): void;
|
|
26
|
-
/**
|
|
27
|
-
* By default, unknown bosses will be drawn on the boss "versus" screen as "???". If your custom
|
|
28
|
-
* stage has custom bosses, you can use this function to register the corresponding graphic file
|
|
29
|
-
* files for them.
|
|
30
|
-
*
|
|
31
|
-
* For reference:
|
|
32
|
-
* - The vanilla name sprite for Monstro is located at:
|
|
33
|
-
* `resources/gfx/ui/boss/bossname_20.0_monstro.png`
|
|
34
|
-
* - The vanilla portrait sprite for Monstro is located at:
|
|
35
|
-
* `resources/gfx/ui/boss/portrait_20.0_monstro.png`
|
|
36
|
-
*
|
|
37
|
-
* (Note that boss metadata like this cannot be specified with the rest of the custom stage metadata
|
|
38
|
-
* in the "tsconfig.json" file because there is not a way to retrieve the name of an entity at
|
|
39
|
-
* run-time.)
|
|
40
|
-
*
|
|
41
|
-
* @param entityType The entity type of the custom boss.
|
|
42
|
-
* @param variant The variant of the custom boss.
|
|
43
|
-
* @param subType The sub-type of the custom boss.
|
|
44
|
-
* @param namePNGPath The full path to the PNG file that contains the name of the boss that will be
|
|
45
|
-
* displayed on the top of the boss "versus" screen.
|
|
46
|
-
* @param portraitPNGPath The full path to the PNG file that contains the portrait of the boss that
|
|
47
|
-
* will be displayed on the right side of the boss "versus" screen.
|
|
48
|
-
*/
|
|
49
|
-
export declare function registerCustomBoss(entityType: EntityType, variant: int, subType: int, namePNGPath: string, portraitPNGPath: string): void;
|
|
50
26
|
/**
|
|
51
27
|
* Helper function to disable the custom stage. This is typically called before taking the player to
|
|
52
28
|
* a vanilla floor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/exports.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/exports.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EAEL,UAAU,EAGV,SAAS,EACV,MAAM,8BAA8B,CAAC;AAoBtC,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D,eAAO,MAAM,mBAAmB,YAAmB,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,UAAU,UAAO,EACjB,OAAO,UAAQ,GACd,IAAI,CAwDN;AAkGD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Map = ____lualib.Map
|
|
3
|
+
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
3
4
|
local ____exports = {}
|
|
4
5
|
local setStageRoomsData
|
|
5
6
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
7
|
+
local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
|
|
6
8
|
local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
|
|
7
9
|
local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
|
|
8
10
|
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
|
|
@@ -11,8 +13,8 @@ local ____reorderedCallbacks = require("callbacks.reorderedCallbacks")
|
|
|
11
13
|
local reorderedCallbacksSetStageInternal = ____reorderedCallbacks.reorderedCallbacksSetStageInternal
|
|
12
14
|
local ____cachedClasses = require("core.cachedClasses")
|
|
13
15
|
local game = ____cachedClasses.game
|
|
14
|
-
local
|
|
15
|
-
local
|
|
16
|
+
local ____doors = require("functions.doors")
|
|
17
|
+
local doorSlotFlagsToDoorSlots = ____doors.doorSlotFlagsToDoorSlots
|
|
16
18
|
local ____log = require("functions.log")
|
|
17
19
|
local logError = ____log.logError
|
|
18
20
|
local ____rng = require("functions.rng")
|
|
@@ -25,10 +27,10 @@ local setStage = ____stage.setStage
|
|
|
25
27
|
local ____types = require("functions.types")
|
|
26
28
|
local asNumber = ____types.asNumber
|
|
27
29
|
local ____customStageUtils = require("features.customStage.customStageUtils")
|
|
30
|
+
local getRandomBossRoomFromPool = ____customStageUtils.getRandomBossRoomFromPool
|
|
28
31
|
local getRandomCustomStageRoom = ____customStageUtils.getRandomCustomStageRoom
|
|
29
32
|
local ____v = require("features.customStage.v")
|
|
30
33
|
local v = ____v.default
|
|
31
|
-
local customBossPNGPaths = ____v.customBossPNGPaths
|
|
32
34
|
local customStageCachedRoomData = ____v.customStageCachedRoomData
|
|
33
35
|
local customStagesMap = ____v.customStagesMap
|
|
34
36
|
function setStageRoomsData(self, customStage, rng, verbose)
|
|
@@ -60,9 +62,31 @@ function setStageRoomsData(self, customStage, rng, verbose)
|
|
|
60
62
|
local roomsMetadata = roomDoorSlotFlagMap:get(doorSlotFlags)
|
|
61
63
|
if roomsMetadata == nil then
|
|
62
64
|
logError((((((((((("Failed to find any custom rooms for RoomType." .. tostring(RoomType[roomType])) .. " (") .. tostring(roomType)) .. ") + RoomShape.") .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ") + DoorSlotFlags ") .. tostring(doorSlotFlags)) .. " for custom stage: ") .. customStage.name)
|
|
65
|
+
local header = ("For reference, a DoorSlotFlags of " .. tostring(doorSlotFlags)) .. " is equal to the following doors being enabled:\n"
|
|
66
|
+
local doorSlots = doorSlotFlagsToDoorSlots(nil, doorSlotFlags)
|
|
67
|
+
local doorSlotLines = __TS__ArrayMap(
|
|
68
|
+
doorSlots,
|
|
69
|
+
function(____, doorSlot) return ((("- DoorSlot." .. tostring(DoorSlot[doorSlot])) .. " (") .. tostring(doorSlot)) .. ")" end
|
|
70
|
+
)
|
|
71
|
+
local explanation = header .. table.concat(doorSlotLines, "\n")
|
|
72
|
+
logError(explanation)
|
|
63
73
|
goto __continue7
|
|
64
74
|
end
|
|
65
|
-
local randomRoom
|
|
75
|
+
local randomRoom
|
|
76
|
+
if roomType == RoomType.BOSS then
|
|
77
|
+
if customStage.bossPool == nil then
|
|
78
|
+
goto __continue7
|
|
79
|
+
end
|
|
80
|
+
randomRoom = getRandomBossRoomFromPool(
|
|
81
|
+
nil,
|
|
82
|
+
roomsMetadata,
|
|
83
|
+
customStage.bossPool,
|
|
84
|
+
rng,
|
|
85
|
+
verbose
|
|
86
|
+
)
|
|
87
|
+
else
|
|
88
|
+
randomRoom = getRandomCustomStageRoom(nil, roomsMetadata, rng, verbose)
|
|
89
|
+
end
|
|
66
90
|
local newRoomData = customStageCachedRoomData:get(randomRoom.variant)
|
|
67
91
|
if newRoomData == nil then
|
|
68
92
|
newRoomData = getRoomDataForTypeVariant(nil, roomType, randomRoom.variant, false)
|
|
@@ -125,31 +149,6 @@ function ____exports.setCustomStage(self, name, firstFloor, verbose)
|
|
|
125
149
|
level:SetStage(targetStage, targetStageType)
|
|
126
150
|
reorderedCallbacksSetStageInternal(nil, targetStage, targetStageType)
|
|
127
151
|
end
|
|
128
|
-
--- By default, unknown bosses will be drawn on the boss "versus" screen as "???". If your custom
|
|
129
|
-
-- stage has custom bosses, you can use this function to register the corresponding graphic file
|
|
130
|
-
-- files for them.
|
|
131
|
-
--
|
|
132
|
-
-- For reference:
|
|
133
|
-
-- - The vanilla name sprite for Monstro is located at:
|
|
134
|
-
-- `resources/gfx/ui/boss/bossname_20.0_monstro.png`
|
|
135
|
-
-- - The vanilla portrait sprite for Monstro is located at:
|
|
136
|
-
-- `resources/gfx/ui/boss/portrait_20.0_monstro.png`
|
|
137
|
-
--
|
|
138
|
-
-- (Note that boss metadata like this cannot be specified with the rest of the custom stage metadata
|
|
139
|
-
-- in the "tsconfig.json" file because there is not a way to retrieve the name of an entity at
|
|
140
|
-
-- run-time.)
|
|
141
|
-
--
|
|
142
|
-
-- @param entityType The entity type of the custom boss.
|
|
143
|
-
-- @param variant The variant of the custom boss.
|
|
144
|
-
-- @param subType The sub-type of the custom boss.
|
|
145
|
-
-- @param namePNGPath The full path to the PNG file that contains the name of the boss that will be
|
|
146
|
-
-- displayed on the top of the boss "versus" screen.
|
|
147
|
-
-- @param portraitPNGPath The full path to the PNG file that contains the portrait of the boss that
|
|
148
|
-
-- will be displayed on the right side of the boss "versus" screen.
|
|
149
|
-
function ____exports.registerCustomBoss(self, entityType, variant, subType, namePNGPath, portraitPNGPath)
|
|
150
|
-
local entityID = getEntityIDFromConstituents(nil, entityType, variant, subType)
|
|
151
|
-
customBossPNGPaths:set(entityID, {namePNGPath, portraitPNGPath})
|
|
152
|
-
end
|
|
153
152
|
--- Helper function to disable the custom stage. This is typically called before taking the player to
|
|
154
153
|
-- a vanilla floor.
|
|
155
154
|
function ____exports.disableCustomStage(self)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/init.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/init.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AA8BxD,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CA0BtD"}
|
|
@@ -19,6 +19,8 @@ local ____exports = require("features.saveDataManager.exports")
|
|
|
19
19
|
local saveDataManager = ____exports.saveDataManager
|
|
20
20
|
local ____backdrop = require("features.customStage.backdrop")
|
|
21
21
|
local setCustomStageBackdrop = ____backdrop.setCustomStageBackdrop
|
|
22
|
+
local ____customStageConstants = require("features.customStage.customStageConstants")
|
|
23
|
+
local CUSTOM_STAGE_FEATURE_NAME = ____customStageConstants.CUSTOM_STAGE_FEATURE_NAME
|
|
22
24
|
local ____customStageGridEntities = require("features.customStage.customStageGridEntities")
|
|
23
25
|
local convertVanillaTrapdoors = ____customStageGridEntities.convertVanillaTrapdoors
|
|
24
26
|
local removeUrnRewards = ____customStageGridEntities.removeUrnRewards
|
|
@@ -133,7 +135,7 @@ function ____exports.customStageInit(self, mod)
|
|
|
133
135
|
if customStagesMap.size == 0 then
|
|
134
136
|
return
|
|
135
137
|
end
|
|
136
|
-
saveDataManager(nil,
|
|
138
|
+
saveDataManager(nil, CUSTOM_STAGE_FEATURE_NAME, v)
|
|
137
139
|
versusScreenInit(nil)
|
|
138
140
|
mod:AddCallback(ModCallback.POST_RENDER, postRender)
|
|
139
141
|
mod:AddCallback(ModCallback.POST_CURSE_EVAL, postCurseEval)
|
|
@@ -30,6 +30,4 @@ export default v;
|
|
|
30
30
|
export declare const customStagesMap: Map<string, CustomStage>;
|
|
31
31
|
/** Indexed by room variant. */
|
|
32
32
|
export declare const customStageCachedRoomData: Map<number, Readonly<RoomConfig>>;
|
|
33
|
-
/** Indexed by entity ID. */
|
|
34
|
-
export declare const customBossPNGPaths: Map<string, [namePNGPath: string, portraitPNGPath: string]>;
|
|
35
33
|
//# sourceMappingURL=v.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/v.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,QAAA,MAAM,CAAC;;;QAIH,iDAAiD;;;QAKjD,oFAAoF;;;;;;;;;;;;;;;;;CAqBvF,CAAC;AACF,eAAe,CAAC,CAAC;AAEjB,oCAAoC;AACpC,eAAO,MAAM,eAAe,0BAAiC,CAAC;AAE9D,+BAA+B;AAC/B,eAAO,MAAM,yBAAyB,mCAAuC,CAAC
|
|
1
|
+
{"version":3,"file":"v.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/v.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,QAAA,MAAM,CAAC;;;QAIH,iDAAiD;;;QAKjD,oFAAoF;;;;;;;;;;;;;;;;;CAqBvF,CAAC;AACF,eAAe,CAAC,CAAC;AAEjB,oCAAoC;AACpC,eAAO,MAAM,eAAe,0BAAiC,CAAC;AAE9D,+BAA+B;AAC/B,eAAO,MAAM,yBAAyB,mCAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versusScreen.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/versusScreen.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"versusScreen.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/versusScreen.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AA+EnE;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAavC;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CA4ExE;AAmGD,wBAAgB,sBAAsB,IAAI,IAAI,CAkC7C"}
|