isaacscript-common 6.0.1 → 6.2.0

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 (60) hide show
  1. package/callbacks/postCollectibleEmpty.d.ts +1 -0
  2. package/callbacks/postCollectibleEmpty.lua +40 -0
  3. package/callbacks/subscriptions/postCollectibleEmpty.d.ts +5 -0
  4. package/callbacks/subscriptions/postCollectibleEmpty.lua +29 -0
  5. package/classes/DefaultMap.lua +2 -2
  6. package/enums/ModCallbackCustom.d.ts +92 -77
  7. package/enums/ModCallbackCustom.lua +79 -77
  8. package/features/customStage/exports.d.ts +3 -9
  9. package/features/customStage/exports.lua +86 -15
  10. package/features/customStage/init.d.ts +1 -0
  11. package/features/customStage/init.lua +48 -0
  12. package/features/customStage/metadata.lua +1 -0
  13. package/features/customStage/util.d.ts +11 -0
  14. package/features/customStage/util.lua +51 -0
  15. package/features/customStage/v.d.ts +6 -2
  16. package/features/customStage/v.lua +4 -1
  17. package/features/deployJSONRoom.d.ts +1 -1
  18. package/functions/boss.d.ts +2 -2
  19. package/functions/doors.d.ts +4 -0
  20. package/functions/doors.lua +14 -0
  21. package/functions/entity.d.ts +2 -2
  22. package/functions/entitySpecific.d.ts +20 -20
  23. package/functions/familiars.d.ts +2 -0
  24. package/functions/familiars.lua +16 -0
  25. package/functions/jsonRoom.d.ts +26 -4
  26. package/functions/jsonRoom.lua +64 -2
  27. package/functions/pickups.d.ts +16 -16
  28. package/functions/playerCenter.d.ts +6 -0
  29. package/functions/playerCenter.lua +57 -0
  30. package/functions/rooms.d.ts +1 -1
  31. package/functions/rooms.lua +2 -2
  32. package/functions/stage.d.ts +3 -3
  33. package/functions/stage.lua +5 -4
  34. package/functions/trinkets.lua +1 -1
  35. package/index.d.ts +1 -5
  36. package/initCustomCallbacks.lua +3 -0
  37. package/initFeatures.lua +3 -0
  38. package/interfaces/AddCallbackParameterCustom.d.ts +2 -0
  39. package/interfaces/CustomStage.d.ts +10 -0
  40. package/interfaces/{CustomStageData.lua → CustomStage.lua} +0 -0
  41. package/interfaces/CustomStageLua.d.ts +118 -0
  42. package/interfaces/{JSONDoor.lua → CustomStageLua.lua} +0 -0
  43. package/interfaces/JSONRoomsFile.d.ts +75 -0
  44. package/interfaces/{JSONEntity.lua → JSONRoomsFile.lua} +0 -0
  45. package/objects/callbackRegisterFunctions.lua +3 -0
  46. package/objects/roomTypeGotoPrefixes.lua +29 -29
  47. package/package.json +1 -1
  48. package/features/customStage/constants.d.ts +0 -18
  49. package/features/customStage/constants.lua +0 -29
  50. package/features/customStage/scripts/generateCustomStageRooms.d.ts +0 -27
  51. package/features/customStage/scripts/generateCustomStageRooms.lua +0 -126
  52. package/interfaces/CustomStageData.d.ts +0 -5
  53. package/interfaces/JSONDoor.d.ts +0 -11
  54. package/interfaces/JSONEntity.d.ts +0 -13
  55. package/interfaces/JSONRoom.d.ts +0 -26
  56. package/interfaces/JSONRoom.lua +0 -2
  57. package/interfaces/JSONRooms.d.ts +0 -11
  58. package/interfaces/JSONRooms.lua +0 -2
  59. package/interfaces/JSONSpawn.d.ts +0 -11
  60. package/interfaces/JSONSpawn.lua +0 -2
