isaacscript-common 4.5.1 → 4.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.
Files changed (67) hide show
  1. package/constants.d.ts +0 -3
  2. package/constantsFirstLast.d.ts +0 -3
  3. package/features/characterHealthConversion.d.ts +6 -0
  4. package/features/characterStats.d.ts +5 -0
  5. package/features/deployJSONRoom.lua +2 -4
  6. package/features/disableAllSound.d.ts +0 -3
  7. package/features/registerHotkey.lua +1 -1
  8. package/functions/array.d.ts +30 -1
  9. package/functions/array.lua +84 -5
  10. package/functions/bitwise.d.ts +17 -0
  11. package/functions/bitwise.lua +41 -0
  12. package/functions/color.d.ts +1 -1
  13. package/functions/doors.d.ts +6 -0
  14. package/functions/doors.lua +23 -2
  15. package/functions/gridEntity.d.ts +12 -0
  16. package/functions/gridEntity.lua +15 -2
  17. package/functions/kColor.d.ts +1 -1
  18. package/functions/log.d.ts +2 -2
  19. package/functions/rng.d.ts +1 -1
  20. package/functions/rng.lua +6 -2
  21. package/functions/roomShape.d.ts +2 -2
  22. package/functions/rooms.d.ts +1 -0
  23. package/functions/rooms.lua +1 -0
  24. package/functions/set.d.ts +17 -0
  25. package/functions/set.lua +24 -0
  26. package/functions/stage.d.ts +6 -1
  27. package/functions/stage.lua +7 -0
  28. package/functions/vector.d.ts +1 -1
  29. package/index.d.ts +0 -1
  30. package/index.lua +0 -8
  31. package/initFeatures.lua +3 -3
  32. package/maps/roomTypeMap.lua +0 -1
  33. package/objects/doorSlotToDoorSlotFlag.d.ts +4 -0
  34. package/objects/doorSlotToDoorSlotFlag.lua +17 -0
  35. package/objects/roomShapeBounds.d.ts +1 -1
  36. package/objects/roomShapeBounds.lua +8 -8
  37. package/objects/roomShapeLayoutSizes.d.ts +1 -1
  38. package/objects/roomShapeLayoutSizes.lua +4 -4
  39. package/objects/roomTypeGotoPrefixes.d.ts +4 -0
  40. package/objects/roomTypeGotoPrefixes.lua +35 -0
  41. package/objects/roomTypeNames.lua +0 -1
  42. package/package.json +2 -2
  43. package/types/CollectibleIndex.d.ts +1 -1
  44. package/types/PickingUpItem.d.ts +3 -3
  45. package/types/PickingUpItem.lua +3 -3
  46. package/types/PlayerIndex.d.ts +1 -1
  47. package/types/private/IsaacAPIClass.d.ts +1 -1
  48. package/types/private/SerializedIsaacAPIClass.d.ts +1 -1
  49. package/types/private/TSTLClass.d.ts +1 -1
  50. package/enums/StageTravelEntityState.d.ts +0 -4
  51. package/enums/StageTravelEntityState.lua +0 -7
  52. package/enums/StageTravelState.d.ts +0 -6
  53. package/enums/StageTravelState.lua +0 -11
  54. package/features/customTrapdoor/constants.d.ts +0 -5
  55. package/features/customTrapdoor/constants.lua +0 -7
  56. package/features/customTrapdoor/exports.d.ts +0 -37
  57. package/features/customTrapdoor/exports.lua +0 -124
  58. package/features/customTrapdoor/init.d.ts +0 -1
  59. package/features/customTrapdoor/init.lua +0 -11
  60. package/features/customTrapdoor/stageTravel.d.ts +0 -0
  61. package/features/customTrapdoor/stageTravel.lua +0 -0
  62. package/features/customTrapdoor/trapdoor.d.ts +0 -0
  63. package/features/customTrapdoor/trapdoor.lua +0 -0
  64. package/features/customTrapdoor/v.d.ts +0 -14
  65. package/features/customTrapdoor/v.lua +0 -16
  66. package/interfaces/StageTravelEntityDescription.d.ts +0 -5
  67. package/interfaces/StageTravelEntityDescription.lua +0 -2
package/functions/set.lua CHANGED
@@ -2,10 +2,12 @@ local ____lualib = require("lualib_bundle")
2
2
  local Set = ____lualib.Set
3
3
  local __TS__Iterator = ____lualib.__TS__Iterator
4
4
  local __TS__New = ____lualib.__TS__New
5
+ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
5
6
  local __TS__Spread = ____lualib.__TS__Spread
6
7
  local __TS__ArraySort = ____lualib.__TS__ArraySort
7
8
  local ____exports = {}
8
9
  local ____array = require("functions.array")
