isaacscript-common 6.2.0 → 6.4.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 (96) hide show
  1. package/cachedClasses.d.ts +15 -0
  2. package/cachedClasses.lua +20 -0
  3. package/callbacks/reorderedCallbacks.d.ts +9 -0
  4. package/callbacks/reorderedCallbacks.lua +9 -0
  5. package/constants.d.ts +26 -4
  6. package/constants.lua +20 -4
  7. package/enums/CornerType.d.ts +6 -0
  8. package/enums/CornerType.lua +11 -0
  9. package/features/customStage/backdrop.d.ts +2 -0
  10. package/features/customStage/backdrop.lua +202 -0
  11. package/features/customStage/customStageConstants.d.ts +1 -0
  12. package/features/customStage/customStageConstants.lua +3 -0
  13. package/features/customStage/exports.d.ts +28 -0
  14. package/features/customStage/exports.lua +58 -1
  15. package/features/customStage/init.d.ts +2 -1
  16. package/features/customStage/init.lua +45 -9
  17. package/features/customStage/streakText.d.ts +2 -0
  18. package/features/customStage/streakText.lua +22 -0
  19. package/features/customStage/v.d.ts +10 -0
  20. package/features/customStage/v.lua +4 -0
  21. package/features/customStage/versusScreen.d.ts +3 -0
  22. package/features/customStage/versusScreen.lua +193 -0
  23. package/features/debugDisplay/debugDisplay.lua +2 -0
  24. package/features/debugDisplay/exports.d.ts +108 -0
  25. package/features/debugDisplay/exports.lua +145 -0
  26. package/features/debugDisplay/v.d.ts +2 -0
  27. package/features/debugDisplay/v.lua +9 -0
  28. package/features/deployJSONRoom.lua +6 -2
  29. package/features/extraConsoleCommands/init.lua +8 -1
  30. package/features/extraConsoleCommands/listCommands.d.ts +12 -4
  31. package/features/extraConsoleCommands/listCommands.lua +30 -15
  32. package/features/extraConsoleCommands/v.d.ts +1 -0
  33. package/features/extraConsoleCommands/v.lua +2 -1
  34. package/features/pause.d.ts +11 -0
  35. package/features/pause.lua +71 -0
  36. package/features/runNextRoom.d.ts +8 -0
  37. package/features/runNextRoom.lua +40 -0
  38. package/features/saveDataManager/exports.lua +2 -2
  39. package/features/saveDataManager/load.lua +3 -3
  40. package/features/saveDataManager/main.lua +3 -3
  41. package/features/saveDataManager/merge.lua +2 -2
  42. package/features/saveDataManager/save.lua +3 -3
  43. package/features/saveDataManager/{constants.d.ts → saveDataManagerConstants.d.ts} +0 -0
  44. package/features/saveDataManager/{constants.lua → saveDataManagerConstants.lua} +0 -0
  45. package/functions/chargeBar.lua +4 -6
  46. package/functions/color.d.ts +0 -2
  47. package/functions/color.lua +0 -4
  48. package/functions/deepCopy.lua +2 -2
  49. package/functions/direction.d.ts +1 -1
  50. package/functions/doors.d.ts +2 -2
  51. package/functions/entity.d.ts +5 -0
  52. package/functions/entity.lua +13 -0
  53. package/functions/gridEntity.d.ts +5 -0
  54. package/functions/gridEntity.lua +7 -2
  55. package/functions/kColor.d.ts +0 -2
  56. package/functions/kColor.lua +0 -4
  57. package/functions/log.lua +2 -1
  58. package/functions/playerCenter.d.ts +5 -1
  59. package/functions/playerCenter.lua +15 -8
  60. package/functions/playerIndex.d.ts +3 -0
  61. package/functions/playerIndex.lua +3 -0
  62. package/functions/roomShape.d.ts +10 -4
  63. package/functions/roomShape.lua +15 -2
  64. package/functions/sprite.d.ts +1 -1
  65. package/functions/sprite.lua +1 -1
  66. package/functions/ui.d.ts +2 -0
  67. package/functions/ui.lua +8 -0
  68. package/functions/utils.d.ts +6 -4
  69. package/functions/utils.lua +6 -4
  70. package/index.d.ts +2 -1
  71. package/index.lua +10 -0
  72. package/initFeatures.lua +7 -1
  73. package/interfaces/Corner.d.ts +6 -0
  74. package/interfaces/Corner.lua +2 -0
  75. package/interfaces/CustomStageLua.d.ts +38 -9
  76. package/objects/bossNamePNGFileNames.d.ts +5 -0
  77. package/objects/bossNamePNGFileNames.lua +108 -0
  78. package/objects/bossPortraitPNGFileNames.d.ts +5 -0
  79. package/objects/bossPortraitPNGFileNames.lua +108 -0
  80. package/objects/colors.d.ts +15 -8
  81. package/objects/colors.lua +9 -2
  82. package/objects/playerNamePNGFileNames.d.ts +5 -0
  83. package/objects/playerNamePNGFileNames.lua +49 -0
  84. package/objects/playerPortraitPNGFileNames.d.ts +5 -0
  85. package/objects/playerPortraitPNGFileNames.lua +49 -0
  86. package/objects/roomShapeCorners.d.ts +6 -0
  87. package/objects/roomShapeCorners.lua +259 -0
  88. package/objects/roomShapeToBottomRightPosition.d.ts +1 -1
  89. package/objects/roomShapeToTopLeftPosition.d.ts +1 -1
  90. package/objects/versusScreenBackgroundColors.d.ts +5 -0
  91. package/objects/versusScreenBackgroundColors.lua +38 -0
  92. package/objects/versusScreenDirtSpotColors.d.ts +5 -0
  93. package/objects/versusScreenDirtSpotColors.lua +38 -0
  94. package/package.json +2 -2
  95. package/sets/narrowRoomShapesSet.d.ts +2 -0
  96. package/sets/narrowRoomShapesSet.lua +8 -0
