isaacscript-common 7.5.0 → 7.5.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.
Files changed (45) hide show
  1. package/dist/classes/DefaultMap.d.ts +3 -2
  2. package/dist/classes/DefaultMap.d.ts.map +1 -1
  3. package/dist/classes/DefaultMap.lua +2 -1
  4. package/dist/features/customStage/customStageUtils.d.ts +2 -1
  5. package/dist/features/customStage/customStageUtils.d.ts.map +1 -1
  6. package/dist/features/customStage/customStageUtils.lua +40 -1
  7. package/dist/features/customStage/exports.d.ts +1 -25
  8. package/dist/features/customStage/exports.d.ts.map +1 -1
  9. package/dist/features/customStage/exports.lua +28 -29
  10. package/dist/features/customStage/v.d.ts +0 -2
  11. package/dist/features/customStage/v.d.ts.map +1 -1
  12. package/dist/features/customStage/v.lua +0 -2
  13. package/dist/features/customStage/versusScreen.d.ts.map +1 -1
  14. package/dist/features/customStage/versusScreen.lua +74 -60
  15. package/dist/functions/doors.d.ts +6 -5
  16. package/dist/functions/doors.d.ts.map +1 -1
  17. package/dist/functions/doors.lua +25 -12
  18. package/dist/functions/enums.d.ts +3 -3
  19. package/dist/functions/enums.lua +3 -3
  20. package/dist/functions/players.d.ts.map +1 -1
  21. package/dist/functions/players.lua +3 -2
  22. package/dist/index.d.ts +105 -102
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/interfaces/{CustomStageLua.d.ts → CustomStageTSConfig.d.ts} +86 -60
  25. package/dist/interfaces/CustomStageTSConfig.d.ts.map +1 -0
  26. package/dist/interfaces/{CustomStageLua.lua → CustomStageTSConfig.lua} +0 -0
  27. package/dist/interfaces/JSONRoomsFile.d.ts +6 -5
  28. package/dist/interfaces/JSONRoomsFile.d.ts.map +1 -1
  29. package/dist/interfaces/private/CustomStage.d.ts +1 -1
  30. package/dist/interfaces/private/CustomStage.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/src/classes/DefaultMap.ts +3 -2
  33. package/src/features/customStage/customStageUtils.ts +52 -1
  34. package/src/features/customStage/exports.ts +33 -45
  35. package/src/features/customStage/init.ts +1 -1
  36. package/src/features/customStage/v.ts +0 -6
  37. package/src/features/customStage/versusScreen.ts +70 -55
  38. package/src/functions/doors.ts +37 -21
  39. package/src/functions/enums.ts +3 -3
  40. package/src/functions/players.ts +7 -3
  41. package/src/index.ts +1 -1
  42. package/src/interfaces/{CustomStageLua.ts → CustomStageTSConfig.ts} +107 -41
  43. package/src/interfaces/JSONRoomsFile.ts +6 -5
  44. package/src/interfaces/private/CustomStage.ts +4 -1
  45. package/dist/interfaces/CustomStageLua.d.ts.map +0 -1
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * The `CustomStageLua` interface extends this, adding room metadata.
11
11
  */