10
+ local getArrayCombinations = ____array.getArrayCombinations
9
11
  local getRandomArrayElement = ____array.getRandomArrayElement
10
12
  local ____rng = require("functions.rng")
11
13
  local getRandomSeed = ____rng.getRandomSeed
@@ -80,4 +82,26 @@ function ____exports.getRandomSetElement(self, set, seedOrRNG, exceptions)
80
82
  local array = ____exports.getSortedSetValues(nil, set)
81
83
  return getRandomArrayElement(nil, array, seedOrRNG, exceptions)
82
84
  end
85
+ --- Helper function to get all possible combinations of the given set. This includes the combination
86
+ -- of an empty set.
87
+ --
88
+ -- For example, if this function is provided a set containing 1, 2, and 3, then it will return an
89
+ -- array containing the following sets:
90
+ --
91
+ -- - []
92
+ -- - [1]
93
+ -- - [2]
94
+ -- - [3]
95
+ -- - [1, 2]
96
+ -- - [1, 3]
97
+ -- - [2, 3]
98
+ -- - [1, 2, 3]
99
+ function ____exports.getSetCombinations(self, set)
100
+ local values = ____exports.getSortedSetValues(nil, set)
101
+ local combinations = getArrayCombinations(nil, values)
102
+ return __TS__ArrayMap(
103
+ combinations,
104
+ function(____, array) return __TS__New(Set, array) end
105
+ )
106
+ end
83
107
  return ____exports
@@ -1,4 +1,4 @@
1
- import { LevelStage, StageType } from "isaac-typescript-definitions";
1
+ import { LevelStage, RoomType, StageType } from "isaac-typescript-definitions";
2
2
  /**
3
3
  * Helper function that calculates what the stage type should be for the provided stage. This
4
4
  * emulates what the game's internal code does.
@@ -15,6 +15,11 @@ export declare function calculateStageTypeRepentance(stage: LevelStage): StageTy
15
15
  * consider Downpour 2 to have a stage of 3.
16
16
  */
17
17
  export declare function getEffectiveStage(): int;
18
+ /**
19
+ * Helper function to get the prefix to use with the "goto" console command that would correspond to
20
+ * the provided room type.
21
+ */
22
+ export declare function getGotoCommandPrefix(roomType: RoomType): string;
18
23
  /** Alias for the `Level.GetStage` method. */
19
24
  export declare function getStage(): LevelStage;
20
25
  /** Alias for the `Level.GetStageType` method. */
@@ -4,6 +4,8 @@ local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
4
4
  local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
5
5
  local ____cachedClasses = require("cachedClasses")
6
6
  local game = ____cachedClasses.game
7
+ local ____roomTypeGotoPrefixes = require("objects.roomTypeGotoPrefixes")
8
+ local ROOM_TYPE_GOTO_PREFIXES = ____roomTypeGotoPrefixes.ROOM_TYPE_GOTO_PREFIXES
7
9
  local ____stageTypeSuffixes = require("objects.stageTypeSuffixes")
8
10
  local STAGE_TYPE_SUFFIXES = ____stageTypeSuffixes.STAGE_TYPE_SUFFIXES
9
11
  local ____stageTypeToLetter = require("objects.stageTypeToLetter")
@@ -62,6 +64,11 @@ function ____exports.getEffectiveStage(self)
62
64
  end
63
65
  return stage
64
66
  end
67
+ --- Helper function to get the prefix to use with the "goto" console command that would correspond to
68
+ -- the provided room type.
69
+ function ____exports.getGotoCommandPrefix(self, roomType)
70
+ return ROOM_TYPE_GOTO_PREFIXES[roomType]
71
+ end
65
72
  --- Alias for the `Level.GetStage` method.
66
73
  function ____exports.getStage(self)
67
74
  local level = game:GetLevel()
@@ -2,7 +2,7 @@
2
2
  import { Direction } from "isaac-typescript-definitions";
3
3
  import { SerializationType } from "../enums/SerializationType";
4
4
  declare type SerializedVector = LuaTable<string, unknown> & {
5
- readonly __serializedVectorBrand: unique symbol;
5
+ readonly __serializedVectorBrand: symbol;
6
6
  };