@@ -0,0 +1,71 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local postUpdate, inputActionGetActionValue, v
6
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
+ local ButtonAction = ____isaac_2Dtypescript_2Ddefinitions.ButtonAction
8
+ local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
9
+ local InputHook = ____isaac_2Dtypescript_2Ddefinitions.InputHook
10
+ local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
11
+ local ____log = require("functions.log")
12
+ local logError = ____log.logError
13
+ local ____player = require("functions.player")
14
+ local useActiveItemTemp = ____player.useActiveItemTemp
15
+ local ____disableInputs = require("features.disableInputs")
16
+ local disableAllInputsExceptFor = ____disableInputs.disableAllInputsExceptFor
17
+ local enableAllInputs = ____disableInputs.enableAllInputs
18
+ local ____exports = require("features.saveDataManager.exports")
19
+ local saveDataManager = ____exports.saveDataManager
20
+ function postUpdate(self)
21
+ if not v.run.isPseudoPaused then
22
+ return
23
+ end
24
+ local player = Isaac.GetPlayer()
25
+ useActiveItemTemp(nil, player, CollectibleType.PAUSE)
26
+ end
27
+ function inputActionGetActionValue(self, _entity, _inputHook, buttonAction)
28
+ if buttonAction ~= ButtonAction.SHOOT_RIGHT then
29
+ return
30
+ end
31
+ if not v.run.shouldUnpause then
32
+ return
33
+ end
34
+ v.run.shouldUnpause = false
35
+ return 1
36
+ end
37
+ local FEATURE_NAME = "pause"
38
+ v = {run = {isPseudoPaused = false, shouldUnpause = false}}
39
+ ---
40
+ -- @internal
41
+ function ____exports.pauseInit(self, mod)
42
+ saveDataManager(nil, FEATURE_NAME, v)
43
+ mod:AddCallback(ModCallback.POST_UPDATE, postUpdate)
44
+ mod:AddCallback(ModCallback.INPUT_ACTION, inputActionGetActionValue, InputHook.GET_ACTION_VALUE)
45
+ end
46
+ --- Helper function to emulate what happens when the player pauses the game. Use the `unpause`
47
+ -- function to return things back to normal.
48
+ --
49
+ -- Under the hood, this function:
50
+ -- - uses the Pause collectible on every game frame
51
+ -- - disables any player inputs (except for `ButtonAction.MENU_CONFIRM`)
52
+ function ____exports.pause(self)
53
+ if v.run.isPseudoPaused then
54
+ logError("Failed to pseudo-pause the game, since it was already pseudo-paused.")
55
+ return
56
+ end
57
+ v.run.isPseudoPaused = true
58
+ local whitelist = __TS__New(Set, {ButtonAction.MENU_CONFIRM})
59
+ disableAllInputsExceptFor(nil, FEATURE_NAME, whitelist)
60
+ end
61
+ --- Helper function to put things back to normal after the `pause` function was used.
62
+ function ____exports.unpause(self)
63
+ if not v.run.isPseudoPaused then
64
+ logError("Failed to pseudo-unpause the game, since it was not already pseudo-paused.")
65
+ return
66
+ end
67
+ v.run.isPseudoPaused = false
68
+ enableAllInputs(nil, FEATURE_NAME)
69
+ v.run.shouldUnpause = true
70
+ end
71
+ return ____exports
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Supply a function to run on the next `POST_NEW_ROOM` callback.
3
+ *
4
+ * Note that this function will not handle saving and quitting. If a player saving and quitting
5
+ * before the deferred function fires would cause a bug in your mod, then you should handle deferred
6
+ * functions manually using serializable data.
7
+ */
8
+ export declare function runNextRoom(func: () => void): void;
@@ -0,0 +1,40 @@
1
+ local ____exports = {}
2
+ local postNewRoomReordered, v
3
+ local ____ModCallbackCustom = require("enums.ModCallbackCustom")
4
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
5
+ local ____featuresInitialized = require("featuresInitialized")
6
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
7
+ local ____array = require("functions.array")
8
+ local emptyArray = ____array.emptyArray
9
+ local ____exports = require("features.saveDataManager.exports")
10
+ local saveDataManager = ____exports.saveDataManager
11
+ function postNewRoomReordered(self)
12
+ for ____, func in ipairs(v.run.queuedFunctions) do
13
+ func(nil)
14
+ end
15
+ emptyArray(nil, v.run.queuedFunctions)
16
+ end
17
+ local FEATURE_NAME = "runNextRoom"
18
+ v = {run = {queuedFunctions = {}}}
19
+ ---
20
+ -- @internal
21
+ function ____exports.runNextRoomInit(self, mod)
22
+ saveDataManager(
23
+ nil,
24
+ FEATURE_NAME,
25
+ v,
26
+ function() return false end
27
+ )
28
+ mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
29
+ end
30
+ --- Supply a function to run on the next `POST_NEW_ROOM` callback.
31
+ --
32
+ -- Note that this function will not handle saving and quitting. If a player saving and quitting
33
+ -- before the deferred function fires would cause a bug in your mod, then you should handle deferred
34
+ -- functions manually using serializable data.
35
+ function ____exports.runNextRoom(self, func)
36
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
37
+ local ____v_run_queuedFunctions_0 = v.run.queuedFunctions
38
+ ____v_run_queuedFunctions_0[#____v_run_queuedFunctions_0 + 1] = func
39
+ end
40
+ return ____exports
@@ -11,8 +11,6 @@ local ____deepCopy = require("functions.deepCopy")
11
11
  local deepCopy = ____deepCopy.deepCopy
12
12
  local ____types = require("functions.types")
13
13
  local isString = ____types.isString
14
- local ____constants = require("features.saveDataManager.constants")
15
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
16
14
  local ____main = require("features.saveDataManager.main")
17
15
  local forceSaveDataManagerLoad = ____main.forceSaveDataManagerLoad
18
16
  local forceSaveDataManagerSave = ____main.forceSaveDataManagerSave
@@ -21,6 +19,8 @@ local ____maps = require("features.saveDataManager.maps")
21
19
  local saveDataConditionalFuncMap = ____maps.saveDataConditionalFuncMap
22
20
  local saveDataDefaultsMap = ____maps.saveDataDefaultsMap
23
21
  local saveDataMap = ____maps.saveDataMap
22
+ local ____saveDataManagerConstants = require("features.saveDataManager.saveDataManagerConstants")
23
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
24
24
  --- This is the entry point to the save data manager, a system which provides two major features:
25
25
  --
26
26
  -- 1. automatic resetting of variables on a new run, on a new level, or on a new room (as desired)
@@ -12,11 +12,11 @@ local iterateTableInOrder = ____table.iterateTableInOrder
12
12
  local ____types = require("functions.types")
13
13
  local isString = ____types.isString
14
14
  local isTable = ____types.isTable
15
- local ____constants = require("features.saveDataManager.constants")
16
- local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
17
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
18
15
  local ____merge = require("features.saveDataManager.merge")
19
16
  local merge = ____merge.merge
17
+ local ____saveDataManagerConstants = require("features.saveDataManager.saveDataManagerConstants")
18
+ local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
19
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
20
20
  function readSaveDatFile(self, mod)
21
21
  local renderFrameCount = Isaac.GetFrameCount()
22
22
  local ok, jsonStringOrErrMsg = pcall(tryLoadModData, mod)
@@ -21,9 +21,6 @@ local logError = ____log.logError
21
21
  local ____table = require("functions.table")
22
22
  local clearTable = ____table.clearTable
23
23
  local iterateTableInOrder = ____table.iterateTableInOrder
24
- local ____constants = require("features.saveDataManager.constants")
25
- local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
26
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
27
24
  local ____load = require("features.saveDataManager.load")
28
25
  local loadFromDisk = ____load.loadFromDisk
29
26
  local ____maps = require("features.saveDataManager.maps")
@@ -32,6 +29,9 @@ local saveDataDefaultsMap = ____maps.saveDataDefaultsMap
32
29
  local saveDataMap = ____maps.saveDataMap
33
30
  local ____save = require("features.saveDataManager.save")
34
31
  local saveToDisk = ____save.saveToDisk
32
+ local ____saveDataManagerConstants = require("features.saveDataManager.saveDataManagerConstants")
33
+ local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
34
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
35
35
  function postPlayerInit(self)
36
36
  if mod == nil then
37
37
  error(("The mod for the " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " was not initialized.")
@@ -26,8 +26,8 @@ local ____types = require("functions.types")
26
26
  local isTable = ____types.isTable
27
27
  local ____utils = require("functions.utils")
28
28
  local getTraversalDescription = ____utils.getTraversalDescription
29
- local ____constants = require("features.saveDataManager.constants")
30
- local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
29
+ local ____saveDataManagerConstants = require("features.saveDataManager.saveDataManagerConstants")
30
+ local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
31
31
  local ____serializationBrand = require("features.saveDataManager.serializationBrand")
32
32
  local isSerializationBrand = ____serializationBrand.isSerializationBrand
33
33
  --- `merge` takes the values from a new table and recursively merges them into an old object (while
@@ -13,9 +13,9 @@ local ____log = require("functions.log")
13
13
  local log = ____log.log
14
14
  local ____table = require("functions.table")
15
15
  local iterateTableInOrder = ____table.iterateTableInOrder
16
- local ____constants = require("features.saveDataManager.constants")
17
- local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
18
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
16
+ local ____saveDataManagerConstants = require("features.saveDataManager.saveDataManagerConstants")
17
+ local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
18
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
19
19
  function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
20
20
  local allSaveData = {}
21
21
  iterateTableInOrder(
@@ -1,7 +1,5 @@
1
1
  local ____exports = {}
2
2
  local getChargeBarClamp
3
- local ____constants = require("constants")
4
- local VectorZero = ____constants.VectorZero
5
3
  function getChargeBarClamp(self, charges, maxCharges)
6
4
  local meterMultiplier = 24 / maxCharges
7
5
  local meterClip = 26 - charges * meterMultiplier
@@ -37,11 +35,11 @@ end
37
35
  --- Helper function to render a charge bar on the screen. First, call the `newChargeBarSprites`
38
36
  -- function to initialize the sprites, and then call this function on every render frame.
39
37
  function ____exports.renderChargeBar(self, sprites, position, normalCharges, batteryCharges)
40
- sprites.back:Render(position, VectorZero, VectorZero)
38
+ sprites.back:Render(position)
41
39
  local normalChargesClamp = getChargeBarClamp(nil, normalCharges, sprites.maxCharges)
42
- sprites.meter:Render(position, normalChargesClamp, VectorZero)
40
+ sprites.meter:Render(position, normalChargesClamp)
43
41
  local batteryChargesClamp = getChargeBarClamp(nil, batteryCharges, sprites.maxCharges)
44
- sprites.meterBattery:Render(position, batteryChargesClamp, VectorZero)
45
- sprites.lines:Render(position, VectorZero, VectorZero)
42
+ sprites.meterBattery:Render(position, batteryChargesClamp)
43
+ sprites.lines:Render(position)
46
44
  end
47
45
  return ____exports
@@ -19,8 +19,6 @@ export declare function colorEquals(color1: Color, color2: Color): boolean;
19
19
  */
20
20
  export declare function copyColor<C extends Color | SerializedColor, S extends SerializationType>(color: C, serializationType: S): CopyColorReturn[S];
21
21
  export declare function copyColor<C extends Color | SerializedColor>(color: C): CopyColorReturn[SerializationType.NONE];
22
- /** Returns `Color(1, 1, 1)`. */
23
- export declare function getDefaultColor(): Color;
24
22
  /** Helper function to check if something is an instantiated Color object. */
25
23
  export declare function isColor(object: unknown): object is Color;
26
24
  /**
@@ -104,10 +104,6 @@ function ____exports.copyColor(self, color, serializationType)
104
104
  end
105
105
  until true
106
106
  end
107
- --- Returns `Color(1, 1, 1)`.
108
- function ____exports.getDefaultColor(self)
109
- return Color(1, 1, 1)
110
- end
111
107
  --- Used to determine is the given table is a serialized `Color` object created by the save data
112
108
  -- manager and/or the `deepCopy` function.
113
109
  function ____exports.isSerializedColor(self, object)
@@ -15,8 +15,8 @@ local ____SerializationBrand = require("enums.private.SerializationBrand")
15
15
  local SerializationBrand = ____SerializationBrand.SerializationBrand
16
16
  local ____SerializationType = require("enums.SerializationType")
17
17
  local SerializationType = ____SerializationType.SerializationType
18
- local ____constants = require("features.saveDataManager.constants")
19
- local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
18
+ local ____saveDataManagerConstants = require("features.saveDataManager.saveDataManagerConstants")
19
+ local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
20
20
  local ____serializationBrand = require("features.saveDataManager.serializationBrand")
21
21
  local isSerializationBrand = ____serializationBrand.isSerializationBrand
22
22
  local ____array = require("functions.array")
@@ -8,5 +8,5 @@ import { Direction } from "isaac-typescript-definitions";
8
8
  */
9
9
  export declare function angleToDirection(angleDegrees: int): Direction;
10
10
  export declare function directionToDegrees(direction: Direction): int;
11
- export declare function directionToVector(direction: Direction): Vector;
11
+ export declare function directionToVector(direction: Direction): Readonly<Vector>;
12
12
  export declare function getDirectionName(direction: Direction): string | undefined;
@@ -22,7 +22,7 @@ export declare function getDevilRoomOrAngelRoomDoor(): GridEntityDoor | undefine
22
22
  * they would immediately collide with the loading zone. Instead, they are offset by a certain
23
23
  * amount of units.
24
24
  */
25
- export declare function getDoorEnterPosition(door: GridEntityDoor): Vector;
25
+ export declare function getDoorEnterPosition(door: GridEntityDoor): Readonly<Vector>;
26
26
  /**
27
27
  * Helper function to get the offset from a door position that a player will enter a room at.
28
28
  *
@@ -30,7 +30,7 @@ export declare function getDoorEnterPosition(door: GridEntityDoor): Vector;
30
30
  * they would immediately collide with the loading zone. Instead, they are offset by a certain
31
31
  * amount of units.
32
32
  */
33
- export declare function getDoorSlotEnterPositionOffset(doorSlot: DoorSlot): Vector;
33
+ export declare function getDoorSlotEnterPositionOffset(doorSlot: DoorSlot): Readonly<Vector>;
34
34
  /**
35
35
  * Helper function to convert an array of door slots or a set of door slots to the resulting bit
36
36
  * flag number.
@@ -72,6 +72,11 @@ export declare function getEntities(entityType?: EntityType, variant?: number, s
72
72
  export declare function getEntityFields(entity: Entity): LuaTable<string, boolean | number | string>;
73
73
  /** Helper function to return a string containing the entity's type, variant, and sub-type. */
74
74
  export declare function getEntityID(entity: Entity): string;
75
+ /**
76
+ * Helper function to return a formatted string in the format returned by the `getEntityID`
77
+ * function.
78
+ */
79
+ export declare function getEntityIDFromConstituents(entityType: EntityType, variant: int, subType: int): string;
75
80
  /**
76
81
  * Helper function to compare two different arrays of entities. Returns the entities that are in the
77
82
  * second array but not in the first array.
@@ -202,6 +202,11 @@ end
202
202
  function ____exports.getEntityID(self, entity)
203
203
  return (((tostring(entity.Type) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType)
204
204
  end
205
+ --- Helper function to return a formatted string in the format returned by the `getEntityID`
206
+ -- function.
207
+ function ____exports.getEntityIDFromConstituents(self, entityType, variant, subType)
208
+ return (((tostring(entityType) .. ".") .. tostring(variant)) .. ".") .. tostring(subType)
209
+ end
205
210
  --- Helper function to compare two different arrays of entities. Returns the entities that are in the
206
211
  -- second array but not in the first array.
207
212
  function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
@@ -349,6 +354,14 @@ function ____exports.spawn(self, entityType, variant, subType, position, velocit
349
354
  if seedOrRNG == nil then
350
355
  seedOrRNG = nil
351
356
  end
357
+ if position == nil then
358
+ local entityID = ____exports.getEntityIDFromConstituents(nil, entityType, variant, subType)
359
+ error(("Failed to spawn entity " .. entityID) .. " since an undefined position was passed to the \"spawn\" function.")
360
+ end
361
+ if velocity == nil then
362
+ local entityID = ____exports.getEntityIDFromConstituents(nil, entityType, variant, subType)
363
+ error(("Failed to spawn entity " .. entityID) .. " since an undefined velocity was passed to the \"spawn\" function.")
364
+ end
352
365
  if seedOrRNG == nil then
353
366
  return Isaac.Spawn(
354
367
  entityType,
@@ -61,6 +61,11 @@ export declare function getGridEntitiesExcept(...gridEntityTypes: GridEntityType
61
61
  export declare function getGridEntitiesMap(...gridEntityTypes: GridEntityType[]): Map<int, GridEntity>;
62
62
  /** Helper function to return a string containing the grid entity's type and variant. */
63
63
  export declare function getGridEntityID(gridEntity: GridEntity): string;
64
+ /**
65
+ * Helper function to return a formatted string in the format returned by the `getGridEntityID`
66
+ * function.
67
+ */
68
+ export declare function getGridEntityIDFromConstituents(gridEntityType: GridEntityType, variant: int): string;
64
69
  /**
65
70
  * Helper function to get all of the grid entities in the room that specifically match the type and
66
71
  * variant provided.
@@ -238,8 +238,13 @@ end
238
238
  --- Helper function to return a string containing the grid entity's type and variant.
239
239
  function ____exports.getGridEntityID(self, gridEntity)
240
240
  local gridEntityType = gridEntity:GetType()
241
- local gridEntityVariant = gridEntity:GetVariant()
242
- return (tostring(gridEntityType) .. ".") .. tostring(gridEntityVariant)
241
+ local variant = gridEntity:GetVariant()
242
+ return (tostring(gridEntityType) .. ".") .. tostring(variant)
243
+ end
244
+ --- Helper function to return a formatted string in the format returned by the `getGridEntityID`
245
+ -- function.
246
+ function ____exports.getGridEntityIDFromConstituents(self, gridEntityType, variant)
247
+ return (tostring(gridEntityType) .. ".") .. tostring(variant)
243
248
  end
244
249
  --- Helper function to get all of the grid entities in the room that specifically match the type and
245
250
  -- variant provided.
@@ -18,8 +18,6 @@ interface CopyKColorReturn {
18
18
  */
19
19
  export declare function copyKColor<K extends KColor | SerializedKColor, S extends SerializationType>(kColor: K, serializationType: S): CopyKColorReturn[S];
20
20
  export declare function copyKColor<K extends KColor | SerializedKColor>(kColor: K): CopyKColorReturn[SerializationType.NONE];
21
- /** Returns `KColor(1, 1, 1, 1)`. */
22
- export declare function getDefaultKColor(): KColor;
23
21
  /** Helper function to check if something is an instantiated KColor object. */
24
22
  export declare function isKColor(object: unknown): object is KColor;
25
23
  /**
@@ -80,10 +80,6 @@ function ____exports.copyKColor(self, kColor, serializationType)
80
80
  end
81
81
  until true
82
82
  end
83
- --- Returns `KColor(1, 1, 1, 1)`.
84
- function ____exports.getDefaultKColor(self)
85
- return KColor(1, 1, 1, 1)
86
- end
87
83
  --- Used to determine is the given table is a serialized `KColor` object created by the save data
88
84
  -- manager and/or the `deepCopy` function.
89
85
  function ____exports.isSerializedKColor(self, object)
package/functions/log.lua CHANGED
@@ -247,7 +247,8 @@ function ____exports.logEntityFlags(flags)
247
247
  ____exports.logFlags(flags, EntityFlag, "entity")
248
248
  end
249
249
  function ____exports.logEntityID(entity)
250
- ____exports.log((((("Entity: " .. tostring(entity.Type)) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType))
250
+ local entityID = getEntityID(nil, entity)
251
+ ____exports.log("Entity: " .. entityID)
251
252
  end
252
253
  --- Helper function to log an error message and also print it to the console for better visibility.
253
254
  --
@@ -1,5 +1,9 @@
1
1
  /**
2
- * Helper function to move all of the players to the center of the room.
2
+ * Helper function to move all of the players to where they would normally go when arriving at a new
3
+ * floor. (In normal mode, this is the center of the room. In Greed Mode, this is below the top
4
+ * door.)
5
+ *
6
+ * If there is more than one player, they will be distributed around the center in a circle.
3
7
  *
4
8
  * This function emulates what happens in the vanilla game when you travel to a new floor.
5
9
  */
@@ -4,6 +4,9 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
4
4
  local Direction = ____isaac_2Dtypescript_2Ddefinitions.Direction
5
5
  local ____cachedClasses = require("cachedClasses")
6
6
  local game = ____cachedClasses.game
7
+ local ____constants = require("constants")
8
+ local NEW_FLOOR_STARTING_POSITION_GREED_MODE = ____constants.NEW_FLOOR_STARTING_POSITION_GREED_MODE
9
+ local NEW_FLOOR_STARTING_POSITION_NORMAL_MODE = ____constants.NEW_FLOOR_STARTING_POSITION_NORMAL_MODE
7
10
  local ____familiars = require("functions.familiars")
8
11
  local getPlayerFamiliars = ____familiars.getPlayerFamiliars
9
12
  local ____math = require("functions.math")
@@ -18,24 +21,28 @@ function movePlayerAndTheirFamiliars(self, player, position)
18
21
  end
19
22
  end
20
23
  local CIRCLE_RADIUS_BETWEEN_PLAYERS = 50
21
- --- Helper function to move all of the players to the center of the room.
24
+ --- Helper function to move all of the players to where they would normally go when arriving at a new
25
+ -- floor. (In normal mode, this is the center of the room. In Greed Mode, this is below the top
26
+ -- door.)
27
+ --
28
+ -- If there is more than one player, they will be distributed around the center in a circle.
22
29
  --
23
30
  -- This function emulates what happens in the vanilla game when you travel to a new floor.
24
31
  function ____exports.movePlayersToCenter(self)
25
- local room = game:GetRoom()
26
- local centerPos = room:GetCenterPos()
32
+ local isGreedMode = game:IsGreedMode()
33
+ local startingPosition = isGreedMode and NEW_FLOOR_STARTING_POSITION_GREED_MODE or NEW_FLOOR_STARTING_POSITION_NORMAL_MODE
27
34
  local players = getPlayers(nil)
28
35
  local firstPlayer = players[1]
29
36
  if firstPlayer == nil then
30
37
  return
31
38
  end
32
39
  if #players == 1 then
33
- movePlayerAndTheirFamiliars(nil, firstPlayer, centerPos)
40
+ movePlayerAndTheirFamiliars(nil, firstPlayer, startingPosition)
34
41
  return
35
42
  end
36
43
  local circlePoints = getCircleDiscretizedPoints(
37
44
  nil,
38
- centerPos,
45
+ startingPosition,
39
46
  CIRCLE_RADIUS_BETWEEN_PLAYERS,
40
47
  #players,
41
48
  1,
@@ -46,9 +53,9 @@ function ____exports.movePlayersToCenter(self)
46
53
  local i = 0
47
54
  while i < #players do
48
55
  local player = players[i + 1]
49
- local position = circlePoints[i + 1]
50
- if player ~= nil and position ~= nil then
51
- player.Position = position
56
+ local circlePosition = circlePoints[i + 1]
57
+ if player ~= nil and circlePosition ~= nil then
58
+ player.Position = circlePosition
52
59
  end
53
60
  i = i + 1
54
61
  end
@@ -44,6 +44,9 @@ export declare function getPlayerIndex(player: EntityPlayer, differentiateForgot
44
44
  /**
45
45
  * Helper function to return the index of this player with respect to the output of the
46
46
  * `Isaac.GetPlayer` method.
47
+ *
48
+ * Note that if you storing information about a player in a data structure, you never want to use
49
+ * this index; use the `getPlayerIndex` function instead.
47
50
  */
48
51
  export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int | undefined;
49
52
  /**
@@ -155,6 +155,9 @@ function ____exports.getPlayerFromIndex(self, playerIndex)
155
155
  end
156
156
  --- Helper function to return the index of this player with respect to the output of the
157
157
  -- `Isaac.GetPlayer` method.
158
+ --
159
+ -- Note that if you storing information about a player in a data structure, you never want to use
160
+ -- this index; use the `getPlayerIndex` function instead.
158
161
  function ____exports.getPlayerIndexVanilla(self, playerToFind)
159
162
  local numPlayers = game:GetNumPlayers()
160
163
  local playerToFindHash = GetPtrHash(playerToFind)
@@ -1,4 +1,5 @@
1
1
  import { DoorSlot, RoomShape } from "isaac-typescript-definitions";
2
+ import { Corner } from "../interfaces/Corner";
2
3
  /**
3
4
  * Helper function to get the grid index delta that a door out of the given room shape would lead
4
5
  * to. For example, if you went through the bottom door in a room of `RoomShape.SHAPE_1x2`, you
@@ -12,7 +13,7 @@ export declare function getGridIndexDelta(roomShape: RoomShape, doorSlot: DoorSl
12
13
  *
13
14
  * For example, `RoomShape.SHAPE_2x2` will return 2.
14
15
  */
15
- export declare function getRoomShapeBottomRightPosition(roomShape: RoomShape): Vector;
16
+ export declare function getRoomShapeBottomRightPosition(roomShape: RoomShape): Readonly<Vector>;
16
17
  /**
17
18
  * Helper function to get the grid position of the bottom-right tile of a given room shape.
18
19
  *
@@ -21,10 +22,14 @@ export declare function getRoomShapeBottomRightPosition(roomShape: RoomShape): V
21
22
  */
22
23
  export declare function getRoomShapeBounds(roomShape: RoomShape): readonly [width: int, height: int];
23
24
  /**
24
- * Helper function to get the bounds of a room shape, which are a box representing its contents.
25
- * This does not include the tiles that the walls are on. L rooms use the same bounds as a 2x2 room.
25
+ * Helper function to get the number of charges that a given room shape will grant to a player upon
26
+ * clearing it.
27
+ *
28
+ * For example, `RoomShape.SHAPE_2x2` will return 2.
26
29
  */
27
30
  export declare function getRoomShapeCharges(roomShape: RoomShape): int;
31
+ /** Helper function to get the corners that exist in the given room shape. */
32
+ export declare function getRoomShapeCorners(roomShape: RoomShape): readonly Corner[];
28
33
  /**
29
34
  * Helper function to get the dimensions of a room shape's layout. This is NOT the size of the
30
35
  * room's actual contents! For that, use the `getRoomShapeBounds` function.
@@ -38,7 +43,7 @@ export declare function getRoomShapeLayoutSize(roomShape: RoomShape): readonly [
38
43
  * "Vector(0, 0)" corresponds to the top left tile of a room, not including the walls. (The top-left
39
44
  * wall would be at "Vector(-1, -1)".)
40
45
  */
41
- export declare function getRoomShapeTopLeftPosition(roomShape: RoomShape): Vector;
46
+ export declare function getRoomShapeTopLeftPosition(roomShape: RoomShape): Readonly<Vector>;
42
47
  /**
43
48
  * Helper function to get the volume of a room shape, which is the amount of tiles that are inside
44
49
  * the room.
@@ -48,6 +53,7 @@ export declare function getRoomShapeTopLeftPosition(roomShape: RoomShape): Vecto
48
53
  export declare function getRoomShapeVolume(roomShape: RoomShape): int;
49
54
  export declare function getRoomShapeWidth(roomShape: RoomShape): int;
50
55
  export declare function isLRoom(roomShape: RoomShape): boolean;
56
+ export declare function isNarrowRoom(roomShape: RoomShape): boolean;
51
57
  /**
52
58
  * Helper function to see if a given room shape will grant a single charge or a double charge to the
53
59
  * player's active item(s).
@@ -5,6 +5,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
5
5
  local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
6
6
  local ____roomShapeBounds = require("objects.roomShapeBounds")
7
7
  local ROOM_SHAPE_BOUNDS = ____roomShapeBounds.ROOM_SHAPE_BOUNDS
8
+ local ____roomShapeCorners = require("objects.roomShapeCorners")
9
+ local ROOM_SHAPE_CORNERS = ____roomShapeCorners.ROOM_SHAPE_CORNERS
8
10
  local ____roomShapeLayoutSizes = require("objects.roomShapeLayoutSizes")
9
11
  local ROOM_SHAPE_LAYOUT_SIZES = ____roomShapeLayoutSizes.ROOM_SHAPE_LAYOUT_SIZES
10
12
  local ____roomShapeToBottomRightPosition = require("objects.roomShapeToBottomRightPosition")
@@ -19,6 +21,8 @@ local ____roomShapeVolumes = require("objects.roomShapeVolumes")
19
21
  local ROOM_SHAPE_VOLUMES = ____roomShapeVolumes.ROOM_SHAPE_VOLUMES
20
22
  local ____LRoomShapesSet = require("sets.LRoomShapesSet")
21
23
  local L_ROOM_SHAPES_SET = ____LRoomShapesSet.L_ROOM_SHAPES_SET
24
+ local ____narrowRoomShapesSet = require("sets.narrowRoomShapesSet")
25
+ local NARROW_ROOM_SHAPES_SET = ____narrowRoomShapesSet.NARROW_ROOM_SHAPES_SET
22
26
  --- Helper function to see if a given room shape will grant a single charge or a double charge to the
23
27
  -- player's active item(s).
24
28
  --
@@ -48,11 +52,17 @@ end
48
52
  function ____exports.getRoomShapeBounds(self, roomShape)
49
53
  return ROOM_SHAPE_BOUNDS[roomShape]
50
54
  end
51
- --- Helper function to get the bounds of a room shape, which are a box representing its contents.
52
- -- This does not include the tiles that the walls are on. L rooms use the same bounds as a 2x2 room.
55
+ --- Helper function to get the number of charges that a given room shape will grant to a player upon
56
+ -- clearing it.
57
+ --
58
+ -- For example, `RoomShape.SHAPE_2x2` will return 2.
53
59
  function ____exports.getRoomShapeCharges(self, roomShape)
54
60
  return ____exports.isRoomShapeDoubleCharge(nil, roomShape) and 2 or 1
55
61
  end
62
+ --- Helper function to get the corners that exist in the given room shape.
63
+ function ____exports.getRoomShapeCorners(self, roomShape)
64
+ return ROOM_SHAPE_CORNERS[roomShape]
65
+ end
56
66
  --- Helper function to get the dimensions of a room shape's layout. This is NOT the size of the
57
67
  -- room's actual contents! For that, use the `getRoomShapeBounds` function.
58
68
  --
@@ -80,4 +90,7 @@ end
80
90
  function ____exports.isLRoom(self, roomShape)
81
91
  return L_ROOM_SHAPES_SET:has(roomShape)
82
92
  end
93
+ function ____exports.isNarrowRoom(self, roomShape)
94
+ return NARROW_ROOM_SHAPES_SET:has(roomShape)
95
+ end
83
96
  return ____exports
@@ -2,7 +2,7 @@
2
2
  /// <reference types="isaac-typescript-definitions" />
3
3
  /// <reference types="isaac-typescript-definitions" />
4
4
  /**
5
- * Helper function to clear a specific layer from a sprite.
5
+ * Helper function to clear all layers or specific layers from a sprite.
6
6
  *
7
7
  * This function is variadic, so pass as many layer IDs as you want to clear. If no specific layers
8
8
  * are passed, it will clear every layer.
@@ -12,7 +12,7 @@ function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
12
12
  local kColor2 = sprite2:GetTexel(position, VectorZero, 1, layerID)
13
13
  return kColorEquals(nil, kColor1, kColor2)
14
14
  end
15
- --- Helper function to clear a specific layer from a sprite.
15
+ --- Helper function to clear all layers or specific layers from a sprite.
16
16
  --
17
17
  -- This function is variadic, so pass as many layer IDs as you want to clear. If no specific layers
18
18
  -- are passed, it will clear every layer.
package/functions/ui.d.ts CHANGED
@@ -23,9 +23,11 @@ export declare function getHeartRowLength(player: EntityPlayer): int;
23
23
  * combination with the the `getHUDOffsetVector` helper function.
24
24
  */
25
25
  export declare function getHeartsUIWidth(): int;
26
+ export declare function getScreenBottomCenterPos(): Vector;
26
27
  export declare function getScreenBottomLeftPos(): Vector;
27
28
  export declare function getScreenBottomRightPos(): Vector;
28
29
  export declare function getScreenCenterPos(): Vector;
30
+ export declare function getScreenTopCenterPos(): Vector;
29
31
  export declare function getScreenTopLeftPos(): Vector;
30
32
  export declare function getScreenTopRightPos(): Vector;
31
33
  /**
package/functions/ui.lua CHANGED
@@ -79,6 +79,10 @@ function ____exports.getHeartsUIWidth(self)
79
79
  end
80
80
  return width
81
81
  end
82
+ function ____exports.getScreenBottomCenterPos(self)
83
+ local bottomRight = ____exports.getScreenBottomRightPos(nil)
84
+ return Vector(bottomRight.X / 2, bottomRight.Y)
85
+ end
82
86
  function ____exports.getScreenBottomLeftPos(self)
83
87
  local bottomRight = ____exports.getScreenBottomRightPos(nil)
84
88
  return Vector(0, bottomRight.Y)
@@ -87,6 +91,10 @@ function ____exports.getScreenCenterPos(self)
87
91
  local bottomRight = ____exports.getScreenBottomRightPos(nil)
88
92
  return bottomRight / 2
89
93
  end
94
+ function ____exports.getScreenTopCenterPos(self)
95
+ local bottomRight = ____exports.getScreenBottomRightPos(nil)
96
+ return Vector(bottomRight.X / 2, 0)
97
+ end
90
98
  function ____exports.getScreenTopLeftPos(self)
91
99
  return copyVector(nil, VectorZero)
92
100
  end