12
- export declare type CustomStageTSConfig = Readonly<{
12
+ export interface CustomStageTSConfig {
13
13
  /** Mandatory. The name of the custom stage. */
14
14
  name: string;
15
15
  /**
@@ -34,8 +34,14 @@ export declare type CustomStageTSConfig = Readonly<{
34
34
  * number of the stage that will be warped to and used as a basis for the stage by the level
35
35
  * generation algorithm.
36
36
  *
37
- * (It is not possible to use Basement 1 as a base stage due to conflicts with the `Game.SetStage`
38
- * method.)
37
+ * For example, if you wanted to have a custom stage with a small amount of rooms per floor, then
38
+ * you should choose 2 as a base. (This would copy the number of rooms that would appear in
39
+ * Basement 2.) And if you wanted to have a custom stage with the maximum amount of rooms, then
40
+ * you should choose 13 as a base. (This would copy the number of rooms that would appear on The
41
+ * Void.)
42
+ *
43
+ * It is not possible to use Basement 1 as a base stage due to conflicts with the `Game.SetStage`
44
+ * method.
39
45
  *
40
46
  * If not specified, `LevelStage.BASEMENT_2` (2) will be used.
41
47
  *
@@ -59,7 +65,7 @@ export declare type CustomStageTSConfig = Readonly<{
59
65
  * the graphics for the walls and floor.) If not specified, the graphics for Basement will be
60
66
  * used.
61
67
  */
62
- backdropPNGPaths?: Readonly<{
68
+ backdropPNGPaths?: {
63
69
  /**
64
70
  * An array that contains the full paths to the graphic files that are used for the floor in
65
71
  * narrow rooms. (The "n" stands for "narrow").
@@ -69,7 +75,7 @@ export declare type CustomStageTSConfig = Readonly<{
69
75
  *
70
76
  * For an example of this, see the vanilla file "resources/gfx/backdrop/01_basement_nfloor.png".
71
77
  */
72
- nFloors: readonly string[];
78
+ nFloors: string[];
73
79
  /**
74
80
  * An array that contains the full paths to the graphic files that are used for the floor in L
75
81
  * rooms.
@@ -79,7 +85,7 @@ export declare type CustomStageTSConfig = Readonly<{
79
85
  *
80
86
  * For an example of this, see the vanilla file "resources/gfx/backdrop/01_lbasementfloor.png".
81
87
  */
82
- lFloors: readonly string[];
88
+ lFloors: string[];
83
89
  /**
84
90
  * An array that contains the full paths to the graphic files that are used for the walls of the
85
91
  * floor.
@@ -91,7 +97,7 @@ export declare type CustomStageTSConfig = Readonly<{
91
97
  * the vanilla file, they concatenate all four variations together into one PNG file. However,
92
98
  * for the custom stages feature, you must separate each wall variation into a separate file.)
93
99
  */
94
- walls: readonly string[];
100
+ walls: string[];
95
101
  /**
96
102
  * An array that contains the full paths to the graphic files for the stage's corners.
97
103
  *
@@ -105,8 +111,8 @@ export declare type CustomStageTSConfig = Readonly<{
105
111
  * you must separate each corner variation into a separate file (and put it in a different file
106
112
  * from the walls).
107
113
  */
108
- corners: readonly string[];
109
- }>;
114
+ corners: string[];
115
+ };
110
116
  /**
111
117
  * Optional. The full path to the spritesheet that contains the graphics of the decorations for
112
118
  * the floor.
@@ -140,7 +146,7 @@ export declare type CustomStageTSConfig = Readonly<{
140
146
  * Optional. A collection of paths that contain graphics for the doors of the floor. If not
141
147
  * specified, the doors for Basement will be used.
142
148
  */
143
- doorPNGPaths?: Readonly<{
149
+ doorPNGPaths?: {
144
150
  /**
145
151
  * Optional. The full path to the spritesheet that contains the graphics of the normal doors for
146
152
  * the floor.
@@ -237,14 +243,14 @@ export declare type CustomStageTSConfig = Readonly<{
237
243
  * located at: `resources/gfx/grid/door_02b_chestroomdoor.png`
238
244
  */
239
245
  chestRoom?: string;
240
- }>;
246
+ };
241
247
  /**
242
248
  * Optional. An array of shadow objects that describe the graphics for the custom shadows of the
243
249
  * floor. (In this context, "shadows" are the outlines from things on the roof. For example, in
244
250
  * Basement, a shadow of a sideways V is used, among others.) If not specified, no extra shadows
245
251
  * will be drawn.
246
252
  */
247
- shadows?: Readonly<{
253
+ shadows?: {
248
254
  /**
249
255
  * Optional. An array containing the shadows that will be used in rooms of shape
250
256
  * `RoomShape.SHAPE_1x1` (1), `RoomShape.IH` (2), and `RoomShape.IV` (3).
@@ -253,7 +259,7 @@ export declare type CustomStageTSConfig = Readonly<{
253
259
  *
254
260
  * If not specified, no extra shadows will be drawn in these room shapes.
255
261
  */
256
- "1x1"?: readonly CustomStageShadow[];
262
+ "1x1"?: CustomStageShadow[];
257
263
  /**
258
264
  * Optional. An array containing the shadows that will be used in rooms of shape
259
265
  * `RoomShape.SHAPE_1x2` (4) and `RoomShape.IIV` (5).
@@ -262,7 +268,7 @@ export declare type CustomStageTSConfig = Readonly<{
262
268
  *
263
269
  * If not specified, no extra shadows will be drawn in these room shapes.
264
270
  */
265
- "1x2"?: readonly CustomStageShadow[];
271
+ "1x2"?: CustomStageShadow[];
266
272
  /**
267
273
  * Optional. An array containing the shadows that will be used in rooms of shape
268
274
  * `RoomShape.SHAPE_2x1` (6) and `RoomShape.IIH` (7).
@@ -271,7 +277,7 @@ export declare type CustomStageTSConfig = Readonly<{
271
277
  *
272
278
  * If not specified, no extra shadows will be drawn in these room shapes.
273
279
  */
274
- "2x1"?: readonly CustomStageShadow[];
280
+ "2x1"?: CustomStageShadow[];
275
281
  /**
276
282
  * Optional. An array containing the shadows that will be used in rooms of shape
277
283
  * `RoomShape.SHAPE_2x2` (8), `RoomShape.LTL` (9), `RoomShape.LTR` (10), `RoomShape.LBL` (11),
@@ -281,12 +287,20 @@ export declare type CustomStageTSConfig = Readonly<{
281
287
  *
282
288
  * If not specified, no extra shadows will be drawn in these room shapes.
283
289
  */
284
- "2x2"?: readonly CustomStageShadow[];
285
- }>;
286
- /** Optional. An array containing the bosses that should be used for the stage. */
287
- bossPool?: readonly CustomStageBossPoolEntry[];
288
- /** Optional. A collection of colors used in the boss "versus" screen. */
289
- versusScreen?: Readonly<{
290
+ "2x2"?: CustomStageShadow[];
291
+ };
292
+ /**
293
+ * Optional. An array containing the bosses that should be used for the stage. This can include
294
+ * both vanilla bosses and modded bosses.
295
+ */
296
+ bossPool?: CustomStageBossPoolEntry[];
297
+ /**
298
+ * Optional. A collection of colors used for in the boss "versus" screen for all of the bosses.
299
+ *
300
+ * Note that these graphics will only be applied if one or more bosses are specified in the
301
+ * `bossPool` field.
302
+ */
303
+ versusScreen?: {
290
304
  /**
291
305
  * Optional. An object representing the color to use for the background of the boss "versus"
292
306
  * screen. If not specified, the color for Basement 1 will be used.
@@ -294,7 +308,7 @@ export declare type CustomStageTSConfig = Readonly<{
294
308
  * For a list of the colors that correspond to the vanilla stages, see
295
309
  * `versusScreenBackgroundColors.ts`.
296
310
  */
297
- backgroundColor?: Readonly<{
311
+ backgroundColor?: {
298
312
  /**
299
313
  * @minimum 0
300
314
  * @maximum 1
@@ -315,7 +329,7 @@ export declare type CustomStageTSConfig = Readonly<{
315
329
  * @maximum 1
316
330
  */
317
331
  a: number;
318
- }>;
332
+ };
319
333
  /**
320
334
  * Optional. An object representing the color to use for the dirt spots in the boss "versus"
321
335
  * screen. (There are two dirt spots; one for the player and one for the boss.) If not
@@ -324,7 +338,7 @@ export declare type CustomStageTSConfig = Readonly<{
324
338
  * For a list of the colors that correspond to the vanilla stages, see
325
339
  * `versusScreenDirtSpotColors.ts`.
326
340
  */
327
- dirtSpotColor?: Readonly<{
341
+ dirtSpotColor?: {
328
342
  /**
329
343
  * @minimum 0
330
344
  * @maximum 1
@@ -345,14 +359,14 @@ export declare type CustomStageTSConfig = Readonly<{
345
359
  * @maximum 1
346
360
  */
347
361
  a: number;
348
- }>;
349
- }>;
350
- }>;
362
+ };
363
+ };
364
+ }
351
365
  /**
352
366
  * A description of a custom stage shadow. (In this context, "shadows" are the outlines from things
353
367
  * on the roof. For example, in Basement, a shadow of a sideways V is used, among others.)
354
368
  */