@@ -0,0 +1,118 @@
1
+ /**
2
+ * This is the format of a custom stage in the "isaacscript" section of the "tsconfig.json" file.
3
+ *
4
+ * The contents of this interface are used to create a "tsconfig-isaacscript-section-schema.json"
5
+ * schema with the "ts-json-schema-generator" library.
6
+ *
7
+ * The contents of this interface are validated at run-time against the schema using the Ajv
8
+ * library.
9
+ *
10
+ * The `CustomStageLua` interface extends this, adding room metadata.
11
+ */
12
+ export interface CustomStageTSConfig {
13
+ /** The name of the custom stage. Mandatory. */
14
+ readonly name: string;
15
+ /**
16
+ * Path to the XML file that contains the rooms for the custom stage (created with Basement
17
+ * Renovator). Mandatory.
18
+ */
19
+ readonly xmlPath: string;
20
+ /** An arbitrarily chosen prefix in the range of 101-999. Mandatory. */
21
+ readonly roomVariantPrefix: number;
22
+ /**
23
+ * An integer between 2 and 13, corresponding to the `LevelStage` enum. This is the number of the
24
+ * stage that will be warped to and used as a basis for the stage by the level generation
25
+ * algorithm. Mandatory.
26
+ *
27
+ * (It is not possible to use Basement 1 as a base due to conflicts with the `Game.SetStage`
28
+ * method.)
29
+ */
30
+ readonly baseStage: number;
31
+ /**
32
+ * An integer between 0 and 5, corresponding to the `StageType` enum. This is the number of the
33
+ * stage type that will be warped to and used as a basis for the stage by the level generation
34
+ * algorithm. Mandatory.
35
+ */
36
+ readonly baseStageType: number;
37
+ /**
38
+ * An object containing the paths to the backdrop for the stage. (A backdrop is the graphics for
39
+ * the walls and floor.) Mandatory.
40
+ */
41
+ readonly backdrop: CustomStageBackdrop;
42
+ }
43
+ interface CustomStageBackdrop {
44
+ /**
45
+ * The beginning of the path that leads to the backdrop graphics. For example:
46
+ *
47
+ * ```sh
48
+ * gfx/backdrop/revelations/revelations_
49
+ * ```
50
+ */
51
+ prefix: string;
52
+ /**
53
+ * The end of the path that leads to the backdrop graphics. In most cases, this will be ".png".
54
+ */
55
+ suffix: string;
56
+ /**
57
+ * An array of strings that represent the graphic files for the stage's "nFloor". You must have at
58
+ * least one string in this array, but you can specify more than one to randomly add extra variety
59
+ * (like the vanilla stages do).
60
+ *
61
+ * For an example of this, see the vanilla file "resources/gfx/backdrop/01_basement_nfloor.png".
62
+ */
63
+ nFloors: string[];
64
+ /**
65
+ * An array of strings that represent the graphic files for the stage's "lFloor". You must have at
66
+ * least one in the array, but you can specify more than one to randomly add extra variety (like
67
+ * the vanilla stages do).
68
+ *
69
+ * For an example of this, see the vanilla file "resources/gfx/backdrop/01_lbasementfloor.png".
70
+ */
71
+ lFloors: string[];
72
+ /**
73
+ * An array of strings that represent the graphic files for the stage's walls. You must have at
74
+ * least one string in this array, but you can specify more than one to randomly add extra variety
75
+ * (like the vanilla stages do).
76
+ *
77
+ * For an example of this, see the vanilla file "resources/gfx/backdrop/01_basement.png". (In the
78
+ * vanilla file, they concatenate all four variations together into one PNG file. However, for the
79
+ * custom stages feature, you must separate each wall variation into a separate file.)
80
+ */
81
+ walls: string[];
82
+ /**
83
+ * An array of strings that represent the graphic files for the stage's corners. You must have at
84
+ * least one string in this array, but you can specify more than one to randomly add extra variety
85
+ * (like the vanilla stages do).
86
+ *
87
+ * For an example of this, see the vanilla file "resources/gfx/backdrop/01_basement.png". (In the
88
+ * vanilla file, they concatenate both variations together into one PNG file and put it in the top
89
+ * right hand corner. The corners are shown in the top right hand corner of the file, with two
90
+ * different variations concatenated together. However, for the custom stages feature, you must
91
+ * separate each corner variation into a separate file (and put it in a different file from the
92
+ * walls).
93
+ */
94
+ corners: string[];
95
+ }
96
+ /**
97
+ * An object that represents a custom stage. The "metadata.lua" file contains an array of these
98
+ * objects. Besides the room metadata, the data is the same as what is specified inside the
99
+ * "tsconfig.json" file.
100
+ *
101
+ * The `CustomStage` interface extends this, adding more data.
102
+ */
103
+ export interface CustomStageLua extends CustomStageTSConfig {
104
+ readonly roomsMetadata: readonly CustomStageRoomMetadata[];
105
+ }
106
+ /**
107
+ * Metadata about a custom stage room. Each custom stage object contains an array with metadata for
108
+ * each room.
109
+ */
110
+ export interface CustomStageRoomMetadata {
111
+ readonly type: number;
112
+ readonly variant: number;
113
+ readonly subType: number;
114
+ readonly shape: number;
115
+ readonly doorSlotFlags: number;
116
+ readonly weight: number;
117
+ }
118
+ export {};
File without changes
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Custom rooms are created with the Basement Renovator program, which outputs XML files and STB
3
+ * files. A `JSONRoomsFile` object is simply an XML file converted to JSON. (It is useful to have
4
+ * the room data in JSON format so that it can be directly consumed by TypeScript programs.)
5
+ *
6
+ * You can convert your XML files using the following command:
7
+ *
8
+ * ```sh
9
+ * npx convert-xml-to-json foo.xml foo.json
10
+ * ```
11
+ */
12
+ export interface JSONRoomsFile {
13
+ rooms: JSONRooms;
14
+ }
15
+ export interface JSONRooms {
16
+ room: JSONRoom[];
17
+ }
18
+ /** Part of `JSONRooms`. */
19
+ export interface JSONRoom {
20
+ $: {
21
+ /** Needs to be converted to an `int`. */
22
+ difficulty: string;
23
+ /** Needs to be converted to an `int`. */
24
+ height: string;
25
+ name: string;
26
+ /** Needs to be converted to an `int`. */
27
+ shape: string;
28
+ /** Needs to be converted to an `int`. */
29
+ subtype: string;
30
+ /** Needs to be converted to an `int`. */
31
+ type: string;
32
+ /** Needs to be converted to an `int`. */
33
+ variant: string;
34
+ /** Needs to be converted to a `float`. */
35
+ weight: string;
36
+ /** Needs to be converted to an `int`. */
37
+ width: string;
38
+ };
39
+ door: JSONDoor[];
40
+ spawn: JSONSpawn[];
41
+ }
42
+ /** Part of `JSONRooms`. */
43
+ export interface JSONDoor {
44
+ $: {
45
+ /** Equal to "True" or "False". Needs to be converted to an `boolean`. */
46
+ exists: string;
47
+ /** Needs to be converted to an `int`. */
48
+ x: string;
49
+ /** Needs to be converted to an `int`. */
50
+ y: string;
51
+ };
52
+ }
53
+ /** Part of `JSONRooms`. */
54
+ export interface JSONSpawn {
55
+ $: {
56
+ /** Needs to be converted to an `int`. */
57
+ x: string;
58
+ /** Needs to be converted to an `int`. */
59
+ y: string;
60
+ };
61
+ entity: JSONEntity[];
62
+ }
63
+ /** Part of `JSONRooms`. */
64
+ export interface JSONEntity {
65
+ $: {
66
+ /** Needs to be converted to an `int`. */
67
+ type: string;
68
+ /** Needs to be converted to an `int`. */
69
+ variant: string;
70
+ /** Needs to be converted to an `int`. */
71
+ subtype: string;
72
+ /** Needs to be converted to a `float`. */
73
+ weight: string;
74
+ };
75
+ }
File without changes
@@ -9,6 +9,8 @@ local ____postBoneExploded = require("callbacks.subscriptions.postBoneExploded")
9
9
  local postBombExplodedRegister = ____postBoneExploded.postBombExplodedRegister
