isaacscript-common 2.3.2 → 3.0.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.
- package/cachedClasses.lua +24 -0
- package/callbacks/customRevive.lua +2 -0
- package/callbacks/itemPickup.lua +2 -0
- package/callbacks/postBombInitLate.lua +2 -0
- package/callbacks/postBoneSwing.lua +2 -0
- package/callbacks/postCollectibleInitFirst.lua +2 -0
- package/callbacks/postCursedTeleport.lua +2 -0
- package/callbacks/postCustomDoorEnter.lua +44 -0
- package/callbacks/postDoorRender.lua +2 -0
- package/callbacks/postDoorUpdate.lua +2 -0
- package/callbacks/postEffectInitLate.lua +2 -0
- package/callbacks/postEffectStateChanged.lua +2 -0
- package/callbacks/postEsauJr.lua +2 -0
- package/callbacks/postFamiliarInitLate.lua +2 -0
- package/callbacks/postFamiliarStateChanged.lua +2 -0
- package/callbacks/postFlip.lua +2 -0
- package/callbacks/postGreedModeWave.lua +2 -0
- package/callbacks/postGridEntity.lua +2 -0
- package/callbacks/postGridEntityCollision.lua +2 -0
- package/callbacks/postGridEntityRender.lua +2 -0
- package/callbacks/postHolyMantleRemoved.lua +2 -0
- package/callbacks/postKnifeInitLate.lua +2 -0
- package/callbacks/postLaserInitLate.lua +2 -0
- package/callbacks/postNPCInitLate.lua +2 -0
- package/callbacks/postNPCStateChanged.lua +2 -0
- package/callbacks/postNewRoomEarly.lua +2 -0
- package/callbacks/postPickupCollect.lua +2 -0
- package/callbacks/postPickupInitLate.lua +2 -0
- package/callbacks/postPickupStateChanged.lua +2 -0
- package/callbacks/postPitRender.lua +2 -0
- package/callbacks/postPitUpdate.lua +2 -0
- package/callbacks/postPlayerChangeHealth.lua +2 -0
- package/callbacks/postPlayerChangeType.lua +2 -0
- package/callbacks/postPlayerFatalDamage.lua +2 -0
- package/callbacks/postPlayerInitLate.lua +2 -0
- package/callbacks/postPlayerReordered.lua +2 -0
- package/callbacks/postPoopRender.lua +2 -0
- package/callbacks/postPoopUpdate.lua +2 -0
- package/callbacks/postPressurePlateRender.lua +2 -0
- package/callbacks/postPressurePlateUpdate.lua +2 -0
- package/callbacks/postProjectileInitLate.lua +2 -0
- package/callbacks/postPurchase.lua +2 -0
- package/callbacks/postRockRender.lua +2 -0
- package/callbacks/postRockUpdate.lua +2 -0
- package/callbacks/postRoomClearChanged.lua +2 -0
- package/callbacks/postSacrifice.lua +2 -0
- package/callbacks/postSlotInitUpdate.lua +2 -0
- package/callbacks/postSlotRender.lua +2 -0
- package/callbacks/postSpikesRender.lua +2 -0
- package/callbacks/postSpikesUpdate.lua +2 -0
- package/callbacks/postTNTRender.lua +2 -0
- package/callbacks/postTNTUpdate.lua +2 -0
- package/callbacks/postTearInitLate.lua +2 -0
- package/callbacks/postTearInitVeryLate.lua +2 -0
- package/callbacks/postTransformation.lua +2 -0
- package/callbacks/postTrinketBreak.lua +2 -0
- package/callbacks/preBerserkDeath.lua +2 -0
- package/callbacks/preNewLevel.lua +2 -0
- package/callbacks/reorderedCallbacks.lua +16 -0
- package/callbacks/subscriptions/postBombInitLate.lua +6 -0
- package/callbacks/subscriptions/postBoneSwing.lua +6 -0
- package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
- package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
- package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
- package/callbacks/subscriptions/postCustomRevive.lua +6 -0
- package/callbacks/subscriptions/postDoorRender.lua +6 -0
- package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
- package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
- package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
- package/callbacks/subscriptions/postEsauJr.lua +6 -0
- package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
- package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
- package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
- package/callbacks/subscriptions/postFirstFlip.lua +6 -0
- package/callbacks/subscriptions/postFlip.lua +6 -0
- package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
- package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
- package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
- package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
- package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
- package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
- package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
- package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
- package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
- package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
- package/callbacks/subscriptions/postItemDischarged.lua +6 -0
- package/callbacks/subscriptions/postItemPickup.lua +6 -0
- package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
- package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
- package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
- package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
- package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
- package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
- package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
- package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
- package/callbacks/subscriptions/postPickupCollect.lua +6 -0
- package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
- package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
- package/callbacks/subscriptions/postPitRender.lua +6 -0
- package/callbacks/subscriptions/postPitUpdate.lua +6 -0
- package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
- package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
- package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
- package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
- package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
- package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
- package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
- package/callbacks/subscriptions/postPoopRender.lua +6 -0
- package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
- package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
- package/callbacks/subscriptions/postPurchase.lua +6 -0
- package/callbacks/subscriptions/postRockRender.lua +6 -0
- package/callbacks/subscriptions/postRockUpdate.lua +6 -0
- package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
- package/callbacks/subscriptions/postSacrifice.lua +6 -0
- package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
- package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
- package/callbacks/subscriptions/postSlotInit.lua +6 -0
- package/callbacks/subscriptions/postSlotRender.lua +6 -0
- package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
- package/callbacks/subscriptions/postSpikesRender.lua +6 -0
- package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
- package/callbacks/subscriptions/postTNTRender.lua +6 -0
- package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
- package/callbacks/subscriptions/postTearInitLate.lua +6 -0
- package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
- package/callbacks/subscriptions/postTransformation.lua +6 -0
- package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
- package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
- package/callbacks/subscriptions/preCustomRevive.lua +6 -0
- package/callbacks/subscriptions/preItemPickup.lua +6 -0
- package/callbacks/subscriptions/preNewLevel.lua +6 -0
- package/classes/DefaultMap.d.ts +70 -39
- package/classes/DefaultMap.lua +94 -43
- package/classes/ModUpgraded.d.ts +3 -3
- package/classes/ModUpgraded.lua +5 -0
- package/constants.lua +41 -0
- package/constantsFirstLast.lua +63 -0
- package/enums/HealthType.lua +3 -0
- package/enums/ModCallbackCustom.d.ts +1 -1
- package/enums/ModCallbackCustom.lua +6 -0
- package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
- package/enums/private/SerializationBrand.lua +5 -0
- package/features/characterHealthConversion.lua +6 -0
- package/features/characterStats.lua +17 -0
- package/features/debugDisplay/exports.lua +90 -0
- package/features/deployJSONRoom.lua +56 -0
- package/features/disableInputs.lua +45 -0
- package/features/disableSound.lua +14 -0
- package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
- package/features/extraConsoleCommands/init.lua +16 -0
- package/features/extraConsoleCommands/listCommands.lua +172 -0
- package/features/fadeInRemover.lua +10 -0
- package/features/fastReset.lua +10 -0
- package/features/forgottenSwitch.lua +4 -0
- package/features/getCollectibleItemPoolType.lua +5 -0
- package/features/playerInventory.lua +18 -0
- package/features/ponyDetection.lua +4 -0
- package/features/preventCollectibleRotation.lua +9 -0
- package/features/runInNFrames.lua +50 -0
- package/features/saveDataManager/constants.lua +1 -0
- package/features/saveDataManager/exports.lua +115 -0
- package/features/saveDataManager/main.lua +6 -0
- package/features/saveDataManager/maps.lua +3 -0
- package/features/saveDataManager/merge.lua +20 -0
- package/features/sirenHelpers.lua +13 -0
- package/features/taintedLazarusPlayers.lua +11 -0
- package/featuresInitialized.lua +6 -0
- package/functions/array.lua +85 -0
- package/functions/benchmark.lua +6 -0
- package/functions/boss.lua +35 -0
- package/functions/cacheFlag.lua +4 -0
- package/functions/cards.lua +60 -0
- package/functions/challenges.lua +1 -0
- package/functions/character.lua +23 -0
- package/functions/charge.lua +39 -0
- package/functions/chargeBar.lua +4 -0
- package/functions/collectibleCacheFlag.lua +15 -0
- package/functions/collectibleSet.lua +3 -0
- package/functions/collectibleTag.lua +9 -0
- package/functions/collectibles.lua +131 -0
- package/functions/color.lua +18 -0
- package/functions/debug.lua +18 -0
- package/functions/deepCopy.lua +25 -0
- package/functions/doors.lua +53 -0
- package/functions/entity.lua +88 -0
- package/functions/entitySpecific.lua +182 -0
- package/functions/entityTypes.d.ts +1 -1
- package/functions/entityTypes.lua +1 -0
- package/functions/enums.lua +62 -0
- package/functions/familiars.lua +52 -0
- package/functions/flag.lua +77 -0
- package/functions/flying.lua +10 -0
- package/functions/globals.lua +6 -0
- package/functions/gridEntity.lua +105 -0
- package/functions/gridEntitySpecific.lua +8 -0
- package/functions/input.lua +11 -0
- package/functions/isaacAPIClass.lua +12 -0
- package/functions/jsonHelpers.lua +11 -0
- package/functions/jsonRoom.lua +5 -0
- package/functions/kColor.lua +9 -0
- package/functions/language.lua +5 -0
- package/functions/log.lua +28 -0
- package/functions/map.lua +18 -0
- package/functions/math.lua +26 -0
- package/functions/npc.lua +24 -0
- package/functions/pickupVariants.d.ts +11 -11
- package/functions/pickupVariants.lua +11 -0
- package/functions/pickups.lua +67 -0
- package/functions/pills.lua +45 -0
- package/functions/player.lua +166 -0
- package/functions/playerDataStructures.lua +65 -0
- package/functions/playerHealth.lua +10 -0
- package/functions/playerIndex.lua +47 -0
- package/functions/pocketItems.lua +18 -0
- package/functions/positionVelocity.lua +46 -0
- package/functions/random.lua +32 -0
- package/functions/revive.lua +15 -0
- package/functions/rng.lua +19 -0
- package/functions/roomData.lua +68 -0
- package/functions/roomGrid.lua +21 -0
- package/functions/roomShape.lua +22 -0
- package/functions/rooms.lua +100 -0
- package/functions/run.lua +5 -0
- package/functions/seeds.lua +4 -0
- package/functions/serialization.lua +4 -0
- package/functions/set.lua +22 -0
- package/functions/spawnCollectible.lua +24 -0
- package/functions/sprite.lua +25 -0
- package/functions/stage.lua +16 -0
- package/functions/string.lua +6 -0
- package/functions/table.lua +19 -0
- package/functions/tears.lua +12 -0
- package/functions/transformations.lua +18 -0
- package/functions/trinketCacheFlag.lua +3 -0
- package/functions/trinketGive.lua +24 -0
- package/functions/trinkets.lua +52 -0
- package/functions/tstlClass.lua +9 -0
- package/functions/ui.lua +16 -0
- package/functions/utils.d.ts +1 -0
- package/functions/utils.lua +88 -0
- package/functions/vector.lua +9 -0
- package/lualib_bundle.lua +21 -34
- package/maps/cardMap.lua +1 -0
- package/maps/characterMap.lua +1 -0
- package/maps/defaultPlayerStatMap.lua +1 -0
- package/maps/gridEntityXMLMap.lua +2 -0
- package/maps/pillEffectMap.lua +1 -0
- package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
- package/maps/roomTypeMap.lua +1 -0
- package/objects/LRoomShapeToRectangles.lua +2 -0
- package/objects/colors.lua +4 -0
- package/objects/roomShapeBounds.lua +2 -0
- package/objects/roomShapeLayoutSizes.lua +4 -0
- package/objects/roomShapeToBottomRightPosition.lua +2 -0
- package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
- package/objects/roomShapeToTopLeftPosition.lua +2 -0
- package/objects/roomShapeVolumes.lua +3 -0
- package/package.json +2 -2
- package/patchErrorFunctions.lua +8 -0
- package/sets/bossSets.lua +23 -0
- package/sets/charactersWithNoRedHeartsSet.lua +2 -0
- package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
- package/sets/lostStyleCharactersSet.lua +2 -0
- package/types/PickingUpItem.lua +7 -0
- package/upgradeMod.d.ts +4 -4
- package/upgradeMod.lua +18 -0
|
@@ -44,6 +44,16 @@ function initQuestionMarkSprite(self)
|
|
|
44
44
|
sprite:LoadGraphics()
|
|
45
45
|
return sprite
|
|
46
46
|
end
|
|
47
|
+
--- Helper function to change the sprite of a collectible pedestal entity.
|
|
48
|
+
--
|
|
49
|
+
-- For more information about removing the collectible sprite, see the documentation for the
|
|
50
|
+
-- "clearSprite" helper function.
|
|
51
|
+
--
|
|
52
|
+
-- @param collectible The collectible whose sprite you want to modify.
|
|
53
|
+
-- @param pngPath Equal to either the spritesheet path to load (e.g.
|
|
54
|
+
-- "gfx/items/collectibles/collectibles_001_thesadonion.png") or undefined. If
|
|
55
|
+
-- undefined, the sprite will be removed, making it appear like the collectible has
|
|
56
|
+
-- already been taken by the player.
|
|
47
57
|
function ____exports.setCollectibleSprite(self, collectible, pngPath)
|
|
48
58
|
if not isCollectible(nil, collectible) then
|
|
49
59
|
local entityID = getEntityID(nil, collectible)
|
|
@@ -64,6 +74,7 @@ local questionMarkSprite = initQuestionMarkSprite(nil)
|
|
|
64
74
|
function ____exports.clearCollectibleSprite(self, collectible)
|
|
65
75
|
____exports.setCollectibleSprite(nil, collectible, nil)
|
|
66
76
|
end
|
|
77
|
+
--- Helper function to check if two collectible sprites have the same sprite sheet loaded.
|
|
67
78
|
function ____exports.collectibleSpriteEquals(self, sprite1, sprite2)
|
|
68
79
|
local xStart = -1
|
|
69
80
|
local xFinish = 1
|
|
@@ -84,6 +95,8 @@ function ____exports.collectibleSpriteEquals(self, sprite1, sprite2)
|
|
|
84
95
|
yIncrement
|
|
85
96
|
)
|
|
86
97
|
end
|
|
98
|
+
--- Helper function to get the in-game description for a collectible. Returns "Unknown" if the
|
|
99
|
+
-- provided collectible type was not valid.
|
|
87
100
|
function ____exports.getCollectibleDescription(self, collectibleType)
|
|
88
101
|
local collectibleDescription = COLLECTIBLE_DESCRIPTION_MAP:get(collectibleType)
|
|
89
102
|
if collectibleDescription ~= nil then
|
|
@@ -95,6 +108,8 @@ function ____exports.getCollectibleDescription(self, collectibleType)
|
|
|
95
108
|
end
|
|
96
109
|
return DEFAULT_COLLECTIBLE_DESCRIPTION
|
|
97
110
|
end
|
|
111
|
+
--- Helper function to get the heart cost that a collectible item would be if it were being offered
|
|
112
|
+
-- in a Devil Room deal. Returns 0 if passed CollectibleType.NULL.
|
|
98
113
|
function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player)
|
|
99
114
|
local maxHearts = player:GetMaxHearts()
|
|
100
115
|
if collectibleType == CollectibleType.NULL then
|
|
@@ -111,6 +126,8 @@ function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player
|
|
|
111
126
|
local twoHeartPrice = maxHearts == 2 and PickupPrice.ONE_HEART_AND_TWO_SOUL_HEARTS or PickupPrice.TWO_HEARTS
|
|
112
127
|
return itemConfigItem.DevilPrice == 2 and twoHeartPrice or PickupPrice.ONE_HEART
|
|
113
128
|
end
|
|
129
|
+
--- Helper function to get the path to a collectible's sprite. Returns the path to the question mark
|
|
130
|
+
-- sprite (i.e. from Curse of the Blind) if the provided collectible type was not valid.
|
|
114
131
|
function ____exports.getCollectibleGfxFilename(self, collectibleType)
|
|
115
132
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
116
133
|
if itemConfigItem == nil then
|
|
@@ -118,6 +135,41 @@ function ____exports.getCollectibleGfxFilename(self, collectibleType)
|
|
|
118
135
|
end
|
|
119
136
|
return itemConfigItem.GfxFileName
|
|
120
137
|
end
|
|
138
|
+
--- Mods often have to track variables relating to a collectible. Finding an index for these kinds of
|
|
139
|
+
-- data structures is difficult, since collectibles are respawned every time a player re-enters a
|
|
140
|
+
-- room, so the `PtrHash` will change. Instead, we use a 4-tuple of the room list index, the grid
|
|
141
|
+
-- index of the collectible in the room, the collectible's SubType, and the collectible's InitSeed.
|
|
142
|
+
--
|
|
143
|
+
-- Collectibles that are shifted by Tainted Isaac's mechanic will have unique collectible indexes
|
|
144
|
+
-- because the SubType is different. (The collectible entities share the same InitSeed.)
|
|
145
|
+
--
|
|
146
|
+
-- Collectibles that are rolled (with e.g. a D6) will have unique collectible indexes because the
|
|
147
|
+
-- SubType and InitSeed are different. If you want to track collectibles independently of any
|
|
148
|
+
-- rerolls, then you can use the `PtrHash` as an index instead. (The `PtrHash` will not persist
|
|
149
|
+
-- between rooms, however.)
|
|
150
|
+
--
|
|
151
|
+
-- Note that:
|
|
152
|
+
-- - The grid index is a necessary part of the collectible index because Diplopia and Crooked Penny
|
|
153
|
+
-- can cause two or more collectibles with the same SubType and InitSeed to exist in the same
|
|
154
|
+
-- room.
|
|
155
|
+
-- - This index will fail in the case where the player uses Diplopia or a successful Crooked Penny
|
|
156
|
+
-- seven or more times in the same room, since that will cause two or more collectibles with the
|
|
157
|
+
-- same grid index, SubType, and InitSeed to exist.
|
|
158
|
+
-- - The SubType is a necessary part of the collectible index because Tainted Isaac will
|
|
159
|
+
-- continuously cause collectibles to morph into new sub-types with the same InitSeed.
|
|
160
|
+
-- - Using a collectible's position as part of the index is problematic, since players can push a
|
|
161
|
+
-- pedestal. (Even using the grid index does not solve this problem, since it is possible in
|
|
162
|
+
-- certain cases for collectibles to be spawned at a position that is not aligned with the grid,
|
|
163
|
+
-- and the pedestal pushed to an adjacent tile, but this case should be extremely rare.)
|
|
164
|
+
-- - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
|
|
165
|
+
-- different InitSeeds, so this is not a problem for this indexing scheme.
|
|
166
|
+
-- - The indexing scheme used is different for collectibles that are inside of a Treasure Room, in
|
|
167
|
+
-- order to handle the case of the player seeing the same collectible again in a post-Ascent
|
|
168
|
+
-- Treasure Room. A 5-tuple of stage, stage type, grid index, SubType, and InitSeed is used in
|
|
169
|
+
-- this case. (Using the room list index or the room grid index is not suitable for this purpose,
|
|
170
|
+
-- since both of these values can change in the post-Ascent Treasure Room.) Even though there can
|
|
171
|
+
-- be two Treasure Rooms on an XL floor, both Treasure Rooms should not have collectibles with the
|
|
172
|
+
-- same grid index, Subtype, and InitSeed.
|
|
121
173
|
function ____exports.getCollectibleIndex(self, collectible)
|
|
122
174
|
if not isCollectible(nil, collectible) then
|
|
123
175
|
local entityID = getEntityID(nil, collectible)
|
|
@@ -135,6 +187,8 @@ function ____exports.getCollectibleIndex(self, collectible)
|
|
|
135
187
|
end
|
|
136
188
|
return (((((tostring(roomListIndex) .. ",") .. tostring(gridIndex)) .. ",") .. tostring(collectible.SubType)) .. ",") .. tostring(collectible.InitSeed)
|
|
137
189
|
end
|
|
190
|
+
--- Helper function to get the initial amount of charges that a collectible has. Returns 0 if the
|
|
191
|
+
-- provided collectible type was not valid.
|
|
138
192
|
function ____exports.getCollectibleInitCharge(self, collectibleType)
|
|
139
193
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
140
194
|
if itemConfigItem == nil then
|
|
@@ -142,6 +196,8 @@ function ____exports.getCollectibleInitCharge(self, collectibleType)
|
|
|
142
196
|
end
|
|
143
197
|
return itemConfigItem.InitCharge
|
|
144
198
|
end
|
|
199
|
+
--- Helper function to get the `ItemType` of a collectible. Returns `ItemType.ITEM_NULL` if the
|
|
200
|
+
-- provided collectible type was not valid.
|
|
145
201
|
function ____exports.getCollectibleItemType(self, collectibleType)
|
|
146
202
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
147
203
|
if itemConfigItem == nil then
|
|
@@ -149,6 +205,8 @@ function ____exports.getCollectibleItemType(self, collectibleType)
|
|
|
149
205
|
end
|
|
150
206
|
return itemConfigItem.Type
|
|
151
207
|
end
|
|
208
|
+
--- Helper function to get the maximum amount of charges that a collectible has. Returns 0 if the
|
|
209
|
+
-- provided collectible type was not valid.
|
|
152
210
|
function ____exports.getCollectibleMaxCharges(self, collectibleType)
|
|
153
211
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
154
212
|
if itemConfigItem == nil then
|
|
@@ -156,6 +214,15 @@ function ____exports.getCollectibleMaxCharges(self, collectibleType)
|
|
|
156
214
|
end
|
|
157
215
|
return itemConfigItem.MaxCharges
|
|
158
216
|
end
|
|
217
|
+
--- Helper function to get the name of a collectible. Returns "Unknown" if the provided collectible
|
|
218
|
+
-- type is not valid.
|
|
219
|
+
--
|
|
220
|
+
-- For example:
|
|
221
|
+
--
|
|
222
|
+
-- ```ts
|
|
223
|
+
-- const collectibleType = CollectibleType.SAD_ONION;
|
|
224
|
+
-- const collectibleName = getCollectibleName(collectibleType); // collectibleName is "Sad Onion"
|
|
225
|
+
-- ```
|
|
159
226
|
function ____exports.getCollectibleName(self, collectibleType)
|
|
160
227
|
local collectibleName = COLLECTIBLE_NAME_MAP:get(collectibleType)
|
|
161
228
|
if collectibleName ~= nil then
|
|
@@ -175,6 +242,8 @@ function ____exports.getCollectiblePedestalType(self, collectible)
|
|
|
175
242
|
local sprite = collectible:GetSprite()
|
|
176
243
|
return sprite:GetOverlayFrame()
|
|
177
244
|
end
|
|
245
|
+
--- Helper function to get the path to a collectible's quality. Returns 0 if the provided collectible
|
|
246
|
+
-- type was not valid.
|
|
178
247
|
function ____exports.getCollectibleQuality(self, collectibleType)
|
|
179
248
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
180
249
|
if itemConfigItem == nil then
|
|
@@ -182,26 +251,59 @@ function ____exports.getCollectibleQuality(self, collectibleType)
|
|
|
182
251
|
end
|
|
183
252
|
return itemConfigItem.Quality
|
|
184
253
|
end
|
|
254
|
+
--- Helper function to get the tags of a collectible (which is the composition of zero or more
|
|
255
|
+
-- `ItemConfigTag`). Returns 0 if the provided collectible type is not valid.
|
|
256
|
+
--
|
|
257
|
+
-- For example:
|
|
258
|
+
--
|
|
259
|
+
-- ```ts
|
|
260
|
+
-- const collectibleType = CollectibleType.SAD_ONION;
|
|
261
|
+
-- const itemConfigTags = getCollectibleTags(collectibleType); // itemConfigTags is "18350080"
|
|
262
|
+
-- ```
|
|
185
263
|
function ____exports.getCollectibleTags(self, collectibleType)
|
|
186
264
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
187
265
|
return itemConfigItem == nil and ItemConfigTagZero or itemConfigItem.Tags
|
|
188
266
|
end
|
|
267
|
+
--- Helper function to get an array that represents the range from the first collectible type to the
|
|
268
|
+
-- last collectible type. This will include integers that do not represent any valid collectible
|
|
269
|
+
-- types.
|
|
270
|
+
--
|
|
271
|
+
-- This function is only useful when building collectible type objects. For most purposes, you
|
|
272
|
+
-- should use the `getCollectibleSet` helper function instead.
|
|
189
273
|
function ____exports.getCollectibleTypeRange(self)
|
|
190
274
|
return irange(nil, FIRST_COLLECTIBLE_TYPE, LAST_COLLECTIBLE_TYPE)
|
|
191
275
|
end
|
|
276
|
+
--- Helper function to get an array that represents the all modded collectible types.
|
|
277
|
+
--
|
|
278
|
+
-- This function is only useful when building collectible type objects. For most purposes, you
|
|
279
|
+
-- should use the `getModdedCollectibleSet` helper function instead.
|
|
280
|
+
--
|
|
281
|
+
-- Returns an empty array if there are no modded collectible types.
|
|
282
|
+
--
|
|
283
|
+
-- (This function is named differently from the `getVanillaCollectibleTypeRange` function because
|
|
284
|
+
-- all modded collectible types are contiguous. Thus, each value represents a real
|
|
285
|
+
-- `CollectibleType`.)
|
|
192
286
|
function ____exports.getModdedCollectibleTypes(self)
|
|
193
287
|
if LAST_VANILLA_COLLECTIBLE_TYPE == LAST_COLLECTIBLE_TYPE then
|
|
194
288
|
return {}
|
|
195
289
|
end
|
|
196
290
|
return irange(nil, FIRST_MODDED_COLLECTIBLE_TYPE, LAST_COLLECTIBLE_TYPE)
|
|
197
291
|
end
|
|
292
|
+
--- Helper function to get an array that represents the range from the first collectible type to the
|
|
293
|
+
-- last vanilla collectible type. This will include integers that do not represent any valid
|
|
294
|
+
-- collectible types.
|
|
295
|
+
--
|
|
296
|
+
-- This function is only useful when building collectible type objects. For most purposes, you
|
|
297
|
+
-- should use the `getVanillaCollectibleSet` helper function instead.
|
|
198
298
|
function ____exports.getVanillaCollectibleTypeRange(self)
|
|
199
299
|
return irange(nil, FIRST_COLLECTIBLE_TYPE, LAST_VANILLA_COLLECTIBLE_TYPE)
|
|
200
300
|
end
|
|
301
|
+
--- Returns true if the item type in the item config is equal to `ItemType.ITEM_ACTIVE`.
|
|
201
302
|
function ____exports.isActiveCollectible(self, collectibleType)
|
|
202
303
|
local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
|
|
203
304
|
return itemType == ItemType.ACTIVE
|
|
204
305
|
end
|
|
306
|
+
--- Returns true if the collectible has a red question mark sprite.
|
|
205
307
|
function ____exports.isBlindCollectible(self, collectible)
|
|
206
308
|
if not isCollectible(nil, collectible) then
|
|
207
309
|
local entityID = getEntityID(nil, collectible)
|
|
@@ -213,17 +315,28 @@ function ____exports.isBlindCollectible(self, collectible)
|
|
|
213
315
|
questionMarkSprite:SetFrame(animation, frame)
|
|
214
316
|
return ____exports.collectibleSpriteEquals(nil, sprite, questionMarkSprite)
|
|
215
317
|
end
|
|
318
|
+
--- Returns whether or not the given collectible is a "glitched" item. All items are replaced by
|
|
319
|
+
-- glitched items once a player has TMTRAINER. However, glitched items can also "naturally" appear
|
|
320
|
+
-- in secret rooms and I AM ERROR rooms if the "Corrupted Data" achievement is unlocked.
|
|
216
321
|
function ____exports.isGlitchedCollectible(self, pickup)
|
|
217
322
|
return pickup.Variant == PickupVariant.COLLECTIBLE and pickup.SubType > GLITCHED_ITEM_THRESHOLD
|
|
218
323
|
end
|
|
324
|
+
--- Returns true if the collectible has the "Hidden" attribute in the item config.
|
|
325
|
+
--
|
|
326
|
+
-- Hidden collectibles will not show up in any pools and Eden will not start with them.
|
|
219
327
|
function ____exports.isHiddenCollectible(self, collectibleType)
|
|
220
328
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
221
329
|
return itemConfigItem ~= nil and itemConfigItem.Hidden
|
|
222
330
|
end
|
|
331
|
+
--- Returns true if the item type in the item config is equal to `ItemType.ITEM_PASSIVE` or
|
|
332
|
+
-- `ItemType.ITEM_FAMILIAR`.
|
|
223
333
|
function ____exports.isPassiveCollectible(self, collectibleType)
|
|
224
334
|
local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
|
|
225
335
|
return itemType == ItemType.PASSIVE or itemType == ItemType.FAMILIAR
|
|
226
336
|
end
|
|
337
|
+
--- Helper function to determine if a particular collectible will disappear from the player's
|
|
338
|
+
-- inventory upon use. Note that this will not work will modded items, as there is no way to
|
|
339
|
+
-- dynamically know if a modded item will disappear.
|
|
227
340
|
function ____exports.isSingleUseCollectible(self, collectibleType)
|
|
228
341
|
return SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES_SET:has(collectibleType)
|
|
229
342
|
end
|
|
@@ -231,10 +344,17 @@ function ____exports.isValidCollectibleType(self, collectibleType)
|
|
|
231
344
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
232
345
|
return itemConfigItem ~= nil
|
|
233
346
|
end
|
|
347
|
+
--- Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that it
|
|
348
|
+
-- should remove an item.
|
|
349
|
+
--
|
|
350
|
+
-- The "item tracker" in this function does not refer to the in-game item tracker, but rather to the
|
|
351
|
+
-- Python program located at: https://github.com/Rchardon/RebirthItemTracker
|
|
234
352
|
function ____exports.removeCollectibleFromItemTracker(self, collectibleType)
|
|
235
353
|
local collectibleName = ____exports.getCollectibleName(nil, collectibleType)
|
|
236
354
|
Isaac.DebugString(((("Removing collectible " .. tostring(collectibleType)) .. " (") .. collectibleName) .. ") on player 0 (Player)")
|
|
237
355
|
end
|
|
356
|
+
--- Helper function to remove all pickup delay on a collectible. By default, collectibles have a 20
|
|
357
|
+
-- frame delay before they can be picked up by a player.
|
|
238
358
|
function ____exports.removeCollectiblePickupDelay(self, collectible)
|
|
239
359
|
if not isCollectible(nil, collectible) then
|
|
240
360
|
local entityID = getEntityID(nil, collectible)
|
|
@@ -242,6 +362,8 @@ function ____exports.removeCollectiblePickupDelay(self, collectible)
|
|
|
242
362
|
end
|
|
243
363
|
collectible.Wait = 0
|
|
244
364
|
end
|
|
365
|
+
--- Helper function to set a collectible sprite to a question mark (i.e. how collectibles look when
|
|
366
|
+
-- the player has Curse of the Blind).
|
|
245
367
|
function ____exports.setCollectibleBlind(self, collectible)
|
|
246
368
|
if not isCollectible(nil, collectible) then
|
|
247
369
|
local entityID = getEntityID(nil, collectible)
|
|
@@ -249,6 +371,11 @@ function ____exports.setCollectibleBlind(self, collectible)
|
|
|
249
371
|
end
|
|
250
372
|
____exports.setCollectibleSprite(nil, collectible, BLIND_ITEM_PNG_PATH)
|
|
251
373
|
end
|
|
374
|
+
--- Helper function to remove the collectible from a collectible pedestal and make it appear as if a
|
|
375
|
+
-- player has already taken the item. This is accomplished by changing the sub-type to
|
|
376
|
+
-- `CollectibleType.NULL` and then setting the sprite to an empty/missing PNG file.
|
|
377
|
+
--
|
|
378
|
+
-- For more information, see the documentation for the "clearSprite" helper function.
|
|
252
379
|
function ____exports.setCollectibleEmpty(self, collectible)
|
|
253
380
|
if not isCollectible(nil, collectible) then
|
|
254
381
|
local entityID = getEntityID(nil, collectible)
|
|
@@ -257,6 +384,8 @@ function ____exports.setCollectibleEmpty(self, collectible)
|
|
|
257
384
|
collectible.SubType = CollectibleType.NULL
|
|
258
385
|
____exports.clearCollectibleSprite(nil, collectible)
|
|
259
386
|
end
|
|
387
|
+
--- Helper function to change the collectible on a pedestal. Simply updating the `SubType` property
|
|
388
|
+
-- is not sufficient because the sprite will not change.
|
|
260
389
|
function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
|
|
261
390
|
if not isCollectible(nil, collectible) then
|
|
262
391
|
local entityID = getEntityID(nil, collectible)
|
|
@@ -275,6 +404,8 @@ function ____exports.setCollectibleSubType(self, collectible, newCollectibleType
|
|
|
275
404
|
true
|
|
276
405
|
)
|
|
277
406
|
end
|
|
407
|
+
--- Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that
|
|
408
|
+
-- the build has been rerolled.
|
|
278
409
|
function ____exports.setCollectiblesRerolledForItemTracker(self)
|
|
279
410
|
Isaac.DebugString("Added 3 Collectibles")
|
|
280
411
|
end
|
package/functions/color.lua
CHANGED
|
@@ -13,6 +13,9 @@ local getNumbersFromTable = ____table.getNumbersFromTable
|
|
|
13
13
|
local tableHasKeys = ____table.tableHasKeys
|
|
14
14
|
local ____utils = require("functions.utils")
|
|
15
15
|
local ensureAllCases = ____utils.ensureAllCases
|
|
16
|
+
--- Helper function to check if something is an instantiated Color object.
|
|
17
|
+
--
|
|
18
|
+
-- @category color
|
|
16
19
|
function ____exports.isColor(self, object)
|
|
17
20
|
return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
|
|
18
21
|
end
|
|
@@ -26,9 +29,17 @@ local KEYS = {
|
|
|
26
29
|
"BO"
|
|
27
30
|
}
|
|
28
31
|
OBJECT_NAME = "Color"
|
|
32
|
+
---
|
|
33
|
+
-- @category color
|
|
29
34
|
function ____exports.colorEquals(self, color1, color2)
|
|
30
35
|
return isaacAPIClassEquals(nil, color1, color2, KEYS)
|
|
31
36
|
end
|
|
37
|
+
--- Helper function to copy a `Color` object.
|
|
38
|
+
--
|
|
39
|
+
-- @param color The Color object to copy. In the case of deserialization, this will actually be a
|
|
40
|
+
-- Lua table instead of an instantiated Color class.
|
|
41
|
+
-- @param serializationType Default is `SerializationType.NONE`.
|
|
42
|
+
-- @category color
|
|
32
43
|
function ____exports.copyColor(self, color, serializationType)
|
|
33
44
|
if serializationType == nil then
|
|
34
45
|
serializationType = SerializationType.NONE
|
|
@@ -104,9 +115,16 @@ function ____exports.copyColor(self, color, serializationType)
|
|
|
104
115
|
end
|
|
105
116
|
until true
|
|
106
117
|
end
|
|
118
|
+
--- Returns `Color(1, 1, 1)`.
|
|
119
|
+
--
|
|
120
|
+
-- @category color
|
|
107
121
|
function ____exports.getDefaultColor(self)
|
|
108
122
|
return Color(1, 1, 1)
|
|
109
123
|
end
|
|
124
|
+
--- Used to determine is the given table is a serialized `Color` object created by the save data
|
|
125
|
+
-- manager and/or the `deepCopy` function.
|
|
126
|
+
--
|
|
127
|
+
-- @category color
|
|
110
128
|
function ____exports.isSerializedColor(self, object)
|
|
111
129
|
local objectType = type(object)
|
|
112
130
|
if objectType ~= "table" then
|
package/functions/debug.lua
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local ____log = require("functions.log")
|
|
3
3
|
local log = ____log.log
|
|
4
|
+
--- Helper function to get a stack trace.
|
|
5
|
+
--
|
|
6
|
+
-- This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
|
|
7
|
+
-- enabled.
|
|
4
8
|
function ____exports.getTraceback(self)
|
|
5
9
|
if debug ~= nil then
|
|
6
10
|
return debug.traceback()
|
|
@@ -10,9 +14,23 @@ function ____exports.getTraceback(self)
|
|
|
10
14
|
end
|
|
11
15
|
return "stack traceback:\n(the \"--luadebug\" flag is not enabled)"
|
|
12
16
|
end
|
|
17
|
+
--- Players can boot the game with an launch option called "--luadebug", which will enable additional
|
|
18
|
+
-- functionality that is considered to be unsafe. For more information about this flag, see the
|
|
19
|
+
-- wiki: https://bindingofisaacrebirth.fandom.com/wiki/Launch_Options
|
|
20
|
+
--
|
|
21
|
+
-- When this flag is enabled, the global environment will be slightly different. The differences are
|
|
22
|
+
-- documented here: https://wofsauge.github.io/IsaacDocs/rep/Globals.html
|
|
23
|
+
--
|
|
24
|
+
-- This function uses the `package` global variable as a proxy to determine if the "--luadebug" flag
|
|
25
|
+
-- is enabled or not.
|
|
13
26
|
function ____exports.isLuaDebugEnabled(self)
|
|
14
27
|
return package ~= nil
|
|
15
28
|
end
|
|
29
|
+
--- Helper function to print a stack trace to the "log.txt" file, similar to JavaScript's
|
|
30
|
+
-- `console.trace` function.
|
|
31
|
+
--
|
|
32
|
+
-- This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
|
|
33
|
+
-- enabled.
|
|
16
34
|
function ____exports.traceback(self)
|
|
17
35
|
local tracebackOutput = ____exports.getTraceback(nil)
|
|
18
36
|
log(tracebackOutput)
|
package/functions/deepCopy.lua
CHANGED
|
@@ -39,6 +39,31 @@ local newTSTLClass = ____tstlClass.newTSTLClass
|
|
|
39
39
|
local ____utils = require("functions.utils")
|
|
40
40
|
local ensureAllCases = ____utils.ensureAllCases
|
|
41
41
|
local getTraversalDescription = ____utils.getTraversalDescription
|
|
42
|
+
--- `deepCopy` is a semi-generic deep cloner. It will recursively copy all of the values so that none
|
|
43
|
+
-- of the nested references remain.
|
|
44
|
+
--
|
|
45
|
+
-- It supports the following object types:
|
|
46
|
+
--
|
|
47
|
+
-- - Primitives (i.e. strings, numbers, and booleans)
|
|
48
|
+
-- - `LuaTable` / basic TSTL objects
|
|
49
|
+
-- - TSTL `Map`
|
|
50
|
+
-- - TSTL `Set`
|
|
51
|
+
-- - TSTL classes
|
|
52
|
+
-- - `DefaultMap`
|
|
53
|
+
-- - Isaac `Color` objects
|
|
54
|
+
-- - Isaac `KColor` objects
|
|
55
|
+
-- - Isaac `RNG` objects
|
|
56
|
+
-- - Isaac `Vector` objects
|
|
57
|
+
--
|
|
58
|
+
-- It does not support:
|
|
59
|
+
-- - objects with values of `null` (since that transpiles to `nil`)
|
|
60
|
+
-- - other Isaac API objects such as `EntityPtr` (that have a type of "userdata")
|
|
61
|
+
--
|
|
62
|
+
-- @param value The primitive or object to copy.
|
|
63
|
+
-- @param serializationType Has 3 possible values. Can leave objects as-is, or can serialize objects
|
|
64
|
+
-- to Lua tables, or can deserialize Lua tables to objects. Default is
|
|
65
|
+
-- `SerializationType.NONE`.
|
|
66
|
+
-- @param traversalDescription Used to track the current key that we are operating on.
|
|
42
67
|
function ____exports.deepCopy(self, value, serializationType, traversalDescription)
|
|
43
68
|
if serializationType == nil then
|
|
44
69
|
serializationType = SerializationType.NONE
|
package/functions/doors.lua
CHANGED
|
@@ -27,11 +27,19 @@ local getEnumValues = ____enums.getEnumValues
|
|
|
27
27
|
function ____exports.doorSlotToDirection(self, doorSlot)
|
|
28
28
|
return DOOR_SLOT_TO_DIRECTION[doorSlot]
|
|
29
29
|
end
|
|
30
|
+
--- Helper function to help calculate the position that a player will enter a room at.
|
|
31
|
+
--
|
|
32
|
+
-- When players enter a room, they do not appear exactly on the location of the door, because then
|
|
33
|
+
-- they would immediately collide with the loading zone. Instead, they are offset by a certain
|
|
34
|
+
-- amount of units.
|
|
30
35
|
function ____exports.getDoorEnterPositionOffset(self, doorSlot)
|
|
31
36
|
local direction = ____exports.doorSlotToDirection(nil, doorSlot)
|
|
32
37
|
local vector = directionToVector(nil, direction)
|
|
33
38
|
return vector * ROOM_ENTRY_OFFSET_FROM_DOOR
|
|
34
39
|
end
|
|
40
|
+
--- Helper function to get all of the doors in the room. By default, it will return every door. You
|
|
41
|
+
-- can optionally specify one or more room types to return only the doors that match the specified
|
|
42
|
+
-- room types.
|
|
35
43
|
function ____exports.getDoors(self, ...)
|
|
36
44
|
local roomTypes = {...}
|
|
37
45
|
local room = game:GetRoom()
|
|
@@ -60,10 +68,14 @@ function ____exports.isSecretRoomDoor(self, door)
|
|
|
60
68
|
local filename = sprite:GetFilename()
|
|
61
69
|
return filename == "gfx/grid/Door_08_HoleInWall.anm2"
|
|
62
70
|
end
|
|
71
|
+
--- Helper function to remove a single door.
|
|
63
72
|
function ____exports.removeDoor(self, door)
|
|
64
73
|
local room = game:GetRoom()
|
|
65
74
|
room:RemoveDoor(door.Slot)
|
|
66
75
|
end
|
|
76
|
+
--- Helper function to remove the doors provided.
|
|
77
|
+
--
|
|
78
|
+
-- This function is variadic, meaning that you can specify as many doors as you want to remove.
|
|
67
79
|
function ____exports.removeDoors(self, ...)
|
|
68
80
|
local doors = {...}
|
|
69
81
|
for ____, door in ipairs(doors) do
|
|
@@ -76,6 +88,8 @@ function ____exports.closeAllDoors(self)
|
|
|
76
88
|
door:Close(true)
|
|
77
89
|
end
|
|
78
90
|
end
|
|
91
|
+
--- Use this instead of the `GridEntityDoor.Close` method if you want the door to immediately close
|
|
92
|
+
-- without an animation.
|
|
79
93
|
function ____exports.closeDoorFast(self, door)
|
|
80
94
|
door.State = DoorState.CLOSED
|
|
81
95
|
local sprite = door:GetSprite()
|
|
@@ -105,6 +119,8 @@ function ____exports.getDevilRoomDoor(self)
|
|
|
105
119
|
end
|
|
106
120
|
return ____temp_1
|
|
107
121
|
end
|
|
122
|
+
--- If there is both a Devil Room and an Angel Room door, this function will return door with the
|
|
123
|
+
-- lowest slot number.
|
|
108
124
|
function ____exports.getDevilRoomOrAngelRoomDoor(self)
|
|
109
125
|
local devilRoomOrAngelRoomDoors = ____exports.getDoors(nil, RoomType.DEVIL, RoomType.ANGEL)
|
|
110
126
|
local ____temp_2
|
|
@@ -115,14 +131,24 @@ function ____exports.getDevilRoomOrAngelRoomDoor(self)
|
|
|
115
131
|
end
|
|
116
132
|
return ____temp_2
|
|
117
133
|
end
|
|
134
|
+
--- Helper function to get the position that a player will enter a room at.
|
|
135
|
+
--
|
|
136
|
+
-- When players enter a room, they do not appear exactly on the location of the door, because then
|
|
137
|
+
-- they would immediately collide with the loading zone. Instead, they are offset by a certain
|
|
138
|
+
-- amount of units.
|
|
118
139
|
function ____exports.getDoorEnterPosition(self, door)
|
|
119
140
|
local offset = ____exports.getDoorEnterPositionOffset(nil, door.Slot)
|
|
120
141
|
return door.Position + offset
|
|
121
142
|
end
|
|
143
|
+
--- Helper function to get the possible door slots that can exist for a given room shape.
|
|
122
144
|
function ____exports.getDoorSlotsForRoomShape(self, roomShape)
|
|
123
145
|
local doorSlots = ROOM_SHAPE_TO_DOOR_SLOTS[roomShape]
|
|
124
146
|
return doorSlots == nil and __TS__New(Set) or doorSlots
|
|
125
147
|
end
|
|
148
|
+
--- Helper function to get all of the doors in the room that lead to the provided room index.
|
|
149
|
+
--
|
|
150
|
+
-- This function is variadic, meaning that you can specify N arguments to return all of the doors
|
|
151
|
+
-- that match any of the N room grid indexes.
|
|
126
152
|
function ____exports.getDoorsToRoomIndex(self, ...)
|
|
127
153
|
local roomGridIndex = {...}
|
|
128
154
|
local roomGridIndexesSet = __TS__New(Set, roomGridIndex)
|
|
@@ -139,6 +165,7 @@ function ____exports.getRepentanceDoor(self)
|
|
|
139
165
|
function(____, door) return ____exports.isRepentanceDoor(nil, door) end
|
|
140
166
|
)
|
|
141
167
|
end
|
|
168
|
+
--- Helper function to find unused door slots in the room that can be used to make custom doors.
|
|
142
169
|
function ____exports.getUnusedDoorSlots(self)
|
|
143
170
|
local room = game:GetRoom()
|
|
144
171
|
local doorSlots = getEnumValues(nil, DoorSlot)
|
|
@@ -153,10 +180,13 @@ end
|
|
|
153
180
|
function ____exports.isDevilRoomDoor(self, door)
|
|
154
181
|
return door.TargetRoomType == RoomType.DEVIL
|
|
155
182
|
end
|
|
183
|
+
--- Helper function to see if a door slot could exist for a given room shape.
|
|
156
184
|
function ____exports.isDoorSlotInRoomShape(self, doorSlot, roomShape)
|
|
157
185
|
local doorSlots = ____exports.getDoorSlotsForRoomShape(nil, roomShape)
|
|
158
186
|
return doorSlots:has(doorSlot)
|
|
159
187
|
end
|
|
188
|
+
--- This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
|
|
189
|
+
-- to spend one key to open it. It has a sprite filename of "gfx/grid/Door_Downpour.anm2".
|
|
160
190
|
function ____exports.isDoorToDownpour(self, door)
|
|
161
191
|
if not ____exports.isRepentanceDoor(nil, door) then
|
|
162
192
|
return false
|
|
@@ -165,6 +195,8 @@ function ____exports.isDoorToDownpour(self, door)
|
|
|
165
195
|
local filename = sprite:GetFilename()
|
|
166
196
|
return filename == "gfx/grid/Door_Downpour.anm2"
|
|
167
197
|
end
|
|
198
|
+
--- This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
|
|
199
|
+
-- to spend two hearts to open it. It has a sprite filename of "gfx/grid/Door_Mausoleum.anm2".
|
|
168
200
|
function ____exports.isDoorToMausoleum(self, door)
|
|
169
201
|
if not ____exports.isRepentanceDoor(nil, door) then
|
|
170
202
|
return false
|
|
@@ -173,6 +205,8 @@ function ____exports.isDoorToMausoleum(self, door)
|
|
|
173
205
|
local filename = sprite:GetFilename()
|
|
174
206
|
return filename == "gfx/grid/Door_Mausoleum.anm2"
|
|
175
207
|
end
|
|
208
|
+
--- This refers to the "strange door" located on the first room of Depths 2. You open it with either
|
|
209
|
+
-- a Polaroid or a Negative. It has a sprite filename of "gfx/grid/Door_Mausoleum_Alt.anm2".
|
|
176
210
|
function ____exports.isDoorToMausoleumAscent(self, door)
|
|
177
211
|
if not ____exports.isRepentanceDoor(nil, door) then
|
|
178
212
|
return false
|
|
@@ -181,6 +215,8 @@ function ____exports.isDoorToMausoleumAscent(self, door)
|
|
|
181
215
|
local filename = sprite:GetFilename()
|
|
182
216
|
return filename == "gfx/grid/Door_Mausoleum_Alt.anm2"
|
|
183
217
|
end
|
|
218
|
+
--- This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
|
|
219
|
+
-- to spend two bombs to open it. It has a sprite filename of "gfx/grid/Door_Mines.anm2".
|
|
184
220
|
function ____exports.isDoorToMines(self, door)
|
|
185
221
|
if not ____exports.isRepentanceDoor(nil, door) then
|
|
186
222
|
return false
|
|
@@ -189,6 +225,8 @@ function ____exports.isDoorToMines(self, door)
|
|
|
189
225
|
local filename = sprite:GetFilename()
|
|
190
226
|
return filename == "gfx/grid/Door_Mines.anm2"
|
|
191
227
|
end
|
|
228
|
+
--- This refers to the Repentance door that spawns after defeating Mom. You open it with the
|
|
229
|
+
-- completed knife. It has a sprite filename of "gfx/grid/Door_MomsHeart.anm2".
|
|
192
230
|
function ____exports.isDoorToMomsHeart(self, door)
|
|
193
231
|
if not ____exports.isRepentanceDoor(nil, door) then
|
|
194
232
|
return false
|
|
@@ -202,6 +240,12 @@ function ____exports.isHiddenSecretRoomDoor(self, door)
|
|
|
202
240
|
local animation = sprite:GetAnimation()
|
|
203
241
|
return ____exports.isSecretRoomDoor(nil, door) and animation == "Hidden"
|
|
204
242
|
end
|
|
243
|
+
--- Helper function to reset an unlocked door back to a locked state. Doing this is non-trivial
|
|
244
|
+
-- because in addition to calling the `GridEntityDoor.SetLocked` method, you must also:
|
|
245
|
+
--
|
|
246
|
+
-- - Set the `VisitedCount` of the room's `RoomDescription` to 0.
|
|
247
|
+
-- - Set the variant to `DoorVariant.DOOR_LOCKED`.
|
|
248
|
+
-- - Close the door.
|
|
205
249
|
function ____exports.lockDoor(self, door)
|
|
206
250
|
local level = game:GetLevel()
|
|
207
251
|
local roomDescriptor = level:GetRoomByIdx(door.TargetRoomIndex)
|
|
@@ -210,16 +254,25 @@ function ____exports.lockDoor(self, door)
|
|
|
210
254
|
door:SetLocked(true)
|
|
211
255
|
door:Close(true)
|
|
212
256
|
end
|
|
257
|
+
--- For the purposes of this function, doors to Secret Rooms or Super Secret Rooms that have not been
|
|
258
|
+
-- discovered yet will not be opened.
|
|
213
259
|
function ____exports.openAllDoors(self)
|
|
214
260
|
for ____, door in ipairs(____exports.getDoors(nil)) do
|
|
215
261
|
door:Open()
|
|
216
262
|
end
|
|
217
263
|
end
|
|
264
|
+
--- Use this instead of the `GridEntityDoor.Open` method if you want the door to immediately open
|
|
265
|
+
-- without an animation.
|
|
218
266
|
function ____exports.openDoorFast(self, door)
|
|
219
267
|
door.State = DoorState.OPEN
|
|
220
268
|
local sprite = door:GetSprite()
|
|
221
269
|
sprite:Play("Opened", true)
|
|
222
270
|
end
|
|
271
|
+
--- Helper function to remove all of the doors in the room. By default, it will remove every door.
|
|
272
|
+
-- You can optionally specify one or more room types to remove only the doors that match the
|
|
273
|
+
-- specified room types.
|
|
274
|
+
--
|
|
275
|
+
-- @returns The number of doors removed.
|
|
223
276
|
function ____exports.removeAllDoors(self, ...)
|
|
224
277
|
local doors = ____exports.getDoors(nil, ...)
|
|
225
278
|
____exports.removeDoors(
|