355
- export declare type CustomStageShadow = Readonly<{
369
+ export interface CustomStageShadow {
356
370
  /**
357
371
  * The full path to the shadow overlay PNG file.
358
372
  *
@@ -366,7 +380,7 @@ export declare type CustomStageShadow = Readonly<{
366
380
  * If not specified, an object of `{ r: 0, g: 0, b: 0, a: 0.25 }` will be used (which corresponds
367
381
  * to 75% faded black).
368
382
  */
369
- color?: Readonly<{
383
+ color?: {
370
384
  /**
371
385
  * @minimum 0
372
386
  * @maximum 1
@@ -387,45 +401,57 @@ export declare type CustomStageShadow = Readonly<{
387
401
  * @maximum 1
388
402
  */
389
403
  a: number;
390
- }>;
391
- }>;
392
- /** An object that represents a possible boss for a custom stage. */
404
+ };
405
+ }
406
+ /**
407
+ * An object that represents a possible boss for a custom stage. This can be for a vanilla boss or a
408
+ * custom boss.
409
+ */
393
410
  export interface CustomStageBossPoolEntry {
394
411
  /**
395
- * The name of the boss. This must correspond to the entry in "entities2.xml".
396
- *
397
- * Note that since there is no way to determine the corresponding `EntityType` of the boss during
398
- * compile-time, you must specify the `EntityType` at run-time when your mod first loads using the
399
- * `registerCustomBoss` helper function.
412
+ * The name of the boss. This should correspond to the entry for the boss in the "entities2.xml"
413
+ * file.
400
414
  */
401
415
  name: string;
416
+ /**
417
+ * The arbitrary sub-type chosen for this boss, ranging between 1 and 999. You must set the boss
418
+ * rooms for this boss to this sub-type in Basement Renovator by right-clicking on the room on the
419
+ * right-hand-side.
420
+ *
421
+ * It does not matter if the arbitrary sub-type overlaps with any of the vanilla `BossID` values
422
+ * (e.g. vanilla Boss Room sub-types in "00.special_rooms.stb"). It also does not matter if this
423
+ * value overlaps with the values from other mods.
424
+ *
425
+ * If you are creating an entry for a vanilla boss, it is recommended that you match the sub-type
426
+ * with the corresponding vanilla `BossID` value. This will make things a bit easier to understand
427
+ * for people working on your mod, but is not a hard requirement.
428
+ *
429
+ * @minimum 1
430
+ * @maximum 999
431
+ */
432
+ subType: number;
402
433
  /**
403
434
  * The weight of the boss. This is used when randomly selecting which boss to use for the floor.
404
435
  * For example, use a value of 1 if you want this boss to be equally likely as any other boss, 0.5
405
436
  * if you want it to be half as likely, 2 if you want it to be twice as likely, and so on.
406
437
  */
407
438
  weight: number;
439
+ /** Optional. A collection of sprites used for the boss on the "versus" screen. */
440
+ versusScreen?: {
441
+ /**
442
+ * Mandatory. The full path to the spritesheet that contains the graphics of the name of the
443
+ * boss that will be displayed on the top of the boss "versus" screen.
444
+ *
445
+ * If not specified, a sprite showing "???" will be used.
446
+ */
447
+ namePNGPath: string;
448
+ /**
449
+ * Mandatory. The full path to the spritesheet that contains the portrait of the boss that will
450
+ * be displayed on the right side of the boss "versus" screen.
451
+ *
452
+ * If not specified, a sprite showing "???" will be used.
453
+ */
454
+ portraitPNGPath: string;
455
+ };
408
456
  }