7
7
  interface CopyVectorReturn {
8
8
  [SerializationType.NONE]: Vector;
package/index.d.ts CHANGED
@@ -12,7 +12,6 @@ export * from "./enums/SerializationType";
12
12
  export { ConversionHeartSubType, registerCharacterHealthConversion, } from "./features/characterHealthConversion";
13
13
  export { registerCharacterStats } from "./features/characterStats";
14
14
  export { getCollectibleItemPoolType } from "./features/collectibleItemPoolType";
15
- export * from "./features/customTrapdoor/exports";
16
15
  export * from "./features/debugDisplay/exports";
17
16
  export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/deployJSONRoom";
18
17
  export { disableAllSound, enableAllSound } from "./features/disableAllSound";
package/index.lua CHANGED
@@ -100,14 +100,6 @@ do
100
100
  local getCollectibleItemPoolType = ____collectibleItemPoolType.getCollectibleItemPoolType
101
101
  ____exports.getCollectibleItemPoolType = getCollectibleItemPoolType
102
102
  end
103
- do
104
- local ____export = require("features.customTrapdoor.exports")
105
- for ____exportKey, ____exportValue in pairs(____export) do
106
- if ____exportKey ~= "default" then
107
- ____exports[____exportKey] = ____exportValue
108
- end
109
- end
110
- end
111
103
  do
112
104
  local ____export = require("features.debugDisplay.exports")
113
105
  for ____exportKey, ____exportValue in pairs(____export) do
package/initFeatures.lua CHANGED
@@ -5,8 +5,6 @@ local ____characterStats = require("features.characterStats")
5
5
  local characterStatsInit = ____characterStats.characterStatsInit
6
6
  local ____collectibleItemPoolType = require("features.collectibleItemPoolType")
7
7
  local collectibleItemPoolTypeInit = ____collectibleItemPoolType.collectibleItemPoolTypeInit
8
- local ____init = require("features.customTrapdoor.init")
9
- local stageTravelInit = ____init.stageTravelInit
10
8
  local ____deployJSONRoom = require("features.deployJSONRoom")
11
9
  local deployJSONRoomInit = ____deployJSONRoom.deployJSONRoomInit
12
10
  local ____disableAllSound = require("features.disableAllSound")
@@ -27,6 +25,8 @@ local ____ponyDetection = require("features.ponyDetection")
27
25
  local ponyDetectionInit = ____ponyDetection.ponyDetectionInit
28
26
  local ____preventCollectibleRotation = require("features.preventCollectibleRotation")
29
27
  local preventCollectibleRotationInit = ____preventCollectibleRotation.preventCollectibleRotationInit
28
+ local ____registerHotkey = require("features.registerHotkey")
29
+ local registerHotkeyInit = ____registerHotkey.registerHotkeyInit
30
30
  local ____roomClearFrame = require("features.roomClearFrame")
31
31
  local roomClearFrameInit = ____roomClearFrame.roomClearFrameInit
32
32
  local ____runInNFrames = require("features.runInNFrames")
@@ -54,10 +54,10 @@ function ____exports.initFeaturesMinor(self, mod)
54
54
  playerInventoryInit(nil, mod)
55
55
  ponyDetectionInit(nil, mod)
56
56
  preventCollectibleRotationInit(nil, mod)
57
+ registerHotkeyInit(nil, mod)
57
58
  roomClearFrameInit(nil, mod)
58
59
  sirenHelpersInit(nil, mod)
59
60
  stageHistoryInit(nil, mod)
60
- stageTravelInit(nil)
61
61
  taintedLazarusPlayersInit(nil, mod)
62
62
  end
63
63
  return ____exports
@@ -6,7 +6,6 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
6
6
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
7
7
  --- Maps room type names to room types.
8
8
  ____exports.ROOM_TYPE_MAP = __TS__New(Map, {
9
- {"null", RoomType.NULL},
10
9
  {"default", RoomType.DEFAULT},
11
10
  {"shop", RoomType.SHOP},
12
11
  {"error", RoomType.ERROR},
@@ -0,0 +1,4 @@
1
+ import { DoorSlot, DoorSlotFlag } from "isaac-typescript-definitions";
2
+ export declare const DOOR_SLOT_TO_DOOR_SLOT_FLAG: {
3
+ readonly [key in DoorSlot]: DoorSlotFlag;
4
+ };
@@ -0,0 +1,17 @@
1
+ local ____exports = {}
2
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
+ local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
4
+ local DoorSlotFlag = ____isaac_2Dtypescript_2Ddefinitions.DoorSlotFlag
5
+ local DoorSlotFlagZero = ____isaac_2Dtypescript_2Ddefinitions.DoorSlotFlagZero
6
+ ____exports.DOOR_SLOT_TO_DOOR_SLOT_FLAG = {
7
+ [DoorSlot.NO_DOOR_SLOT] = DoorSlotFlagZero,
8
+ [DoorSlot.LEFT_0] = DoorSlotFlag.LEFT_0,
9
+ [DoorSlot.UP_0] = DoorSlotFlag.UP_0,
10
+ [DoorSlot.RIGHT_0] = DoorSlotFlag.RIGHT_0,
11
+ [DoorSlot.DOWN_0] = DoorSlotFlag.DOWN_0,
12
+ [DoorSlot.LEFT_1] = DoorSlotFlag.LEFT_1,
13
+ [DoorSlot.UP_1] = DoorSlotFlag.UP_1,
14
+ [DoorSlot.RIGHT_1] = DoorSlotFlag.RIGHT_1,
15
+ [DoorSlot.DOWN_1] = DoorSlotFlag.DOWN_1
16
+ }
17
+ return ____exports
@@ -4,5 +4,5 @@ import { RoomShape } from "isaac-typescript-definitions";
4
4
  * rooms use the same bounds as a 2x2 room.
5
5
  */
6
6
  export declare const ROOM_SHAPE_BOUNDS: {
7
- readonly [key in RoomShape]: Vector;
7
+ readonly [key in RoomShape]: readonly [width: int, height: int];
8
8
  };
@@ -6,17 +6,17 @@ local NARROW_CONTENTS_HEIGHT = ____roomShapeVolumes.NARROW_CONTENTS_HEIGHT
6
6
  local NARROW_CONTENTS_WIDTH = ____roomShapeVolumes.NARROW_CONTENTS_WIDTH
7
7
  local ONE_BY_ONE_CONTENTS_HEIGHT = ____roomShapeVolumes.ONE_BY_ONE_CONTENTS_HEIGHT
8
8
  local ONE_BY_ONE_CONTENTS_WIDTH = ____roomShapeVolumes.ONE_BY_ONE_CONTENTS_WIDTH
9
- local TWO_BY_TWO_BOUNDS = Vector(ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT * 2)
9
+ local TWO_BY_TWO_BOUNDS = {ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT * 2}
10
10
  --- The size of a room shape's contents. This does not include the tiles that the walls are on. L
11
11
  -- rooms use the same bounds as a 2x2 room.
12
12
  ____exports.ROOM_SHAPE_BOUNDS = {
13
- [RoomShape.SHAPE_1x1] = Vector(ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT),
14
- [RoomShape.IH] = Vector(ONE_BY_ONE_CONTENTS_WIDTH, NARROW_CONTENTS_HEIGHT),
15
- [RoomShape.IV] = Vector(NARROW_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT),
16
- [RoomShape.SHAPE_1x2] = Vector(ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2),
17
- [RoomShape.IIV] = Vector(NARROW_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2),
18
- [RoomShape.SHAPE_2x1] = Vector(ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT),
19
- [RoomShape.IIH] = Vector(ONE_BY_ONE_CONTENTS_WIDTH * 2, NARROW_CONTENTS_HEIGHT),
13
+ [RoomShape.SHAPE_1x1] = {ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT},
14
+ [RoomShape.IH] = {ONE_BY_ONE_CONTENTS_WIDTH, NARROW_CONTENTS_HEIGHT},
15
+ [RoomShape.IV] = {NARROW_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT},
16
+ [RoomShape.SHAPE_1x2] = {ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2},
17
+ [RoomShape.IIV] = {NARROW_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2},
18
+ [RoomShape.SHAPE_2x1] = {ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT},
19
+ [RoomShape.IIH] = {ONE_BY_ONE_CONTENTS_WIDTH * 2, NARROW_CONTENTS_HEIGHT},
20
20
  [RoomShape.SHAPE_2x2] = TWO_BY_TWO_BOUNDS,
21
21
  [RoomShape.LTL] = TWO_BY_TWO_BOUNDS,
22
22
  [RoomShape.LTR] = TWO_BY_TWO_BOUNDS,
@@ -6,5 +6,5 @@ import { RoomShape } from "isaac-typescript-definitions";
6
6
  * For example, a horizontal narrow room has a layout size of equal to that of a 1x1 room.
7
7
  */
8
8
  export declare const ROOM_SHAPE_LAYOUT_SIZES: {
9
- readonly [key in RoomShape]: Vector;
9
+ readonly [key in RoomShape]: readonly [width: int, height: int];
10
10
  };
@@ -4,10 +4,10 @@ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
4
4
  local ____roomShapeVolumes = require("objects.roomShapeVolumes")
5
5
  local ONE_BY_ONE_CONTENTS_HEIGHT = ____roomShapeVolumes.ONE_BY_ONE_CONTENTS_HEIGHT
6
6
  local ONE_BY_ONE_CONTENTS_WIDTH = ____roomShapeVolumes.ONE_BY_ONE_CONTENTS_WIDTH
7
- local ONE_BY_ONE_LAYOUT_SIZE = Vector(ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT)
8
- local TWO_BY_ONE_VERTICAL_LAYOUT_SIZE = Vector(ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2)
9
- local TWO_BY_ONE_HORIZONTAL_LAYOUT_SIZE = Vector(ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT)
10
- local TWO_BY_TWO_LAYOUT_SIZE = Vector(ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT * 2)
7
+ local ONE_BY_ONE_LAYOUT_SIZE = {ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT}
8
+ local TWO_BY_ONE_VERTICAL_LAYOUT_SIZE = {ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2}
9
+ local TWO_BY_ONE_HORIZONTAL_LAYOUT_SIZE = {ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT}
10
+ local TWO_BY_TWO_LAYOUT_SIZE = {ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT * 2}
11
11
  --- The dimensions of a room shape's layout. This is NOT the size of the room's actual contents! For
12
12
  -- that, use `ROOM_SHAPE_BOUNDS`.
13
13
  --
@@ -0,0 +1,4 @@
1
+ import { RoomType } from "isaac-typescript-definitions";
2
+ export declare const ROOM_TYPE_GOTO_PREFIXES: {
3
+ readonly [key in RoomType]: string;
4
+ };
@@ -0,0 +1,35 @@
1
+ local ____exports = {}
2
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
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."
34
+ }
35
+ return ____exports
@@ -3,7 +3,6 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
3
3
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
4
4
  ____exports.DEFAULT_ROOM_TYPE_NAME = "Unknown"
5
5
  ____exports.ROOM_TYPE_NAMES = {
6
- [RoomType.NULL] = "null room",
7
6
  [RoomType.DEFAULT] = "default room",
8
7
  [RoomType.SHOP] = "shop",
9
8
  [RoomType.ERROR] = "I AM ERROR Room",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "4.5.1",
3
+ "version": "4.6.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "index",
23
23
  "types": "index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^3.0.13"
25
+ "isaac-typescript-definitions": "^3.0.15"
26
26
  }
27
27
  }
@@ -12,5 +12,5 @@
12
12
  * This type is branded for extra type safety.
13
13
  */
14
14
  export declare type CollectibleIndex = string & {
15
- readonly __collectibleIndexBrand: unique symbol;
15
+ readonly __collectibleIndexBrand: symbol;
16
16
  };
@@ -27,8 +27,8 @@ export interface PickingUpItemTrinket {
27
27
  subType: TrinketType;
28
28
  }
29
29
  /** Helper function to narrow the type of `PickingUpItem`. */
30
- export declare function pickingUpItemIsNull(pickingUpItem: PickingUpItem): pickingUpItem is PickingUpItemTrinket;
30
+ export declare function isPickingUpItemNull(pickingUpItem: PickingUpItem): pickingUpItem is PickingUpItemTrinket;
31
31
  /** Helper function to narrow the type of `PickingUpItem`. */
32
- export declare function pickingUpItemIsCollectible(pickingUpItem: PickingUpItem): pickingUpItem is PickingUpItemCollectible;
32
+ export declare function isPickingUpItemCollectible(pickingUpItem: PickingUpItem): pickingUpItem is PickingUpItemCollectible;
33
33
  /** Helper function to narrow the type of `PickingUpItem`. */
34
- export declare function pickingUpItemIsTrinket(pickingUpItem: PickingUpItem): pickingUpItem is PickingUpItemTrinket;
34
+ export declare function isPickingUpItemTrinket(pickingUpItem: PickingUpItem): pickingUpItem is PickingUpItemTrinket;
@@ -20,15 +20,15 @@ function ____exports.resetPickingUpItem(self, pickingUpItem)
20
20
  end
21
21
  local COLLECTIBLE_ITEM_TYPES = __TS__New(Set, {ItemType.PASSIVE, ItemType.ACTIVE, ItemType.FAMILIAR})
22
22
  --- Helper function to narrow the type of `PickingUpItem`.
23
- function ____exports.pickingUpItemIsNull(self, pickingUpItem)
23
+ function ____exports.isPickingUpItemNull(self, pickingUpItem)
24
24
  return pickingUpItem.itemType == ItemType.NULL
25
25
  end
26
26
  --- Helper function to narrow the type of `PickingUpItem`.
27
- function ____exports.pickingUpItemIsCollectible(self, pickingUpItem)
27
+ function ____exports.isPickingUpItemCollectible(self, pickingUpItem)
28
28
  return COLLECTIBLE_ITEM_TYPES:has(pickingUpItem.itemType)
29
29
  end
30
30
  --- Helper function to narrow the type of `PickingUpItem`.
31
- function ____exports.pickingUpItemIsTrinket(self, pickingUpItem)
31
+ function ____exports.isPickingUpItemTrinket(self, pickingUpItem)
32
32
  return pickingUpItem.itemType == ItemType.TRINKET
33
33
  end
34
34
  return ____exports
@@ -12,5 +12,5 @@
12
12
  * This type is branded for extra type safety.
13
13
  */
14
14
  export declare type PlayerIndex = int & {
15
- readonly __playerIndexBrand: unique symbol;
15
+ readonly __playerIndexBrand: symbol;
16
16
  };
@@ -1,4 +1,4 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  export declare type IsaacAPIClass = LuaTable<string, unknown> & {
3
- readonly __isaacAPIClassBrand: unique symbol;
3
+ readonly __isaacAPIClassBrand: symbol;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  export declare type SerializedIsaacAPIClass = LuaTable<string, unknown> & {
3
- readonly __serializedIsaacAPIClassBrand: unique symbol;
3
+ readonly __serializedIsaacAPIClassBrand: symbol;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  export declare type TSTLClass = LuaTable<AnyNotNil, unknown> & {
3
- readonly __tstlClassBrand: unique symbol;
3
+ readonly __tstlClassBrand: symbol;
4
4
  };
@@ -1,4 +0,0 @@
1
- export declare enum StageTravelEntityState {
2
- OPEN = 0,
3
- CLOSED = 1
4
- }
@@ -1,7 +0,0 @@
1
- local ____exports = {}
2
- ____exports.StageTravelEntityState = {}
3
- ____exports.StageTravelEntityState.OPEN = 0
4
- ____exports.StageTravelEntityState[____exports.StageTravelEntityState.OPEN] = "OPEN"
5
- ____exports.StageTravelEntityState.CLOSED = 1
6
- ____exports.StageTravelEntityState[____exports.StageTravelEntityState.CLOSED] = "CLOSED"
7
- return ____exports
@@ -1,6 +0,0 @@
1
- export declare enum StageTravelState {
2
- DISABLED = 0,
3
- FADING_TO_BLACK = 1,
4
- GOING_TO_NEW_FLOOR = 2,
5
- FADING_IN = 3
6
- }
@@ -1,11 +0,0 @@
1
- local ____exports = {}
2
- ____exports.StageTravelState = {}
3
- ____exports.StageTravelState.DISABLED = 0
4
- ____exports.StageTravelState[____exports.StageTravelState.DISABLED] = "DISABLED"
5
- ____exports.StageTravelState.FADING_TO_BLACK = 1
6
- ____exports.StageTravelState[____exports.StageTravelState.FADING_TO_BLACK] = "FADING_TO_BLACK"
7
- ____exports.StageTravelState.GOING_TO_NEW_FLOOR = 2
8
- ____exports.StageTravelState[____exports.StageTravelState.GOING_TO_NEW_FLOOR] = "GOING_TO_NEW_FLOOR"
9
- ____exports.StageTravelState.FADING_IN = 3
10
- ____exports.StageTravelState[____exports.StageTravelState.FADING_IN] = "FADING_IN"
11
- return ____exports
@@ -1,5 +0,0 @@
1
- export declare const CUSTOM_TRAPDOOR_FEATURE_NAME = "customTrapdoor";
2
- /** This also applies to crawl spaces. The value was determined through trial and error. */
3
- export declare const TRAPDOOR_OPEN_DISTANCE = 60;
4
- export declare const TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS: number;
5
- export declare const TRAPDOOR_BOSS_REACTION_FRAMES = 30;
@@ -1,7 +0,0 @@
1
- local ____exports = {}
2
- ____exports.CUSTOM_TRAPDOOR_FEATURE_NAME = "customTrapdoor"
3
- --- This also applies to crawl spaces. The value was determined through trial and error.
4
- ____exports.TRAPDOOR_OPEN_DISTANCE = 60
5
- ____exports.TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = ____exports.TRAPDOOR_OPEN_DISTANCE * 2.5
6
- ____exports.TRAPDOOR_BOSS_REACTION_FRAMES = 30
7
- return ____exports
@@ -1,37 +0,0 @@
1
- import { LevelStage, StageType } from "isaac-typescript-definitions";
2
- /**
3
- * Helper function to spawn a trapdoor grid entity that will have one or more of the following
4
- * attributes:
5
- *
6
- * - custom destination (or custom logic for after the player enters)
7
- * - custom graphics
8
- * - custom logic for opening/closing
9
- * - TODO: animation
10
- *
11
- * You can use this function to take the player to your custom stage. (See the `registerCustomStage`
12
- * helper function.)
13
- *
14
- * Under the hood, the custom trapdoor is represented by a decoration grid entity and is manually
15
- * respawned every time the player re-enters the room.
16
- *
17
- * @param gridIndexOrPosition The location in the room to spawn the trapdoor.
18
- * @param _destination Used to specify where the player will go after jumping into the trapdoor. Can
19
- * either be a tuple containing the stage and stage type, a string containing
20
- * the name of a custom stage, or a function that returns one of these things.
21
- * You can also specify a function that returns undefined in order to perform
22
- * some custom behavior and/or handle the traveling part yourself. By default,
23
- * the destination will be set to the next floor like that of a vanilla
24
- * trapdoor.
25
- * @param _anm2 Optional. The path to the anm2 file to use. By default, the vanilla trapdoor anm2 of
26
- * "gfx/grid/door_11_trapdoor.anm2" will be used.
27
- * @param _shouldOpenFunc Optional. If the trapdoor is currently closed, this function will run on
28
- * every frame to determine if it should open. By default, a function that
29
- * emulates a vanilla trapdoor will be used.
30
- * @param _shouldCloseFunc Optional. If the trapdoor is currently open, this function will run on
31
- * every frame to determine if it should close. By default, a function that
32
- * emulates a vanilla trapdoor will be used.
33
- * @param _spawnOpen Optional. Whether or not to spawn the trapdoor in an open state. Can either be
34
- * a boolean or a function returning a boolean. By default, a function that
35
- * emulates a vanilla trapdoor will be used.
36
- */
37
- export declare function spawnCustomTrapdoor(gridIndexOrPosition: int | Vector, _destination?: [stage: LevelStage, stageType: StageType] | string | ((gridEntity: GridEntity) => [stage: LevelStage, stageType: StageType] | string | undefined), _anm2?: string, _shouldOpenFunc?: (gridEntity: GridEntity) => boolean, _shouldCloseFunc?: (gridEntity: GridEntity) => boolean, _spawnOpen?: boolean | ((gridEntity: GridEntity) => boolean)): GridEntity;
@@ -1,124 +0,0 @@
1
- local ____exports = {}
2
- local defaultDestinationFunc, defaultShouldOpenFunc, isPlayerCloseAfterBoss, shouldBeClosedFromStartingInRoomWithEnemies, defaultShouldCloseFunc, defaultShouldSpawnOpenFunc
3
- local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
- local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
5
- local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
6
- local ____cachedClasses = require("cachedClasses")
7
- local game = ____cachedClasses.game
8
- local ____featuresInitialized = require("featuresInitialized")
9
- local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
10
- local ____gridEntity = require("functions.gridEntity")
11
- local spawnGrid = ____gridEntity.spawnGrid
12
- local ____nextStage = require("functions.nextStage")
13
- local getNextStage = ____nextStage.getNextStage
14
- local getNextStageType = ____nextStage.getNextStageType
15
- local ____positionVelocity = require("functions.positionVelocity")
16
- local anyPlayerCloserThan = ____positionVelocity.anyPlayerCloserThan
17
- local ____roomClearFrame = require("features.roomClearFrame")
18
- local getRoomClearGameFrame = ____roomClearFrame.getRoomClearGameFrame
19
- local ____constants = require("features.customTrapdoor.constants")
20
- local CUSTOM_TRAPDOOR_FEATURE_NAME = ____constants.CUSTOM_TRAPDOOR_FEATURE_NAME
21
- local TRAPDOOR_BOSS_REACTION_FRAMES = ____constants.TRAPDOOR_BOSS_REACTION_FRAMES
22
- local TRAPDOOR_OPEN_DISTANCE = ____constants.TRAPDOOR_OPEN_DISTANCE
23
- local TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = ____constants.TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS
24
- local ____v = require("features.customTrapdoor.v")
25
- local getCustomTrapdoorDescription = ____v.getCustomTrapdoorDescription
26
- function defaultDestinationFunc(self)
27
- local nextStage = getNextStage(nil)
28
- local nextStageType = getNextStageType(nil)
29
- return {nextStage, nextStageType}
30
- end
31
- function defaultShouldOpenFunc(self, gridEntity)
32
- local entityDescription = getCustomTrapdoorDescription(nil, gridEntity)
33
- if entityDescription == nil then
34
- return false
35
- end
36
- local room = game:GetRoom()
37
- local roomClear = room:IsClear()
38
- return not anyPlayerCloserThan(nil, gridEntity.Position, TRAPDOOR_OPEN_DISTANCE) and not isPlayerCloseAfterBoss(nil, gridEntity.Position) and not shouldBeClosedFromStartingInRoomWithEnemies(nil, entityDescription.initial, roomClear)
39
- end
40
- function isPlayerCloseAfterBoss(self, position)
41
- local gameFrameCount = game:GetFrameCount()
42
- local room = game:GetRoom()
43
- local roomType = room:GetType()
44
- local roomClearGameFrame = getRoomClearGameFrame(nil)
45
- if roomType ~= RoomType.BOSS or roomClearGameFrame == nil or gameFrameCount >= roomClearGameFrame + TRAPDOOR_BOSS_REACTION_FRAMES then
46
- return false
47
- end
48
- return anyPlayerCloserThan(nil, position, TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS)
49
- end
50
- function shouldBeClosedFromStartingInRoomWithEnemies(self, initial, roomClear)
51
- return initial and not roomClear
52
- end
53
- function defaultShouldCloseFunc(self)
54
- return false
55
- end
56
- function defaultShouldSpawnOpenFunc(self, gridEntity)
57
- local room = game:GetRoom()
58
- local roomFrameCount = room:GetFrameCount()
59
- local roomClear = room:IsClear()
60
- if roomFrameCount > 0 then
61
- return false
62
- end
63
- if not roomClear then
64
- return false
65
- end
66
- return defaultShouldOpenFunc(nil, gridEntity)
67
- end
68
- --- Helper function to spawn a trapdoor grid entity that will have one or more of the following
69
- -- attributes:
70
- --
71
- -- - custom destination (or custom logic for after the player enters)
72
- -- - custom graphics
73
- -- - custom logic for opening/closing
74
- -- - TODO: animation
75
- --
76
- -- You can use this function to take the player to your custom stage. (See the `registerCustomStage`
77
- -- helper function.)
78
- --
79
- -- Under the hood, the custom trapdoor is represented by a decoration grid entity and is manually
80
- -- respawned every time the player re-enters the room.
81
- --
82
- -- @param gridIndexOrPosition The location in the room to spawn the trapdoor.
83
- -- @param _destination Used to specify where the player will go after jumping into the trapdoor. Can
84
- -- either be a tuple containing the stage and stage type, a string containing
85
- -- the name of a custom stage, or a function that returns one of these things.
86
- -- You can also specify a function that returns undefined in order to perform
87
- -- some custom behavior and/or handle the traveling part yourself. By default,
88
- -- the destination will be set to the next floor like that of a vanilla
89
- -- trapdoor.
90
- -- @param _anm2 Optional. The path to the anm2 file to use. By default, the vanilla trapdoor anm2 of
91
- -- "gfx/grid/door_11_trapdoor.anm2" will be used.
92
- -- @param _shouldOpenFunc Optional. If the trapdoor is currently closed, this function will run on
93
- -- every frame to determine if it should open. By default, a function that
94
- -- emulates a vanilla trapdoor will be used.
95
- -- @param _shouldCloseFunc Optional. If the trapdoor is currently open, this function will run on
96
- -- every frame to determine if it should close. By default, a function that
97
- -- emulates a vanilla trapdoor will be used.
98
- -- @param _spawnOpen Optional. Whether or not to spawn the trapdoor in an open state. Can either be
99
- -- a boolean or a function returning a boolean. By default, a function that
100
- -- emulates a vanilla trapdoor will be used.
101
- function ____exports.spawnCustomTrapdoor(self, gridIndexOrPosition, _destination, _anm2, _shouldOpenFunc, _shouldCloseFunc, _spawnOpen)
102
- if _destination == nil then
103
- _destination = defaultDestinationFunc
104
- end
105
- if _anm2 == nil then
106
- _anm2 = "gfx/grid/door_11_trapdoor.anm2"
107
- end
108
- if _shouldOpenFunc == nil then
109
- _shouldOpenFunc = defaultShouldOpenFunc
110
- end
111
- if _shouldCloseFunc == nil then
112
- _shouldCloseFunc = defaultShouldCloseFunc
113
- end
114
- if _spawnOpen == nil then
115
- _spawnOpen = defaultShouldSpawnOpenFunc
116
- end
117
- errorIfFeaturesNotInitialized(nil, CUSTOM_TRAPDOOR_FEATURE_NAME)
118
- local decoration = spawnGrid(nil, GridEntityType.DECORATION, gridIndexOrPosition)
119
- if decoration == nil then
120
- error("Failed to spawn a custom trapdoor.")
121
- end
122
- return decoration
123
- end
124
- return ____exports
@@ -1 +0,0 @@
1
- export declare function stageTravelInit(): void;
@@ -1,11 +0,0 @@
1
- local ____exports = {}
2
- local ____exports = require("features.saveDataManager.exports")
3
- local saveDataManager = ____exports.saveDataManager
4
- local ____constants = require("features.customTrapdoor.constants")
5
- local CUSTOM_TRAPDOOR_FEATURE_NAME = ____constants.CUSTOM_TRAPDOOR_FEATURE_NAME
6
- local ____v = require("features.customTrapdoor.v")
7
- local v = ____v.default
8
- function ____exports.stageTravelInit(self)
9
- saveDataManager(nil, CUSTOM_TRAPDOOR_FEATURE_NAME, v)
10
- end
11
- return ____exports
File without changes
File without changes
File without changes
File without changes
@@ -1,14 +0,0 @@
1
- /// <reference types="isaac-typescript-definitions" />
2
- import { StageTravelState } from "../../enums/StageTravelState";
3
- import { StageTravelEntityDescription } from "../../interfaces/StageTravelEntityDescription";
4
- declare const v: {
5
- run: {
6
- state: StageTravelState;
7
- };
8
- room: {
9
- /** Indexed by grid index. */
10
- trapdoors: Map<number, StageTravelEntityDescription>;
11
- };
12
- };
13
- export default v;
14
- export declare function getCustomTrapdoorDescription(gridEntity: GridEntity): StageTravelEntityDescription | undefined;