10
10
  local ____postBoneSwing = require("callbacks.subscriptions.postBoneSwing")
11
11
  local postBoneSwingRegister = ____postBoneSwing.postBoneSwingRegister
12
+ local ____postCollectibleEmpty = require("callbacks.subscriptions.postCollectibleEmpty")
13
+ local postCollectibleEmptyRegister = ____postCollectibleEmpty.postCollectibleEmptyRegister
12
14
  local ____postCollectibleInitFirst = require("callbacks.subscriptions.postCollectibleInitFirst")
13
15
  local postCollectibleInitFirstRegister = ____postCollectibleInitFirst.postCollectibleInitFirstRegister
14
16
  local ____postCursedTeleport = require("callbacks.subscriptions.postCursedTeleport")
@@ -171,6 +173,7 @@ ____exports.CALLBACK_REGISTER_FUNCTIONS = {
171
173
  [ModCallbackCustom.POST_BOMB_EXPLODED] = postBombExplodedRegister,
172
174
  [ModCallbackCustom.POST_BOMB_INIT_LATE] = postBombInitLateRegister,
173
175
  [ModCallbackCustom.POST_BONE_SWING] = postBoneSwingRegister,
176
+ [ModCallbackCustom.POST_COLLECTIBLE_EMPTY] = postCollectibleEmptyRegister,
174
177
  [ModCallbackCustom.POST_COLLECTIBLE_INIT_FIRST] = postCollectibleInitFirstRegister,
175
178
  [ModCallbackCustom.POST_CURSED_TELEPORT] = postCursedTeleportRegister,
176
179
  [ModCallbackCustom.POST_CUSTOM_DOOR_ENTER] = postCustomDoorEnterRegister,
@@ -2,34 +2,34 @@ local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
4
4
  ____exports.ROOM_TYPE_GOTO_PREFIXES = {
5
- [RoomType.DEFAULT] = "d.",
6
- [RoomType.SHOP] = "s.shop.",
7
- [RoomType.ERROR] = "s.error.",
8
- [RoomType.TREASURE] = "s.treasure.",
9
- [RoomType.BOSS] = "s.boss.",
10
- [RoomType.MINI_BOSS] = "s.miniboss.",
11
- [RoomType.SECRET] = "s.secret.",
12
- [RoomType.SUPER_SECRET] = "s.supersecret.",
13
- [RoomType.ARCADE] = "s.arcade.",
14
- [RoomType.CURSE] = "s.curse.",
15
- [RoomType.CHALLENGE] = "s.challenge.",
16
- [RoomType.LIBRARY] = "s.library.",
17
- [RoomType.SACRIFICE] = "s.sacrifice.",
18
- [RoomType.DEVIL] = "s.devil.",
19
- [RoomType.ANGEL] = "s.angel.",
20
- [RoomType.DUNGEON] = "s.itemdungeon.",
21
- [RoomType.BOSS_RUSH] = "s.bossrush.",
22
- [RoomType.CLEAN_BEDROOM] = "s.isaacs.",
23
- [RoomType.DIRTY_BEDROOM] = "s.barren.",
24
- [RoomType.CHEST] = "s.chest.",
25
- [RoomType.DICE] = "s.dice.",
26
- [RoomType.BLACK_MARKET] = "s.blackmarket.",
27
- [RoomType.GREED_EXIT] = "s.greedexit.",
28
- [RoomType.PLANETARIUM] = "s.planetarium.",
29
- [RoomType.TELEPORTER] = "s.teleporter.",
30
- [RoomType.TELEPORTER_EXIT] = "s.teleporterexit.",
31
- [RoomType.SECRET_EXIT] = "s.secretexit.",
32
- [RoomType.BLUE] = "s.blue.",
33
- [RoomType.ULTRA_SECRET] = "s.ultrasecret."
5
+ [RoomType.DEFAULT] = "s.default",
6
+ [RoomType.SHOP] = "s.shop",
7
+ [RoomType.ERROR] = "s.error",
8
+ [RoomType.TREASURE] = "s.treasure",
9
+ [RoomType.BOSS] = "s.boss",
10
+ [RoomType.MINI_BOSS] = "s.miniboss",
11
+ [RoomType.SECRET] = "s.secret",
12
+ [RoomType.SUPER_SECRET] = "s.supersecret",
13
+ [RoomType.ARCADE] = "s.arcade",
14
+ [RoomType.CURSE] = "s.curse",
15
+ [RoomType.CHALLENGE] = "s.challenge",
16
+ [RoomType.LIBRARY] = "s.library",
17
+ [RoomType.SACRIFICE] = "s.sacrifice",
18
+ [RoomType.DEVIL] = "s.devil",
19
+ [RoomType.ANGEL] = "s.angel",
20
+ [RoomType.DUNGEON] = "s.itemdungeon",
21
+ [RoomType.BOSS_RUSH] = "s.bossrush",
22
+ [RoomType.CLEAN_BEDROOM] = "s.isaacs",
23
+ [RoomType.DIRTY_BEDROOM] = "s.barren",
24
+ [RoomType.CHEST] = "s.chest",
25
+ [RoomType.DICE] = "s.dice",
26
+ [RoomType.BLACK_MARKET] = "s.blackmarket",
27
+ [RoomType.GREED_EXIT] = "s.greedexit",
28
+ [RoomType.PLANETARIUM] = "s.planetarium",
29
+ [RoomType.TELEPORTER] = "s.teleporter",
30
+ [RoomType.TELEPORTER_EXIT] = "s.teleporterexit",
31
+ [RoomType.SECRET_EXIT] = "s.secretexit",
32
+ [RoomType.BLUE] = "s.blue",
33
+ [RoomType.ULTRA_SECRET] = "s.ultrasecret"
34
34
  }
35
35
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "6.0.1",
3
+ "version": "6.2.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,18 +0,0 @@
1
- import { RoomType } from "isaac-typescript-definitions";
2
- /**
3
- * In order to keep the size of the STB file small, we only allow certain room types to be used in
4
- * IsaacScript custom stages.
5
- */
6
- export declare const CUSTOM_STAGE_ILLEGAL_ROOM_TYPES: Set<RoomType>;
7
- /** StageAPI uses 70000 as a base. */
8
- export declare const CUSTOM_STAGE_BASE_ROOM_VARIANT = 80000;
9
- /**
10
- * - The `RoomShape` enum goes from 1 to 12.
11
- * - 12 in binary is 1100.
12
- * - Thus, we need 4 bits to represent `RoomShape`.
13
- */
14
- export declare const CUSTOM_STAGE_NUM_ROOM_SHAPE_BITS = 4;
15
- /**
16
- * One for each possible door slot. We add one to account for `DoorSlot.LEFT_0` being equal to zero.
17
- */
18
- export declare const CUSTOM_STAGE_NUM_DOOR_SLOT_BITS: number;
@@ -1,29 +0,0 @@
1
- local ____lualib = require("lualib_bundle")
2
- local Set = ____lualib.Set
3
- local __TS__New = ____lualib.__TS__New
4
- local ____exports = {}
5
- local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
- local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
7
- local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
8
- local ____enums = require("functions.enums")
9
- local getLastEnumValue = ____enums.getLastEnumValue
10
- --- In order to keep the size of the STB file small, we only allow certain room types to be used in
11
- -- IsaacScript custom stages.
12
- ____exports.CUSTOM_STAGE_ILLEGAL_ROOM_TYPES = __TS__New(Set, {
13
- RoomType.BOSS_RUSH,
14
- RoomType.BLACK_MARKET,
15
- RoomType.GREED_EXIT,
16
- RoomType.TELEPORTER,
17
- RoomType.TELEPORTER_EXIT,
18
- RoomType.SECRET_EXIT,
19
- RoomType.BLUE
20
- })
21
- --- StageAPI uses 70000 as a base.
22
- ____exports.CUSTOM_STAGE_BASE_ROOM_VARIANT = 80000
23
- --- - The `RoomShape` enum goes from 1 to 12.
24
- -- - 12 in binary is 1100.
25
- -- - Thus, we need 4 bits to represent `RoomShape`.
26
- ____exports.CUSTOM_STAGE_NUM_ROOM_SHAPE_BITS = 4
27
- --- One for each possible door slot. We add one to account for `DoorSlot.LEFT_0` being equal to zero.
28
- ____exports.CUSTOM_STAGE_NUM_DOOR_SLOT_BITS = getLastEnumValue(nil, DoorSlot) + 1
29
- return ____exports
@@ -1,27 +0,0 @@
1
- /**
2
- * Since room data is immutable, we need to create an array of empty rooms like the following:
3
- *
4
- * ```xml
5
- * <room variant="80150" name="1x1" type="2" subtype="0" shape="1" width="13" height="7"
6
- * difficulty="1" weight="0.0">
7
- * <door exists="True" x="-1" y="3"/>
8
- * <door exists="True" x="6" y="-1"/>
9
- * <door exists="True" x="6" y="7"/>
10
- * <door exists="True" x="13" y="3"/>
11
- * </room>
12
- * ```
13
- *
14
- * - We can repeat room variants between different room types.
15
- * - The `RoomShape` enum goes from 1 to 12.
16
- * - 12 in binary is 1100.
17
- * - Thus, we need 4 bits to represent `RoomShape`.
18
- * - There are 8 possible door slots.
19
- * - Thus, we need 8 bits to represent `BitFlags<DoorSlot>`.
20
- *
21
- * Thus, the room variant has the following sequence:
22
- * - 4 bits of `RoomShape` + 8 bits of `BitFlags<DoorSlot>`
23
- *
24
- * Even though Basement Renovator does not allow setting variants to values above 16 bits, values
25
- * with 17 bits work fine in-game.
26
- */
27
- export declare function generateCustomStageBaseRooms(): void;
@@ -1,126 +0,0 @@
1
- local ____lualib = require("lualib_bundle")
2
- local Set = ____lualib.Set
3
- local __TS__New = ____lualib.__TS__New
4
- local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
5
- local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
6
- local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
7
- local __TS__StringTrim = ____lualib.__TS__StringTrim
8
- local __TS__StringSplit = ____lualib.__TS__StringSplit
9
- local ____exports = {}
10
- local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
11
- local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
12
- local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
13
- local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
14
- local ____bitwise = require("functions.bitwise")
15
- local convertBinaryToDecimal = ____bitwise.convertBinaryToDecimal
16
- local convertDecimalToBinary = ____bitwise.convertDecimalToBinary
17
- local setToBitFlags = ____bitwise.setToBitFlags
18
- local ____doors = require("functions.doors")
19
- local doorSlotToDoorSlotFlag = ____doors.doorSlotToDoorSlotFlag
20
- local getDoorSlotsForRoomShape = ____doors.getDoorSlotsForRoomShape
21
- local getRoomShapeDoorSlotCoordinates = ____doors.getRoomShapeDoorSlotCoordinates
22
- local ____enums = require("functions.enums")
23
- local getEnumValues = ____enums.getEnumValues
24
- local ____flag = require("functions.flag")
25
- local hasFlag = ____flag.hasFlag
26
- local ____roomShape = require("functions.roomShape")
27
- local getRoomShapeLayoutSize = ____roomShape.getRoomShapeLayoutSize
28
- local ____set = require("functions.set")
29
- local getSetCombinations = ____set.getSetCombinations
30
- local getSortedSetValues = ____set.getSortedSetValues
31
- local ____constants = require("features.customStage.constants")
32
- local CUSTOM_STAGE_BASE_ROOM_VARIANT = ____constants.CUSTOM_STAGE_BASE_ROOM_VARIANT
33
- local CUSTOM_STAGE_ILLEGAL_ROOM_TYPES = ____constants.CUSTOM_STAGE_ILLEGAL_ROOM_TYPES
34
- local CUSTOM_STAGE_NUM_DOOR_SLOT_BITS = ____constants.CUSTOM_STAGE_NUM_DOOR_SLOT_BITS
35
- local CUSTOM_STAGE_NUM_ROOM_SHAPE_BITS = ____constants.CUSTOM_STAGE_NUM_ROOM_SHAPE_BITS
36
- --- Since room data is immutable, we need to create an array of empty rooms like the following:
37
- --
38
- -- ```xml
39
- -- <room variant="80150" name="1x1" type="2" subtype="0" shape="1" width="13" height="7"
40
- -- difficulty="1" weight="0.0">
41
- -- <door exists="True" x="-1" y="3"/>
42
- -- <door exists="True" x="6" y="-1"/>
43
- -- <door exists="True" x="6" y="7"/>
44
- -- <door exists="True" x="13" y="3"/>
45
- -- </room>
46
- -- ```
47
- --
48
- -- - We can repeat room variants between different room types.
49
- -- - The `RoomShape` enum goes from 1 to 12.
50
- -- - 12 in binary is 1100.
51
- -- - Thus, we need 4 bits to represent `RoomShape`.
52
- -- - There are 8 possible door slots.
53
- -- - Thus, we need 8 bits to represent `BitFlags<DoorSlot>`.
54
- --
55
- -- Thus, the room variant has the following sequence:
56
- -- - 4 bits of `RoomShape` + 8 bits of `BitFlags<DoorSlot>`
57
- --
58
- -- Even though Basement Renovator does not allow setting variants to values above 16 bits, values
59
- -- with 17 bits work fine in-game.
60
- function ____exports.generateCustomStageBaseRooms(self)
61
- local rooms = {}
62
- for ____, roomType in ipairs(getEnumValues(nil, RoomType)) do
63
- do
64
- if CUSTOM_STAGE_ILLEGAL_ROOM_TYPES:has(roomType) then
65
- goto __continue3
66
- end
67
- for ____, roomShape in ipairs(getEnumValues(nil, RoomShape)) do
68
- do
69
- if roomType ~= RoomType.DEFAULT and roomShape ~= RoomShape.SHAPE_1x1 then
70
- goto __continue5
71
- end
72
- local roomShapeBits = convertDecimalToBinary(nil, roomShape, CUSTOM_STAGE_NUM_ROOM_SHAPE_BITS)
73
- local doorSlotsSet = getDoorSlotsForRoomShape(nil, roomShape)
74
- local doorSlots = getSortedSetValues(nil, doorSlotsSet)
75
- local doorSlotFlagsSet = __TS__New(Set)
76
- for ____, doorSlot in ipairs(doorSlots) do
77
- local doorSlotFlag = doorSlotToDoorSlotFlag(nil, doorSlot)
78
- doorSlotFlagsSet:add(doorSlotFlag)
79
- end
80
- local doorSlotFlagCombinations = getSetCombinations(nil, doorSlotFlagsSet, false)
81
- for ____, doorSlotFlagCombination in ipairs(doorSlotFlagCombinations) do
82
- local doorSlotFlags = setToBitFlags(nil, doorSlotFlagCombination)
83
- local doorSlotBits = convertDecimalToBinary(nil, doorSlotFlags, CUSTOM_STAGE_NUM_DOOR_SLOT_BITS)
84
- local ____array_0 = __TS__SparseArrayNew(table.unpack(roomShapeBits))
85
- __TS__SparseArrayPush(
86
- ____array_0,
87
- table.unpack(doorSlotBits)
88
- )
89
- local combinedBits = {__TS__SparseArraySpread(____array_0)}
90
- local roomVariant = CUSTOM_STAGE_BASE_ROOM_VARIANT + convertBinaryToDecimal(nil, combinedBits)
91
- local name = (((("Type: " .. tostring(roomType)) .. ", Shape: ") .. tostring(roomShape)) .. ", DoorSlotFlags: ") .. tostring(doorSlotFlags)
92
- local width, height = table.unpack(getRoomShapeLayoutSize(nil, roomShape))
93
- local roomHeader = (((((((((((" <room name=\"" .. name) .. "\" type=\"") .. tostring(roomType)) .. "\" variant=\"") .. tostring(roomVariant)) .. "\" subtype=\"0\" shape=\"") .. tostring(roomShape)) .. "\" width=\"") .. tostring(width)) .. "\" height=\"") .. tostring(height)) .. "\" difficulty=\"1\" weight=\"0.0\">\n"
94
- local doors = {}
95
- for ____, doorSlot in ipairs(doorSlots) do
96
- local thisDoorSlotFlag = doorSlotToDoorSlotFlag(nil, doorSlot)
97
- local exists = hasFlag(nil, doorSlotFlags, thisDoorSlotFlag)
98
- local existsText = exists and "True" or "False"
99
- local coordinates = getRoomShapeDoorSlotCoordinates(nil, roomShape, doorSlot)
100
- if coordinates == nil then
101
- error(((((((("Failed to get the coordinates for room shape " .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ") and door slot ") .. tostring(DoorSlot[doorSlot])) .. " (") .. tostring(doorSlot)) .. ").")
102
- end
103
- local x, y = table.unpack(coordinates)
104
- local door = (((((" <door exists=\"" .. existsText) .. "\" x=\"") .. tostring(x)) .. "\" y=\"") .. tostring(y)) .. "\" />\n"
105
- doors[#doors + 1] = door
106
- end
107
- local doorsXML = table.concat(doors, "")
108
- local roomFooter = " </room>\n"
109
- local room = (roomHeader .. doorsXML) .. roomFooter
110
- rooms[#rooms + 1] = room
111
- end
112
- end
113
- ::__continue5::
114
- end
115
- end
116
- ::__continue3::
117
- end
118
- local xml = table.concat({
119
- __TS__StringTrim(("\n<?xml version=\"1.0\" ?>\n<rooms>\n" .. table.concat(rooms, "")) .. "\n</rooms>"),
120
- "\n"
121
- })
122
- for ____, line in ipairs(__TS__StringSplit(xml, "\n")) do
123
- Isaac.DebugString(line)
124
- end
125
- end
126
- return ____exports
@@ -1,5 +0,0 @@
1
- import { LevelStage } from "isaac-typescript-definitions";
2
- export interface CustomStageData {
3
- name: string;
4
- baseStage: LevelStage;
5
- }
@@ -1,11 +0,0 @@
1
- /** Part of `JSONRooms`. */
2
- export interface JSONDoor {
3
- $: {
4
- /** Equal to "True" or "False". Needs to be converted to an `boolean`. */
5
- exists: string;
6
- /** Needs to be converted to an `int`. */
7
- x: string;
8
- /** Needs to be converted to an `int`. */
9
- y: string;
10
- };
11
- }
@@ -1,13 +0,0 @@
1
- /** Part of `JSONRooms`. */
2
- export interface JSONEntity {
3
- $: {
4
- /** Needs to be converted to an `int`. */
5
- type: string;
6
- /** Needs to be converted to an `int`. */
7
- variant: string;
8
- /** Needs to be converted to an `int`. */
9
- subtype: string;
10
- /** Needs to be converted to a `float`. */
11
- weight: string;
12
- };
13
- }
@@ -1,26 +0,0 @@
1
- import { JSONDoor } from "./JSONDoor";
2
- import { JSONSpawn } from "./JSONSpawn";
3
- /** Part of `JSONRooms`. */
4
- export interface JSONRoom {
5
- $: {
6
- /** Needs to be converted to an `int`. */
7
- difficulty: string;
8
- /** Needs to be converted to an `int`. */
9
- height: string;
10
- name: string;
11
- /** Needs to be converted to an `int`. */
12
- shape: string;
13
- /** Needs to be converted to an `int`. */
14
- subtype: string;
15
- /** Needs to be converted to an `int`. */
16
- type: string;
17
- /** Needs to be converted to an `int`. */
18
- variant: string;
19
- /** Needs to be converted to a `float`. */
20
- weight: string;
21
- /** Needs to be converted to an `int`. */
22
- width: string;
23
- };
24
- door: JSONDoor[];
25
- spawn: JSONSpawn[];
26
- }
@@ -1,2 +0,0 @@
1
- local ____exports = {}
2
- return ____exports
@@ -1,11 +0,0 @@
1
- import { JSONRoom } from "./JSONRoom";
2
- /**
3
- * Custom rooms are created with the Basement Renovator program, which outputs XML files and STB
4
- * files. A `JSONRooms` object is simply an XML file converted to JSON. You can convert your XML
5
- * files using the following command: `npx convert-xml-to-json foo.xml foo.json`
6
- */
7
- export interface JSONRooms {
8
- rooms: {
9
- room: JSONRoom[];
10
- };
11
- }
@@ -1,2 +0,0 @@
1
- local ____exports = {}
2
- return ____exports
@@ -1,11 +0,0 @@
1
- import { JSONEntity } from "./JSONEntity";
2
- /** Part of `JSONRooms`. */
3
- export interface JSONSpawn {
4
- $: {
5
- /** Needs to be converted to an `int`. */
6
- x: string;
7
- /** Needs to be converted to an `int`. */
8
- y: string;
9
- };
10
- entity: JSONEntity[];
11
- }
@@ -1,2 +0,0 @@
1
- local ____exports = {}
2
- return ____exports