409
- /**
410
- * An object that represents a custom stage. The "metadata.lua" file contains an array of these
411
- * objects. Besides the room metadata, the data is the same as what is specified inside the
412
- * "tsconfig.json" file.
413
- *
414
- * The `CustomStage` interface extends this, adding more data.
415
- */
416
- export interface CustomStageLua extends CustomStageTSConfig {
417
- readonly roomsMetadata: readonly CustomStageRoomMetadata[];
418
- }
419
- /**
420
- * Metadata about a custom stage room. Each custom stage object contains an array with metadata for
421
- * each room.
422
- */
423
- export declare type CustomStageRoomMetadata = Readonly<{
424
- type: number;
425
- variant: number;
426
- subType: number;
427
- shape: number;
428
- doorSlotFlags: number;
429
- weight: number;
430
- }>;
431
- //# sourceMappingURL=CustomStageLua.d.ts.map
457
+ //# sourceMappingURL=CustomStageTSConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomStageTSConfig.d.ts","sourceRoot":"","sources":["../../src/interfaces/CustomStageTSConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IAEb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;;WAGG;QACH,CAAC,EAAE,MAAM,CAAC;QAEV;;;WAGG;QACH,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;CACH;AAED;;;GAGG;AAEH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;;;;;;;;;OAeG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf,kFAAkF;IAClF,YAAY,CAAC,EAAE;QAEb;;;;;WAKG;QACH,WAAW,EAAE,MAAM,CAAC;QAGpB;;;;;WAKG;QACH,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The standard library has the feature to deploy a new room on-the-fly with the `deployJSONRoom`
3
3
  * helper function. It requires a `JSONRoomsFile` as an argument, which is simply an XML file
4
- * converted to JSON. (You create XML room files using the Basement Renovator program.)
4
+ * converted to JSON. (You can create XML room files using the Basement Renovator program.)
5
5
  *
6
6
  * You can convert your XML files using the following command:
7
7
  *
@@ -16,10 +16,11 @@
16
16
  export interface JSONRoomsFile {
17
17
  rooms: JSONRooms;
18
18
  }
19
+ /** Part of `JSONRoomsFile`. */
19
20
  export interface JSONRooms {
20
21
  room: JSONRoom[];
21
22
  }
22
- /** Part of `JSONRooms`. */
23
+ /** Part of `JSONRoomsFile`. */
23
24
  export interface JSONRoom {
24
25
  $: {
25
26
  /** Needs to be converted to an `int`. */
@@ -43,7 +44,7 @@ export interface JSONRoom {
43
44
  door: JSONDoor[];
44
45
  spawn: JSONSpawn[];
45
46
  }
46
- /** Part of `JSONRooms`. */
47
+ /** Part of `JSONRoomsFile`. */
47
48
  export interface JSONDoor {
48
49
  $: {
49
50
  /** Equal to "True" or "False". Needs to be converted to an `boolean`. */
@@ -54,7 +55,7 @@ export interface JSONDoor {
54
55
  y: string;
55
56
  };
56
57
  }
57
- /** Part of `JSONRooms`. */
58
+ /** Part of `JSONRoomsFile`. */
58
59
  export interface JSONSpawn {
59
60
  $: {
60
61
  /** Needs to be converted to an `int`. */
@@ -64,7 +65,7 @@ export interface JSONSpawn {
64
65
  };
65
66
  entity: JSONEntity[];
66
67
  }
67
- /** Part of `JSONRooms`. */
68
+ /** Part of `JSONRoomsFile`. */
68
69
  export interface JSONEntity {
69
70
  $: {
70
71
  /** Needs to be converted to an `int`. */
@@ -1 +1 @@
1
- {"version":3,"file":"JSONRoomsFile.d.ts","sourceRoot":"","sources":["../../src/interfaces/JSONRoomsFile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB;AAED,2BAA2B;AAC3B,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE;QACD,yCAAyC;QACzC,UAAU,EAAE,MAAM,CAAC;QAEnB,yCAAyC;QACzC,MAAM,EAAE,MAAM,CAAC;QAEf,IAAI,EAAE,MAAM,CAAC;QAEb,yCAAyC;QACzC,KAAK,EAAE,MAAM,CAAC;QAEd,yCAAyC;QACzC,OAAO,EAAE,MAAM,CAAC;QAEhB,yCAAyC;QACzC,IAAI,EAAE,MAAM,CAAC;QAEb,yCAAyC;QACzC,OAAO,EAAE,MAAM,CAAC;QAEhB,0CAA0C;QAC1C,MAAM,EAAE,MAAM,CAAC;QAEf,yCAAyC;QACzC,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IAEF,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,2BAA2B;AAC3B,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE;QACD,yEAAyE;QACzE,MAAM,EAAE,MAAM,CAAC;QAEf,yCAAyC;QACzC,CAAC,EAAE,MAAM,CAAC;QAEV,yCAAyC;QACzC,CAAC,EAAE,MAAM,CA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jB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,+BAA+B;AAC/B,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE;QACD,yEAAyE;QACzE,MAAM,EAAE,MAAM,CAAC;QAEf,yCAAyC;QACzC,CAAC,EAAE,MAAM,CAAC;QAEV,yCAAyC;QACzC,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;CACH;AAED,+BAA+B;AAC/B,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE;QACD,yCAAyC;QACzC,CAAC,EAAE,MAAM,CAAC;QAEV,yCAAyC;QACzC,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IAEF,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,+BAA+B;AAC/B,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE;QACD,yCAAyC;QACzC,IAAI,EAAE,MAAM,CAAC;QAEb,yCAAyC;QACzC,OAAO,EAAE,MAAM,CAAC;QAEhB,yCAAyC;QACzC,OAAO,EAAE,MAAM,CAAC;QAEhB,0CAA0C;QAC1C,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH"}
@@ -1,5 +1,5 @@
1
1
  import { DoorSlotFlag, RoomShape, RoomType } from "isaac-typescript-definitions";
2
- import { CustomStageLua, CustomStageRoomMetadata } from "../CustomStageLua";
2
+ import { CustomStageLua, CustomStageRoomMetadata } from "../CustomStageTSConfig";
3
3
  export interface CustomStage extends CustomStageLua {
4
4
  /** A map that makes it easier to select certain room type/shape/door combinations. */
5
5
  readonly roomTypeMap: RoomTypeMap;
@@ -1 +1 @@
1
- {"version":3,"file":"CustomStage.d.ts","sourceRoot":"","sources":["../../../src/interfaces/private/CustomStage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,QAAQ,EACT,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,sFAAsF;IACtF,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;AAED,oBAAY,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AAC9D,aAAK,YAAY,GAAG,WAAW,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC5D,aAAK,eAAe,GAAG,WAAW,CAAC,YAAY,EAAE,uBAAuB,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"CustomStage.d.ts","sourceRoot":"","sources":["../../../src/interfaces/private/CustomStage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,QAAQ,EACT,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,sFAAsF;IACtF,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;AAED,oBAAY,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AAC9D,aAAK,YAAY,GAAG,WAAW,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC5D,aAAK,eAAe,GAAG,WAAW,CAAC,YAAY,EAAE,uBAAuB,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "7.5.0",
3
+ "version": "7.5.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,7 +1,8 @@
1
1
  import { isFunction, isPrimitive } from "../functions/types";
2
2
 
3
3
  /**
4
- * `DefaultMap` is a data structure that makes working with default values easier.
4
+ * `DefaultMap` is a data structure that makes working with default values easier. It extends a
5
+ * `Map` and adds additional methods.
5
6
  *
6
7
  * It is a common pattern to look up a value in a `Map`, and then, if the value does not exist, set
7
8
  * a default value for the key, and then return the default value. `DefaultMap` abstracts this
@@ -89,7 +90,7 @@ export class DefaultMap<Key, Value, Args extends unknown[] = []> extends Map<
89
90
 
90
91
  /**
91
92
  * See the main `DefaultMap` documentation:
92
- * https://isaacscript.github.io/isaacscript-common/classes/classes_DefaultMap.DefaultMap
93
+ * https://isaacscript.github.io/isaacscript-common/other/classes/DefaultMap
93
94
  */
94
95
  constructor(
95
96
  defaultValueOrFactoryFunction: Value | FactoryFunction<Value, Args>,
@@ -2,7 +2,10 @@ import { sumArray } from "../../functions/array";
2
2
  import { log } from "../../functions/log";
3
3
  import { getRandomFloat } from "../../functions/random";
4
4
  import { getRandomSeed } from "../../functions/rng";
5
- import { CustomStageRoomMetadata } from "../../interfaces/CustomStageLua";
5
+ import {
6
+ CustomStageBossPoolEntry,
7
+ CustomStageRoomMetadata,
8
+ } from "../../interfaces/CustomStageTSConfig";
6
9
 
7
10
  /**
8
11
  * Helper function to get a random custom stage room from an array of custom stage rooms.
@@ -52,3 +55,51 @@ function getCustomStageRoomWithChosenWeight(
52
55
  `Failed to get a custom stage room with chosen weight: ${chosenWeight}`,
53
56
  );
54
57
  }
58
+
59
+ export function getRandomBossRoomFromPool(
60
+ roomsMetadata: readonly CustomStageRoomMetadata[],
61
+ bossPool: readonly CustomStageBossPoolEntry[],
62
+ seedOrRNG: Seed | RNG = getRandomSeed(),
63
+ verbose = false,
64
+ ): CustomStageRoomMetadata {
65
+ const totalWeight = getTotalWeightOfBossPool(bossPool);
66
+ if (verbose) {
67
+ log(`Total weight of the custom stage boss pool provided: ${totalWeight}`);
68
+ }
69
+
70
+ const chosenWeight = getRandomFloat(0, totalWeight, seedOrRNG);
71
+ if (verbose) {
72
+ log(`Randomly chose weight for custom stage boss pool: ${chosenWeight}`);
73
+ }
74
+
75
+ const bossEntry = getBossEntryWithChosenWeight(bossPool, chosenWeight);
76
+
77
+ const roomsMetadataForBoss = roomsMetadata.filter(
78
+ (roomMetadata) => roomMetadata.subType === bossEntry.subType,
79
+ );
80
+ return getRandomCustomStageRoom(roomsMetadataForBoss, seedOrRNG, verbose);
81
+ }
82
+
83
+ function getTotalWeightOfBossPool(
84
+ bossPool: readonly CustomStageBossPoolEntry[],
85
+ ): float {
86
+ const weights = bossPool.map((bossEntry) => bossEntry.weight);
87
+ return sumArray(weights);
88
+ }
89
+
90
+ function getBossEntryWithChosenWeight(
91
+ bossPool: readonly CustomStageBossPoolEntry[],
92
+ chosenWeight: float,
93
+ ): CustomStageBossPoolEntry {
94
+ for (const bossEntry of bossPool) {
95
+ if (chosenWeight < bossEntry.weight) {
96
+ return bossEntry;
97
+ }
98
+
99
+ chosenWeight -= bossEntry.weight;
100
+ }
101
+
102
+ error(
103
+ `Failed to get a custom stage boss entry with chosen weight: ${chosenWeight}`,
104
+ );
105
+ }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import {
11
- EntityType,
11
+ DoorSlot,
12
12
  LevelStage,
13
13
  RoomShape,
14
14
  RoomType,
@@ -16,7 +16,7 @@ import {
16
16
  } from "isaac-typescript-definitions";
17
17
  import { reorderedCallbacksSetStageInternal } from "../../callbacks/reorderedCallbacks";
18
18
  import { game } from "../../core/cachedClasses";
19
- import { getEntityIDFromConstituents } from "../../functions/entities";
19
+ import { doorSlotFlagsToDoorSlots } from "../../functions/doors";
20
20
  import { logError } from "../../functions/log";
21
21
  import { newRNG } from "../../functions/rng";
22
22
  import {
@@ -25,13 +25,13 @@ import {
25
25
  } from "../../functions/rooms";
26
26
  import { setStage } from "../../functions/stage";
27
27
  import { asNumber } from "../../functions/types";
28
+ import { CustomStageRoomMetadata } from "../../interfaces/CustomStageTSConfig";
28
29
  import { CustomStage } from "../../interfaces/private/CustomStage";
29
- import { getRandomCustomStageRoom } from "./customStageUtils";
30
- import v, {
31
- customBossPNGPaths,
32
- customStageCachedRoomData,
33
- customStagesMap,
34
- } from "./v";
30
+ import {
31
+ getRandomBossRoomFromPool,
32
+ getRandomCustomStageRoom,
33
+ } from "./customStageUtils";
34
+ import v, { customStageCachedRoomData, customStagesMap } from "./v";
35
35
 
36
36
  export const DEFAULT_BASE_STAGE = LevelStage.BASEMENT_2;
37
37
  export const DEFAULT_BASE_STAGE_TYPE = StageType.ORIGINAL;
@@ -135,8 +135,8 @@ function setStageRoomsData(
135
135
  const roomType = room.Data.Type;
136
136
  const roomShapeMap = customStage.roomTypeMap.get(roomType);
137
137
  if (roomShapeMap === undefined) {
138
- // Only show errors for non-default room types. (By default, we won't replace shops and other
139
- // special rooms.)
138
+ // Only show errors for non-default room types. (We do not require that end-users provide
139
+ // custom rooms for shops and other special rooms inside of their XML file.)
140
140
  if (roomType === RoomType.DEFAULT) {
141
141
  logError(
142
142
  `Failed to find any custom rooms for RoomType.${RoomType[roomType]} (${roomType}) for custom stage: ${customStage.name}`,
@@ -160,10 +160,32 @@ function setStageRoomsData(
160
160
  logError(
161
161
  `Failed to find any custom rooms for RoomType.${RoomType[roomType]} (${roomType}) + RoomShape.${RoomShape[roomShape]} (${roomShape}) + DoorSlotFlags ${doorSlotFlags} for custom stage: ${customStage.name}`,
162
162
  );
163
+
164
+ const header = `For reference, a DoorSlotFlags of ${doorSlotFlags} is equal to the following doors being enabled:\n`;
165
+ const doorSlots = doorSlotFlagsToDoorSlots(doorSlotFlags);
166
+ const doorSlotLines = doorSlots.map(
167
+ (doorSlot) => `- DoorSlot.${DoorSlot[doorSlot]} (${doorSlot})`,
168
+ );
169
+ const explanation = header + doorSlotLines.join("\n");
170
+ logError(explanation);
163
171
  continue;
164
172
  }
165
173
 
166
- const randomRoom = getRandomCustomStageRoom(roomsMetadata, rng, verbose);
174
+ let randomRoom: CustomStageRoomMetadata;
175
+ if (roomType === RoomType.BOSS) {
176
+ if (customStage.bossPool === undefined) {
177
+ continue;
178
+ }
179
+
180
+ randomRoom = getRandomBossRoomFromPool(
181
+ roomsMetadata,
182
+ customStage.bossPool,
183
+ rng,
184
+ verbose,
185
+ );
186
+ } else {
187
+ randomRoom = getRandomCustomStageRoom(roomsMetadata, rng, verbose);
188
+ }
167
189
 
168
190
  let newRoomData = customStageCachedRoomData.get(randomRoom.variant);
169
191
  if (newRoomData === undefined) {
@@ -187,40 +209,6 @@ function setStageRoomsData(
187
209
  }
188
210
  }
189
211
 
190
- /**
191
- * By default, unknown bosses will be drawn on the boss "versus" screen as "???". If your custom
192
- * stage has custom bosses, you can use this function to register the corresponding graphic file
193
- * files for them.
194
- *
195
- * For reference:
196
- * - The vanilla name sprite for Monstro is located at:
197
- * `resources/gfx/ui/boss/bossname_20.0_monstro.png`
198
- * - The vanilla portrait sprite for Monstro is located at:
199
- * `resources/gfx/ui/boss/portrait_20.0_monstro.png`
200
- *
201
- * (Note that boss metadata like this cannot be specified with the rest of the custom stage metadata
202
- * in the "tsconfig.json" file because there is not a way to retrieve the name of an entity at
203
- * run-time.)
204
- *
205
- * @param entityType The entity type of the custom boss.
206
- * @param variant The variant of the custom boss.
207
- * @param subType The sub-type of the custom boss.
208
- * @param namePNGPath The full path to the PNG file that contains the name of the boss that will be
209
- * displayed on the top of the boss "versus" screen.
210
- * @param portraitPNGPath The full path to the PNG file that contains the portrait of the boss that
211
- * will be displayed on the right side of the boss "versus" screen.
212
- */
213
- export function registerCustomBoss(
214
- entityType: EntityType,
215
- variant: int,
216
- subType: int,
217
- namePNGPath: string,
218
- portraitPNGPath: string,
219
- ): void {
220
- const entityID = getEntityIDFromConstituents(entityType, variant, subType);
221
- customBossPNGPaths.set(entityID, [namePNGPath, portraitPNGPath]);
222
- }
223
-
224
212
  /**
225
213
  * Helper function to disable the custom stage. This is typically called before taking the player to
226
214
  * a vanilla floor.
@@ -13,7 +13,7 @@ import { hasFlag, removeFlag } from "../../functions/flag";
13
13
  import {
14
14
  CustomStageLua,
15
15
  CustomStageRoomMetadata,
16
- } from "../../interfaces/CustomStageLua";
16
+ } from "../../interfaces/CustomStageTSConfig";
17
17
  import { CustomStage, RoomTypeMap } from "../../interfaces/private/CustomStage";
18
18
  import { saveDataManager } from "../saveDataManager/exports";
19
19
  import { setCustomStageBackdrop } from "./backdrop";
@@ -40,9 +40,3 @@ export const customStagesMap = new Map<string, CustomStage>();
40
40
 
41
41
  /** Indexed by room variant. */
42
42
  export const customStageCachedRoomData = new Map<int, Readonly<RoomConfig>>();
43
-
44
- /** Indexed by entity ID. */
45
- export const customBossPNGPaths = new Map<
46
- string,
47
- [namePNGPath: string, portraitPNGPath: string]
48
- >();