isaacscript-common 13.1.0 → 13.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -6628,15 +6628,6 @@ export declare function isVanillaTrinketType(trinketType: TrinketType): boolean;
6628
6628
  */
6629
6629
  export declare function isVanillaTSTLClass(object: unknown): boolean;
6630
6630
 
6631
- /**
6632
- * Helper function to determine if a given wall is a "real" wall generated by the vanilla game. This
6633
- * is useful because mods can use custom spawned walls as a stand-in for custom grid entities.
6634
- *
6635
- * This function checks for identity via a combination of `StageAPI.IsCustomGrid` and the
6636
- * `isVanillaWallGridIndex` function.
6637
- */
6638
- export declare function isVanillaWall(gridEntity: GridEntity): boolean;
6639
-
6640
6631
  /**
6641
6632
  * Helper function to determine if a given grid index should have a wall generated by the vanilla
6642
6633
  * game. This is useful as a mechanism to distinguish between real walls and custom walls spawned by
@@ -9477,6 +9468,28 @@ export declare function preventChildEntities(entity: Entity): void;
9477
9468
  */
9478
9469
  export declare function preventCollectibleRotation(collectible: EntityPickup, collectibleType: CollectibleType): void;
9479
9470
 
9471
+ /**
9472
+ * Helper function to prevent any removed grid entities from respawning if the player re-enters the
9473
+ * room.
9474
+ *
9475
+ * This is accomplished by spawning a new grid entity on every tile that does not already have a
9476
+ * grid entity. This will force the game to spawn the new grid entity instead of the old one. The
9477
+ * natural grid entity to choose for this purpose is a decoration, since it is non-interacting.
9478
+ * Then, the decorations are made invisible and any shovel uses are intercepted to avoid creating a
9479
+ * crawl space (instead of a trapdoor).
9480
+ *
9481
+ * Another option besides decorations would be to use a pressure plates with a state of 1, which is
9482
+ * a state that is normally unused by the game and makes it invisible & persistent. However, pickups
9483
+ * will not be able to spawn on pressure plates, which lead to various bugs (e.g. pickups spawning
9484
+ * on top of pits). Thus, using a decoration is preferable.
9485
+ *
9486
+ * Yet another option to accomplish this would be to replace the room data with that of an empty
9487
+ * room. However, the room data must exactly match the room type, the room shape, and the doors, so
9488
+ * this is not possible to do in a robust way without adding empty rooms to the mod's `content`
9489
+ * folder to draw the data from.
9490
+ */
9491
+ export declare function preventGridEntityRespawn(): void;
9492
+
9480
9493
  /**
9481
9494
  * Helper function to print something to the in-game console. Use this instead of invoking the
9482
9495
  * `Isaac.ConsoleOutput` method directly because it will automatically insert a newline at the end
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 13.1.0
3
+ isaacscript-common 13.2.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -40874,6 +40874,302 @@ function ____exports.customTrapdoorInit(self, mod)
40874
40874
  mod:AddCallback(ModCallback.POST_PEFFECT_UPDATE, postPEffectUpdate)
40875
40875
  mod:AddCallbackCustom(ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_UPDATE, postGridEntityCustomUpdateTrapdoor, GridEntityTypeCustom.TRAPDOOR_CUSTOM)
40876
40876
  end
40877
+ return ____exports
40878
+ end,
40879
+ ["src.functions.gridIndex"] = function(...)
40880
+ local ____exports = {}
40881
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
40882
+ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
40883
+ local ____roomShape = require("src.functions.roomShape")
40884
+ local getRoomShapeWidth = ____roomShape.getRoomShapeWidth
40885
+ local ____utils = require("src.functions.utils")
40886
+ local iRange = ____utils.iRange
40887
+ function ____exports.getGridIndexesBetween(self, gridIndex1, gridIndex2, roomShape)
40888
+ if gridIndex1 > gridIndex2 then
40889
+ local oldGridIndex1 = gridIndex1
40890
+ local oldGridIndex2 = gridIndex2
40891
+ gridIndex1 = oldGridIndex2
40892
+ gridIndex2 = oldGridIndex1
40893
+ end
40894
+ local delta = gridIndex2 - gridIndex1
40895
+ local gridWidth = getRoomShapeWidth(nil, roomShape)
40896
+ local isOnHorizontalLine = delta <= gridWidth
40897
+ if isOnHorizontalLine then
40898
+ return iRange(nil, gridIndex1, gridIndex2)
40899
+ end
40900
+ local isOnVerticalLine = delta % gridWidth == 0
40901
+ if isOnVerticalLine then
40902
+ return iRange(nil, gridIndex1, gridIndex2, gridWidth)
40903
+ end
40904
+ error(((((((("Failed to get the grid indexes between " .. tostring(gridIndex1)) .. " and ") .. tostring(gridIndex2)) .. " for RoomShape.") .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ") since they are not on the same horizontal or vertical line.")
40905
+ end
40906
+ return ____exports
40907
+ end,
40908
+ ["src.functions.roomShapeWalls"] = function(...)
40909
+ local ____lualib = require("lualib_bundle")
40910
+ local Map = ____lualib.Map
40911
+ local __TS__New = ____lualib.__TS__New
40912
+ local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
40913
+ local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
40914
+ local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
40915
+ local Set = ____lualib.Set
40916
+ local ____exports = {}
40917
+ local getRoomShapeToWallGridIndexSet, getVanillaWallGridIndexSetForRoomShape, getWallGridIndexSetForRectangleRoomShape
40918
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
40919
+ local BossID = ____isaac_2Dtypescript_2Ddefinitions.BossID
40920
+ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
40921
+ local ____cachedClasses = require("src.core.cachedClasses")
40922
+ local game = ____cachedClasses.game
40923
+ local ____CornerType = require("src.enums.CornerType")
40924
+ local CornerType = ____CornerType.CornerType
40925
+ local ____enums = require("src.functions.enums")
40926
+ local getEnumValues = ____enums.getEnumValues
40927
+ local ____gridIndex = require("src.functions.gridIndex")
40928
+ local getGridIndexesBetween = ____gridIndex.getGridIndexesBetween
40929
+ local ____rooms = require("src.functions.rooms")
40930
+ local inBossRoomOf = ____rooms.inBossRoomOf
40931
+ local inHomeCloset = ____rooms.inHomeCloset
40932
+ local ____roomShape = require("src.functions.roomShape")
40933
+ local getRoomShapeCorners = ____roomShape.getRoomShapeCorners
40934
+ local isLRoom = ____roomShape.isLRoom
40935
+ function getRoomShapeToWallGridIndexSet(self)
40936
+ local roomShapeToWallGridIndexSet = __TS__New(Map)
40937
+ for ____, roomShape in ipairs(getEnumValues(nil, RoomShape)) do
40938
+ local gridIndexSet = getVanillaWallGridIndexSetForRoomShape(nil, roomShape)
40939
+ roomShapeToWallGridIndexSet:set(roomShape, gridIndexSet)
40940
+ end
40941
+ return roomShapeToWallGridIndexSet
40942
+ end
40943
+ function getVanillaWallGridIndexSetForRoomShape(self, roomShape)
40944
+ local corners = getRoomShapeCorners(nil, roomShape)
40945
+ local lRoom = isLRoom(nil, roomShape)
40946
+ if lRoom and #corners ~= 6 then
40947
+ error(((("Failed to get the correct amount of corners for: RoomShape." .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ")")
40948
+ end
40949
+ repeat
40950
+ local ____switch7 = roomShape
40951
+ local ____cond7 = ____switch7 == RoomShape.LTL
40952
+ if ____cond7 then
40953
+ do
40954
+ local topMiddle, topRight, middleLeft, middle, bottomLeft, bottomRight = table.unpack(corners)
40955
+ local ____Set_1 = Set
40956
+ local ____array_0 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topMiddle.gridIndex, topRight.gridIndex, roomShape)))
40957
+ __TS__SparseArrayPush(
40958
+ ____array_0,
40959
+ table.unpack(getGridIndexesBetween(nil, middleLeft.gridIndex, middle.gridIndex, roomShape))
40960
+ )
40961
+ __TS__SparseArrayPush(
40962
+ ____array_0,
40963
+ table.unpack(getGridIndexesBetween(nil, bottomLeft.gridIndex, bottomRight.gridIndex, roomShape))
40964
+ )
40965
+ __TS__SparseArrayPush(
40966
+ ____array_0,
40967
+ table.unpack(getGridIndexesBetween(nil, middleLeft.gridIndex, bottomLeft.gridIndex, roomShape))
40968
+ )
40969
+ __TS__SparseArrayPush(
40970
+ ____array_0,
40971
+ table.unpack(getGridIndexesBetween(nil, topMiddle.gridIndex, middle.gridIndex, roomShape))
40972
+ )
40973
+ __TS__SparseArrayPush(
40974
+ ____array_0,
40975
+ table.unpack(getGridIndexesBetween(nil, topRight.gridIndex, bottomRight.gridIndex, roomShape))
40976
+ )
40977
+ return __TS__New(
40978
+ ____Set_1,
40979
+ {__TS__SparseArraySpread(____array_0)}
40980
+ )
40981
+ end
40982
+ end
40983
+ ____cond7 = ____cond7 or ____switch7 == RoomShape.LTR
40984
+ if ____cond7 then
40985
+ do
40986
+ local topLeft, topMiddle, middle, middleRight, bottomLeft, bottomRight = table.unpack(corners)
40987
+ local ____Set_3 = Set
40988
+ local ____array_2 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, topMiddle.gridIndex, roomShape)))
40989
+ __TS__SparseArrayPush(
40990
+ ____array_2,
40991
+ table.unpack(getGridIndexesBetween(nil, middle.gridIndex, middleRight.gridIndex, roomShape))
40992
+ )
40993
+ __TS__SparseArrayPush(
40994
+ ____array_2,
40995
+ table.unpack(getGridIndexesBetween(nil, bottomLeft.gridIndex, bottomRight.gridIndex, roomShape))
40996
+ )
40997
+ __TS__SparseArrayPush(
40998
+ ____array_2,
40999
+ table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, bottomLeft.gridIndex, roomShape))
41000
+ )
41001
+ __TS__SparseArrayPush(
41002
+ ____array_2,
41003
+ table.unpack(getGridIndexesBetween(nil, topMiddle.gridIndex, middle.gridIndex, roomShape))
41004
+ )
41005
+ __TS__SparseArrayPush(
41006
+ ____array_2,
41007
+ table.unpack(getGridIndexesBetween(nil, middleRight.gridIndex, bottomRight.gridIndex, roomShape))
41008
+ )
41009
+ return __TS__New(
41010
+ ____Set_3,
41011
+ {__TS__SparseArraySpread(____array_2)}
41012
+ )
41013
+ end
41014
+ end
41015
+ ____cond7 = ____cond7 or ____switch7 == RoomShape.LBL
41016
+ if ____cond7 then
41017
+ do
41018
+ local topLeft, topRight, middleLeft, middle, bottomMiddle, bottomRight = table.unpack(corners)
41019
+ local ____Set_5 = Set
41020
+ local ____array_4 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, topRight.gridIndex, roomShape)))
41021
+ __TS__SparseArrayPush(
41022
+ ____array_4,
41023
+ table.unpack(getGridIndexesBetween(nil, middleLeft.gridIndex, middle.gridIndex, roomShape))
41024
+ )
41025
+ __TS__SparseArrayPush(
41026
+ ____array_4,
41027
+ table.unpack(getGridIndexesBetween(nil, bottomMiddle.gridIndex, bottomRight.gridIndex, roomShape))
41028
+ )
41029
+ __TS__SparseArrayPush(
41030
+ ____array_4,
41031
+ table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, middleLeft.gridIndex, roomShape))
41032
+ )
41033
+ __TS__SparseArrayPush(
41034
+ ____array_4,
41035
+ table.unpack(getGridIndexesBetween(nil, middle.gridIndex, bottomMiddle.gridIndex, roomShape))
41036
+ )
41037
+ __TS__SparseArrayPush(
41038
+ ____array_4,
41039
+ table.unpack(getGridIndexesBetween(nil, topRight.gridIndex, bottomRight.gridIndex, roomShape))
41040
+ )
41041
+ return __TS__New(
41042
+ ____Set_5,
41043
+ {__TS__SparseArraySpread(____array_4)}
41044
+ )
41045
+ end
41046
+ end
41047
+ ____cond7 = ____cond7 or ____switch7 == RoomShape.LBR
41048
+ if ____cond7 then
41049
+ do
41050
+ local topLeft, topRight, middle, middleRight, bottomLeft, bottomMiddle = table.unpack(corners)
41051
+ local ____Set_7 = Set
41052
+ local ____array_6 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, topRight.gridIndex, roomShape)))
41053
+ __TS__SparseArrayPush(
41054
+ ____array_6,
41055
+ table.unpack(getGridIndexesBetween(nil, middle.gridIndex, middleRight.gridIndex, roomShape))
41056
+ )
41057
+ __TS__SparseArrayPush(
41058
+ ____array_6,
41059
+ table.unpack(getGridIndexesBetween(nil, bottomLeft.gridIndex, bottomMiddle.gridIndex, roomShape))
41060
+ )
41061
+ __TS__SparseArrayPush(
41062
+ ____array_6,
41063
+ table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, bottomLeft.gridIndex, roomShape))
41064
+ )
41065
+ __TS__SparseArrayPush(
41066
+ ____array_6,
41067
+ table.unpack(getGridIndexesBetween(nil, middle.gridIndex, bottomMiddle.gridIndex, roomShape))
41068
+ )
41069
+ __TS__SparseArrayPush(
41070
+ ____array_6,
41071
+ table.unpack(getGridIndexesBetween(nil, topRight.gridIndex, middleRight.gridIndex, roomShape))
41072
+ )
41073
+ return __TS__New(
41074
+ ____Set_7,
41075
+ {__TS__SparseArraySpread(____array_6)}
41076
+ )
41077
+ end
41078
+ end
41079
+ do
41080
+ do
41081
+ return getWallGridIndexSetForRectangleRoomShape(nil, roomShape, corners)
41082
+ end
41083
+ end
41084
+ until true
41085
+ end
41086
+ function getWallGridIndexSetForRectangleRoomShape(self, roomShape, corners)
41087
+ if #corners ~= 4 then
41088
+ error("Failed to get the correct amount of corners for rectangular room shape.")
41089
+ end
41090
+ local topLeft, topRight, bottomLeft, bottomRight = table.unpack(corners)
41091
+ local ____Set_9 = Set
41092
+ local ____array_8 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, topRight.gridIndex, roomShape)))
41093
+ __TS__SparseArrayPush(
41094
+ ____array_8,
41095
+ table.unpack(getGridIndexesBetween(nil, bottomLeft.gridIndex, bottomRight.gridIndex, roomShape))
41096
+ )
41097
+ __TS__SparseArrayPush(
41098
+ ____array_8,
41099
+ table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, bottomLeft.gridIndex, roomShape))
41100
+ )
41101
+ __TS__SparseArrayPush(
41102
+ ____array_8,
41103
+ table.unpack(getGridIndexesBetween(nil, topRight.gridIndex, bottomRight.gridIndex, roomShape))
41104
+ )
41105
+ return __TS__New(
41106
+ ____Set_9,
41107
+ {__TS__SparseArraySpread(____array_8)}
41108
+ )
41109
+ end
41110
+ local ROOM_SHAPE_TO_WALL_GRID_INDEX_SET = getRoomShapeToWallGridIndexSet(nil)
41111
+ local HOME_CLOSET_CORNERS = {
41112
+ {
41113
+ type = CornerType.TOP_LEFT,
41114
+ gridIndex = 30,
41115
+ position = Vector(60, 220)
41116
+ },
41117
+ {
41118
+ type = CornerType.TOP_RIGHT,
41119
+ gridIndex = 38,
41120
+ position = Vector(340, 220)
41121
+ },
41122
+ {
41123
+ type = CornerType.BOTTOM_LEFT,
41124
+ gridIndex = 90,
41125
+ position = Vector(60, 340)
41126
+ },
41127
+ {
41128
+ type = CornerType.BOTTOM_RIGHT,
41129
+ gridIndex = 98,
41130
+ position = Vector(340, 340)
41131
+ }
41132
+ }
41133
+ local HOME_CLOSET_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(nil, RoomShape.IH, HOME_CLOSET_CORNERS)
41134
+ local MOTHER_ROOM_CORNERS = {
41135
+ {
41136
+ type = CornerType.TOP_LEFT,
41137
+ gridIndex = 0,
41138
+ position = Vector(60, 140)
41139
+ },
41140
+ {
41141
+ type = CornerType.TOP_RIGHT,
41142
+ gridIndex = 14,
41143
+ position = Vector(580, 140)
41144
+ },
41145
+ {
41146
+ type = CornerType.BOTTOM_LEFT,
41147
+ gridIndex = 150,
41148
+ position = Vector(60, 500)
41149
+ },
41150
+ {
41151
+ type = CornerType.BOTTOM_RIGHT,
41152
+ gridIndex = 164,
41153
+ position = Vector(580, 500)
41154
+ }
41155
+ }
41156
+ local MOTHER_ROOM_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(nil, RoomShape.SHAPE_1x2, MOTHER_ROOM_CORNERS)
41157
+ function ____exports.isVanillaWallGridIndex(self, gridIndex)
41158
+ local room = game:GetRoom()
41159
+ local roomShape = room:GetRoomShape()
41160
+ local wallGridIndexSet
41161
+ if inHomeCloset(nil) then
41162
+ wallGridIndexSet = HOME_CLOSET_CORNERS_SET
41163
+ elseif inBossRoomOf(nil, BossID.MOTHER) then
41164
+ wallGridIndexSet = MOTHER_ROOM_CORNERS_SET
41165
+ else
41166
+ wallGridIndexSet = ROOM_SHAPE_TO_WALL_GRID_INDEX_SET:get(roomShape)
41167
+ end
41168
+ if wallGridIndexSet == nil then
41169
+ error(((("Failed to find the wall grid index set for: RoomShape." .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ")")
41170
+ end
41171
+ return wallGridIndexSet:has(gridIndex)
41172
+ end
40877
41173
  return ____exports
40878
41174
  end,
40879
41175
  ["src.functions.emptyRoom"] = function(...)
@@ -40881,7 +41177,7 @@ local ____lualib = require("lualib_bundle")
40881
41177
  local Set = ____lualib.Set
40882
41178
  local __TS__New = ____lualib.__TS__New
40883
41179
  local ____exports = {}
40884
- local emptyRoomEntities, emptyRoomGridEntities, EMPTY_ROOM_BLACKLIST_ENTITY_SET, EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET
41180
+ local emptyRoomEntities, emptyRoomGridEntities, EMPTY_ROOM_BLACKLIST_ENTITY_SET
40885
41181
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
40886
41182
  local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
40887
41183
  local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
@@ -40895,6 +41191,8 @@ local getGridEntities = ____gridEntities.getGridEntities
40895
41191
  local removeGridEntity = ____gridEntities.removeGridEntity
40896
41192
  local ____rooms = require("src.functions.rooms")
40897
41193
  local roomUpdateSafe = ____rooms.roomUpdateSafe
41194
+ local ____roomShapeWalls = require("src.functions.roomShapeWalls")
41195
+ local isVanillaWallGridIndex = ____roomShapeWalls.isVanillaWallGridIndex
40898
41196
  function emptyRoomEntities(self)
40899
41197
  local room = game:GetRoom()
40900
41198
  for ____, entity in ipairs(getEntities(nil)) do
@@ -40920,7 +41218,11 @@ function emptyRoomGridEntities(self)
40920
41218
  for ____, gridEntity in ipairs(getGridEntities(nil)) do
40921
41219
  do
40922
41220
  local gridEntityType = gridEntity:GetType()
40923
- if EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET:has(gridEntityType) then
41221
+ local gridIndex = gridEntity:GetGridIndex()
41222
+ if gridEntityType == GridEntityType.WALL and isVanillaWallGridIndex(nil, gridIndex) then
41223
+ goto __continue10
41224
+ end
41225
+ if gridEntityType == GridEntityType.DOOR then
40924
41226
  goto __continue10
40925
41227
  end
40926
41228
  removeGridEntity(nil, gridEntity, false)
@@ -40941,7 +41243,6 @@ EMPTY_ROOM_BLACKLIST_ENTITY_SET = __TS__New(Set, {
40941
41243
  EntityType.PROJECTILE,
40942
41244
  EntityType.DARK_ESAU
40943
41245
  })
40944
- EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET = __TS__New(Set, {GridEntityType.WALL, GridEntityType.DOOR})
40945
41246
  function ____exports.emptyRoom(self)
40946
41247
  emptyRoomEntities(nil)
40947
41248
  emptyRoomGridEntities(nil)
@@ -41433,7 +41734,7 @@ local __TS__New = ____lualib.__TS__New
41433
41734
  local Map = ____lualib.Map
41434
41735
  local __TS__Iterator = ____lualib.__TS__Iterator
41435
41736
  local ____exports = {}
41436
- local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, PERSISTENT_ENTITY_TYPES, GRID_ENTITY_XML_TYPE_SET, v
41737
+ local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, PERSISTENT_ENTITY_TYPES, GRID_ENTITY_XML_TYPE_SET, v
41437
41738
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
41438
41739
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
41439
41740
  local EntityCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityCollisionClass
@@ -41469,6 +41770,7 @@ local getAllGridIndexes = ____gridEntities.getAllGridIndexes
41469
41770
  local getGridEntities = ____gridEntities.getGridEntities
41470
41771
  local removeGridEntity = ____gridEntities.removeGridEntity
41471
41772
  local setGridEntityInvisible = ____gridEntities.setGridEntityInvisible
41773
+ local spawnGridEntity = ____gridEntities.spawnGridEntity
41472
41774
  local spawnGridEntityWithVariant = ____gridEntities.spawnGridEntityWithVariant
41473
41775
  local ____jsonRoom = require("src.functions.jsonRoom")
41474
41776
  local getRandomJSONEntity = ____jsonRoom.getRandomJSONEntity
@@ -41519,12 +41821,16 @@ function preUseItemWeNeedToGoDeeper(self, _collectibleType, _rng, player, _useFl
41519
41821
  if futurePlayer == nil then
41520
41822
  return
41521
41823
  end
41824
+ local futureRoomListIndex = getRoomListIndex(nil)
41825
+ if futureRoomListIndex ~= roomListIndex then
41826
+ return
41827
+ end
41522
41828
  v.room.manuallyUsingShovel = true
41523
41829
  futurePlayer:UseActiveItem(CollectibleType.WE_NEED_TO_GO_DEEPER)
41524
41830
  v.room.manuallyUsingShovel = false
41525
41831
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
41526
41832
  emptyArray(nil, decorationGridIndexes)
41527
- fillRoomWithDecorations(nil)
41833
+ ____exports.preventGridEntityRespawn(nil)
41528
41834
  end
41529
41835
  )
41530
41836
  return true
@@ -41566,24 +41872,25 @@ function respawnPersistentEntities(self)
41566
41872
  )
41567
41873
  end
41568
41874
  end
41569
- function fillRoomWithDecorations(self)
41875
+ function ____exports.preventGridEntityRespawn(self)
41876
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
41570
41877
  local room = game:GetRoom()
41571
41878
  local roomListIndex = getRoomListIndex(nil)
41879
+ v.level.deployedRoomListIndexes:add(roomListIndex)
41572
41880
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
41573
41881
  for ____, gridIndex in ipairs(getAllGridIndexes(nil)) do
41574
41882
  do
41575
41883
  local existingGridEntity = room:GetGridEntity(gridIndex)
41576
41884
  if existingGridEntity ~= nil then
41577
- goto __continue31
41885
+ goto __continue32
41578
41886
  end
41579
- local position = room:GetGridPosition(gridIndex)
41580
- local decoration = Isaac.GridSpawn(GridEntityType.DECORATION, 0, position)
41887
+ local decoration = spawnGridEntity(nil, GridEntityType.DECORATION, gridIndex)
41581
41888
  if decoration ~= nil then
41582
41889
  setGridEntityInvisible(nil, decoration)
41583
41890
  end
41584
41891
  decorationGridIndexes[#decorationGridIndexes + 1] = gridIndex
41585
41892
  end
41586
- ::__continue31::
41893
+ ::__continue32::
41587
41894
  end
41588
41895
  end
41589
41896
  function spawnAllEntities(self, jsonRoom, rng, verbose)
@@ -41840,7 +42147,7 @@ function getPitFrame(self, L, R, U, D, UL, UR, DL, DR)
41840
42147
  end
41841
42148
  return F
41842
42149
  end
41843
- local FEATURE_NAME = "deployJSONRoom"
42150
+ FEATURE_NAME = "deployJSONRoom"
41844
42151
  PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.WALL_HUGGER})
41845
42152
  local gridEntityXMLTypes = getEnumValues(nil, GridEntityXMLType)
41846
42153
  GRID_ENTITY_XML_TYPE_SET = __TS__New(Set, gridEntityXMLTypes)
@@ -41890,7 +42197,7 @@ function ____exports.deployJSONRoom(self, jsonRoom, seedOrRNG, verbose)
41890
42197
  log(nil, "Finished spawning all of the new entities and grid entities.")
41891
42198
  end
41892
42199
  fixPitGraphics(nil)
41893
- fillRoomWithDecorations(nil)
42200
+ ____exports.preventGridEntityRespawn(nil)
41894
42201
  end
41895
42202
  function ____exports.deployRandomJSONRoom(self, jsonRooms, seedOrRNG, verbose)
41896
42203
  if seedOrRNG == nil then
@@ -48579,35 +48886,6 @@ function ____exports.logNewGlobals(self)
48579
48886
  end
48580
48887
  )
48581
48888
  end
48582
- return ____exports
48583
- end,
48584
- ["src.functions.gridIndex"] = function(...)
48585
- local ____exports = {}
48586
- local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
48587
- local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
48588
- local ____roomShape = require("src.functions.roomShape")
48589
- local getRoomShapeWidth = ____roomShape.getRoomShapeWidth
48590
- local ____utils = require("src.functions.utils")
48591
- local iRange = ____utils.iRange
48592
- function ____exports.getGridIndexesBetween(self, gridIndex1, gridIndex2, roomShape)
48593
- if gridIndex1 > gridIndex2 then
48594
- local oldGridIndex1 = gridIndex1
48595
- local oldGridIndex2 = gridIndex2
48596
- gridIndex1 = oldGridIndex2
48597
- gridIndex2 = oldGridIndex1
48598
- end
48599
- local delta = gridIndex2 - gridIndex1
48600
- local gridWidth = getRoomShapeWidth(nil, roomShape)
48601
- local isOnHorizontalLine = delta <= gridWidth
48602
- if isOnHorizontalLine then
48603
- return iRange(nil, gridIndex1, gridIndex2)
48604
- end
48605
- local isOnVerticalLine = delta % gridWidth == 0
48606
- if isOnVerticalLine then
48607
- return iRange(nil, gridIndex1, gridIndex2, gridWidth)
48608
- end
48609
- error(((((((("Failed to get the grid indexes between " .. tostring(gridIndex1)) .. " and ") .. tostring(gridIndex2)) .. " for RoomShape.") .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ") since they are not on the same horizontal or vertical line.")
48610
- end
48611
48889
  return ____exports
48612
48890
  end,
48613
48891
  ["src.functions.hex"] = function(...)
@@ -49676,280 +49954,6 @@ function ____exports.spawnRockAltReward(self, position, rockAltType, seedOrRNG)
49676
49954
  end
49677
49955
  until true
49678
49956
  end
49679
- return ____exports
49680
- end,
49681
- ["src.functions.roomShapeWalls"] = function(...)
49682
- local ____lualib = require("lualib_bundle")
49683
- local Map = ____lualib.Map
49684
- local __TS__New = ____lualib.__TS__New
49685
- local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
49686
- local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
49687
- local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
49688
- local Set = ____lualib.Set
49689
- local ____exports = {}
49690
- local getRoomShapeToWallGridIndexSet, getVanillaWallGridIndexSetForRoomShape, getWallGridIndexSetForRectangleRoomShape, ROOM_SHAPE_TO_WALL_GRID_INDEX_SET, HOME_CLOSET_CORNERS_SET, MOTHER_ROOM_CORNERS_SET
49691
- local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
49692
- local BossID = ____isaac_2Dtypescript_2Ddefinitions.BossID
49693
- local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
49694
- local ____cachedClasses = require("src.core.cachedClasses")
49695
- local game = ____cachedClasses.game
49696
- local ____CornerType = require("src.enums.CornerType")
49697
- local CornerType = ____CornerType.CornerType
49698
- local ____enums = require("src.functions.enums")
49699
- local getEnumValues = ____enums.getEnumValues
49700
- local ____gridIndex = require("src.functions.gridIndex")
49701
- local getGridIndexesBetween = ____gridIndex.getGridIndexesBetween
49702
- local ____rooms = require("src.functions.rooms")
49703
- local inBossRoomOf = ____rooms.inBossRoomOf
49704
- local inHomeCloset = ____rooms.inHomeCloset
49705
- local ____roomShape = require("src.functions.roomShape")
49706
- local getRoomShapeCorners = ____roomShape.getRoomShapeCorners
49707
- local isLRoom = ____roomShape.isLRoom
49708
- function getRoomShapeToWallGridIndexSet(self)
49709
- local roomShapeToWallGridIndexSet = __TS__New(Map)
49710
- for ____, roomShape in ipairs(getEnumValues(nil, RoomShape)) do
49711
- local gridIndexSet = getVanillaWallGridIndexSetForRoomShape(nil, roomShape)
49712
- roomShapeToWallGridIndexSet:set(roomShape, gridIndexSet)
49713
- end
49714
- return roomShapeToWallGridIndexSet
49715
- end
49716
- function getVanillaWallGridIndexSetForRoomShape(self, roomShape)
49717
- local corners = getRoomShapeCorners(nil, roomShape)
49718
- local lRoom = isLRoom(nil, roomShape)
49719
- if lRoom and #corners ~= 6 then
49720
- error(((("Failed to get the correct amount of corners for: RoomShape." .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ")")
49721
- end
49722
- repeat
49723
- local ____switch7 = roomShape
49724
- local ____cond7 = ____switch7 == RoomShape.LTL
49725
- if ____cond7 then
49726
- do
49727
- local topMiddle, topRight, middleLeft, middle, bottomLeft, bottomRight = table.unpack(corners)
49728
- local ____Set_1 = Set
49729
- local ____array_0 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topMiddle.gridIndex, topRight.gridIndex, roomShape)))
49730
- __TS__SparseArrayPush(
49731
- ____array_0,
49732
- table.unpack(getGridIndexesBetween(nil, middleLeft.gridIndex, middle.gridIndex, roomShape))
49733
- )
49734
- __TS__SparseArrayPush(
49735
- ____array_0,
49736
- table.unpack(getGridIndexesBetween(nil, bottomLeft.gridIndex, bottomRight.gridIndex, roomShape))
49737
- )
49738
- __TS__SparseArrayPush(
49739
- ____array_0,
49740
- table.unpack(getGridIndexesBetween(nil, middleLeft.gridIndex, bottomLeft.gridIndex, roomShape))
49741
- )
49742
- __TS__SparseArrayPush(
49743
- ____array_0,
49744
- table.unpack(getGridIndexesBetween(nil, topMiddle.gridIndex, middle.gridIndex, roomShape))
49745
- )
49746
- __TS__SparseArrayPush(
49747
- ____array_0,
49748
- table.unpack(getGridIndexesBetween(nil, topRight.gridIndex, bottomRight.gridIndex, roomShape))
49749
- )
49750
- return __TS__New(
49751
- ____Set_1,
49752
- {__TS__SparseArraySpread(____array_0)}
49753
- )
49754
- end
49755
- end
49756
- ____cond7 = ____cond7 or ____switch7 == RoomShape.LTR
49757
- if ____cond7 then
49758
- do
49759
- local topLeft, topMiddle, middle, middleRight, bottomLeft, bottomRight = table.unpack(corners)
49760
- local ____Set_3 = Set
49761
- local ____array_2 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, topMiddle.gridIndex, roomShape)))
49762
- __TS__SparseArrayPush(
49763
- ____array_2,
49764
- table.unpack(getGridIndexesBetween(nil, middle.gridIndex, middleRight.gridIndex, roomShape))
49765
- )
49766
- __TS__SparseArrayPush(
49767
- ____array_2,
49768
- table.unpack(getGridIndexesBetween(nil, bottomLeft.gridIndex, bottomRight.gridIndex, roomShape))
49769
- )
49770
- __TS__SparseArrayPush(
49771
- ____array_2,
49772
- table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, bottomLeft.gridIndex, roomShape))
49773
- )
49774
- __TS__SparseArrayPush(
49775
- ____array_2,
49776
- table.unpack(getGridIndexesBetween(nil, topMiddle.gridIndex, middle.gridIndex, roomShape))
49777
- )
49778
- __TS__SparseArrayPush(
49779
- ____array_2,
49780
- table.unpack(getGridIndexesBetween(nil, middleRight.gridIndex, bottomRight.gridIndex, roomShape))
49781
- )
49782
- return __TS__New(
49783
- ____Set_3,
49784
- {__TS__SparseArraySpread(____array_2)}
49785
- )
49786
- end
49787
- end
49788
- ____cond7 = ____cond7 or ____switch7 == RoomShape.LBL
49789
- if ____cond7 then
49790
- do
49791
- local topLeft, topRight, middleLeft, middle, bottomMiddle, bottomRight = table.unpack(corners)
49792
- local ____Set_5 = Set
49793
- local ____array_4 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, topRight.gridIndex, roomShape)))
49794
- __TS__SparseArrayPush(
49795
- ____array_4,
49796
- table.unpack(getGridIndexesBetween(nil, middleLeft.gridIndex, middle.gridIndex, roomShape))
49797
- )
49798
- __TS__SparseArrayPush(
49799
- ____array_4,
49800
- table.unpack(getGridIndexesBetween(nil, bottomMiddle.gridIndex, bottomRight.gridIndex, roomShape))
49801
- )
49802
- __TS__SparseArrayPush(
49803
- ____array_4,
49804
- table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, middleLeft.gridIndex, roomShape))
49805
- )
49806
- __TS__SparseArrayPush(
49807
- ____array_4,
49808
- table.unpack(getGridIndexesBetween(nil, middle.gridIndex, bottomMiddle.gridIndex, roomShape))
49809
- )
49810
- __TS__SparseArrayPush(
49811
- ____array_4,
49812
- table.unpack(getGridIndexesBetween(nil, topRight.gridIndex, bottomRight.gridIndex, roomShape))
49813
- )
49814
- return __TS__New(
49815
- ____Set_5,
49816
- {__TS__SparseArraySpread(____array_4)}
49817
- )
49818
- end
49819
- end
49820
- ____cond7 = ____cond7 or ____switch7 == RoomShape.LBR
49821
- if ____cond7 then
49822
- do
49823
- local topLeft, topRight, middle, middleRight, bottomLeft, bottomMiddle = table.unpack(corners)
49824
- local ____Set_7 = Set
49825
- local ____array_6 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, topRight.gridIndex, roomShape)))
49826
- __TS__SparseArrayPush(
49827
- ____array_6,
49828
- table.unpack(getGridIndexesBetween(nil, middle.gridIndex, middleRight.gridIndex, roomShape))
49829
- )
49830
- __TS__SparseArrayPush(
49831
- ____array_6,
49832
- table.unpack(getGridIndexesBetween(nil, bottomLeft.gridIndex, bottomMiddle.gridIndex, roomShape))
49833
- )
49834
- __TS__SparseArrayPush(
49835
- ____array_6,
49836
- table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, bottomLeft.gridIndex, roomShape))
49837
- )
49838
- __TS__SparseArrayPush(
49839
- ____array_6,
49840
- table.unpack(getGridIndexesBetween(nil, middle.gridIndex, bottomMiddle.gridIndex, roomShape))
49841
- )
49842
- __TS__SparseArrayPush(
49843
- ____array_6,
49844
- table.unpack(getGridIndexesBetween(nil, topRight.gridIndex, middleRight.gridIndex, roomShape))
49845
- )
49846
- return __TS__New(
49847
- ____Set_7,
49848
- {__TS__SparseArraySpread(____array_6)}
49849
- )
49850
- end
49851
- end
49852
- do
49853
- do
49854
- return getWallGridIndexSetForRectangleRoomShape(nil, roomShape, corners)
49855
- end
49856
- end
49857
- until true
49858
- end
49859
- function getWallGridIndexSetForRectangleRoomShape(self, roomShape, corners)
49860
- if #corners ~= 4 then
49861
- error("Failed to get the correct amount of corners for rectangular room shape.")
49862
- end
49863
- local topLeft, topRight, bottomLeft, bottomRight = table.unpack(corners)
49864
- local ____Set_9 = Set
49865
- local ____array_8 = __TS__SparseArrayNew(table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, topRight.gridIndex, roomShape)))
49866
- __TS__SparseArrayPush(
49867
- ____array_8,
49868
- table.unpack(getGridIndexesBetween(nil, bottomLeft.gridIndex, bottomRight.gridIndex, roomShape))
49869
- )
49870
- __TS__SparseArrayPush(
49871
- ____array_8,
49872
- table.unpack(getGridIndexesBetween(nil, topLeft.gridIndex, bottomLeft.gridIndex, roomShape))
49873
- )
49874
- __TS__SparseArrayPush(
49875
- ____array_8,
49876
- table.unpack(getGridIndexesBetween(nil, topRight.gridIndex, bottomRight.gridIndex, roomShape))
49877
- )
49878
- return __TS__New(
49879
- ____Set_9,
49880
- {__TS__SparseArraySpread(____array_8)}
49881
- )
49882
- end
49883
- function ____exports.isVanillaWallGridIndex(self, gridIndex)
49884
- local room = game:GetRoom()
49885
- local roomShape = room:GetRoomShape()
49886
- local wallGridIndexSet
49887
- if inHomeCloset(nil) then
49888
- wallGridIndexSet = HOME_CLOSET_CORNERS_SET
49889
- elseif inBossRoomOf(nil, BossID.MOTHER) then
49890
- wallGridIndexSet = MOTHER_ROOM_CORNERS_SET
49891
- else
49892
- wallGridIndexSet = ROOM_SHAPE_TO_WALL_GRID_INDEX_SET:get(roomShape)
49893
- end
49894
- if wallGridIndexSet == nil then
49895
- error(((("Failed to find the wall grid index set for: RoomShape." .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ")")
49896
- end
49897
- return wallGridIndexSet:has(gridIndex)
49898
- end
49899
- ROOM_SHAPE_TO_WALL_GRID_INDEX_SET = getRoomShapeToWallGridIndexSet(nil)
49900
- local HOME_CLOSET_CORNERS = {
49901
- {
49902
- type = CornerType.TOP_LEFT,
49903
- gridIndex = 30,
49904
- position = Vector(60, 220)
49905
- },
49906
- {
49907
- type = CornerType.TOP_RIGHT,
49908
- gridIndex = 38,
49909
- position = Vector(340, 220)
49910
- },
49911
- {
49912
- type = CornerType.BOTTOM_LEFT,
49913
- gridIndex = 90,
49914
- position = Vector(60, 340)
49915
- },
49916
- {
49917
- type = CornerType.BOTTOM_RIGHT,
49918
- gridIndex = 98,
49919
- position = Vector(340, 340)
49920
- }
49921
- }
49922
- HOME_CLOSET_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(nil, RoomShape.IH, HOME_CLOSET_CORNERS)
49923
- local MOTHER_ROOM_CORNERS = {
49924
- {
49925
- type = CornerType.TOP_LEFT,
49926
- gridIndex = 0,
49927
- position = Vector(60, 140)
49928
- },
49929
- {
49930
- type = CornerType.TOP_RIGHT,
49931
- gridIndex = 14,
49932
- position = Vector(580, 140)
49933
- },
49934
- {
49935
- type = CornerType.BOTTOM_LEFT,
49936
- gridIndex = 150,
49937
- position = Vector(60, 500)
49938
- },
49939
- {
49940
- type = CornerType.BOTTOM_RIGHT,
49941
- gridIndex = 164,
49942
- position = Vector(580, 500)
49943
- }
49944
- }
49945
- MOTHER_ROOM_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(nil, RoomShape.SHAPE_1x2, MOTHER_ROOM_CORNERS)
49946
- function ____exports.isVanillaWall(self, gridEntity)
49947
- local gridIndex = gridEntity:GetGridIndex()
49948
- if StageAPI ~= nil and StageAPI.IsCustomGrid(gridIndex) then
49949
- return false
49950
- end
49951
- return ____exports.isVanillaWallGridIndex(nil, gridIndex)
49952
- end
49953
49957
  return ____exports
49954
49958
  end,
49955
49959
  ["src.functions.saveFile"] = function(...)
@@ -63,4 +63,25 @@ export declare function deployJSONRoom(jsonRoom: JSONRoom | Readonly<JSONRoom>,
63
63
  * what the function is doing. Default is false.
64
64
  */
65
65
  export declare function deployRandomJSONRoom(jsonRooms: JSONRoom[], seedOrRNG?: Seed | RNG, verbose?: boolean): void;
66
+ /**
67
+ * Helper function to prevent any removed grid entities from respawning if the player re-enters the
68
+ * room.
69
+ *
70
+ * This is accomplished by spawning a new grid entity on every tile that does not already have a
71
+ * grid entity. This will force the game to spawn the new grid entity instead of the old one. The
72
+ * natural grid entity to choose for this purpose is a decoration, since it is non-interacting.
73
+ * Then, the decorations are made invisible and any shovel uses are intercepted to avoid creating a
74
+ * crawl space (instead of a trapdoor).
75
+ *
76
+ * Another option besides decorations would be to use a pressure plates with a state of 1, which is
77
+ * a state that is normally unused by the game and makes it invisible & persistent. However, pickups
78
+ * will not be able to spawn on pressure plates, which lead to various bugs (e.g. pickups spawning
79
+ * on top of pits). Thus, using a decoration is preferable.
80
+ *
81
+ * Yet another option to accomplish this would be to replace the room data with that of an empty
82
+ * room. However, the room data must exactly match the room type, the room shape, and the doors, so
83
+ * this is not possible to do in a robust way without adding empty rooms to the mod's `content`
84
+ * folder to draw the data from.
85
+ */
86
+ export declare function preventGridEntityRespawn(): void;
66
87
  //# sourceMappingURL=deployJSONRoom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deployJSONRoom.d.ts","sourceRoot":"","sources":["../../../src/features/deployJSONRoom.ts"],"names":[],"mappings":";;AAgDA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAwKvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,EACvC,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CA4BN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,EACrB,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CAaN"}
1
+ {"version":3,"file":"deployJSONRoom.d.ts","sourceRoot":"","sources":["../../../src/features/deployJSONRoom.ts"],"names":[],"mappings":";;AAiDA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA6KvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,EACvC,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CA4BN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,EACrB,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CAaN;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CA0B/C"}
@@ -4,7 +4,7 @@ local __TS__New = ____lualib.__TS__New
4
4
  local Map = ____lualib.Map
5
5
  local __TS__Iterator = ____lualib.__TS__Iterator
6
6
  local ____exports = {}
7
- local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, PERSISTENT_ENTITY_TYPES, GRID_ENTITY_XML_TYPE_SET, v
7
+ local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, PERSISTENT_ENTITY_TYPES, GRID_ENTITY_XML_TYPE_SET, v
8
8
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
9
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
10
10
  local EntityCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityCollisionClass
@@ -40,6 +40,7 @@ local getAllGridIndexes = ____gridEntities.getAllGridIndexes
40
40
  local getGridEntities = ____gridEntities.getGridEntities
41
41
  local removeGridEntity = ____gridEntities.removeGridEntity
42
42
  local setGridEntityInvisible = ____gridEntities.setGridEntityInvisible
43
+ local spawnGridEntity = ____gridEntities.spawnGridEntity
43
44
  local spawnGridEntityWithVariant = ____gridEntities.spawnGridEntityWithVariant
44
45
  local ____jsonRoom = require("src.functions.jsonRoom")
45
46
  local getRandomJSONEntity = ____jsonRoom.getRandomJSONEntity
@@ -90,12 +91,16 @@ function preUseItemWeNeedToGoDeeper(self, _collectibleType, _rng, player, _useFl
90
91
  if futurePlayer == nil then
91
92
  return
92
93
  end
94
+ local futureRoomListIndex = getRoomListIndex(nil)
95
+ if futureRoomListIndex ~= roomListIndex then
96
+ return
97
+ end
93
98
  v.room.manuallyUsingShovel = true
94
99
  futurePlayer:UseActiveItem(CollectibleType.WE_NEED_TO_GO_DEEPER)
95
100
  v.room.manuallyUsingShovel = false
96
101
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
97
102
  emptyArray(nil, decorationGridIndexes)
98
- fillRoomWithDecorations(nil)
103
+ ____exports.preventGridEntityRespawn(nil)
99
104
  end
100
105
  )
101
106
  return true
@@ -137,24 +142,43 @@ function respawnPersistentEntities(self)
137
142
  )
138
143
  end
139
144
  end
140
- function fillRoomWithDecorations(self)
145
+ --- Helper function to prevent any removed grid entities from respawning if the player re-enters the
146
+ -- room.
147
+ --
148
+ -- This is accomplished by spawning a new grid entity on every tile that does not already have a
149
+ -- grid entity. This will force the game to spawn the new grid entity instead of the old one. The
150
+ -- natural grid entity to choose for this purpose is a decoration, since it is non-interacting.
151
+ -- Then, the decorations are made invisible and any shovel uses are intercepted to avoid creating a
152
+ -- crawl space (instead of a trapdoor).
153
+ --
154
+ -- Another option besides decorations would be to use a pressure plates with a state of 1, which is
155
+ -- a state that is normally unused by the game and makes it invisible & persistent. However, pickups
156
+ -- will not be able to spawn on pressure plates, which lead to various bugs (e.g. pickups spawning
157
+ -- on top of pits). Thus, using a decoration is preferable.
158
+ --
159
+ -- Yet another option to accomplish this would be to replace the room data with that of an empty
160
+ -- room. However, the room data must exactly match the room type, the room shape, and the doors, so
161
+ -- this is not possible to do in a robust way without adding empty rooms to the mod's `content`
162
+ -- folder to draw the data from.
163
+ function ____exports.preventGridEntityRespawn(self)
164
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
141
165
  local room = game:GetRoom()
142
166
  local roomListIndex = getRoomListIndex(nil)
167
+ v.level.deployedRoomListIndexes:add(roomListIndex)
143
168
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
144
169
  for ____, gridIndex in ipairs(getAllGridIndexes(nil)) do
145
170
  do
146
171
  local existingGridEntity = room:GetGridEntity(gridIndex)
147
172
  if existingGridEntity ~= nil then
148
- goto __continue31
173
+ goto __continue32
149
174
  end
150
- local position = room:GetGridPosition(gridIndex)
151
- local decoration = Isaac.GridSpawn(GridEntityType.DECORATION, 0, position)
175
+ local decoration = spawnGridEntity(nil, GridEntityType.DECORATION, gridIndex)
152
176
  if decoration ~= nil then
153
177
  setGridEntityInvisible(nil, decoration)
154
178
  end
155
179
  decorationGridIndexes[#decorationGridIndexes + 1] = gridIndex
156
180
  end
157
- ::__continue31::
181
+ ::__continue32::
158
182
  end
159
183
  end
160
184
  function spawnAllEntities(self, jsonRoom, rng, verbose)
@@ -411,7 +435,7 @@ function getPitFrame(self, L, R, U, D, UL, UR, DL, DR)
411
435
  end
412
436
  return F
413
437
  end
414
- local FEATURE_NAME = "deployJSONRoom"
438
+ FEATURE_NAME = "deployJSONRoom"
415
439
  PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.WALL_HUGGER})
416
440
  local gridEntityXMLTypes = getEnumValues(nil, GridEntityXMLType)
417
441
  GRID_ENTITY_XML_TYPE_SET = __TS__New(Set, gridEntityXMLTypes)
@@ -489,7 +513,7 @@ function ____exports.deployJSONRoom(self, jsonRoom, seedOrRNG, verbose)
489
513
  log(nil, "Finished spawning all of the new entities and grid entities.")
490
514
  end
491
515
  fixPitGraphics(nil)
492
- fillRoomWithDecorations(nil)
516
+ ____exports.preventGridEntityRespawn(nil)
493
517
  end
494
518
  --- Helper function to deconstruct a vanilla room and set up a custom room in its place.
495
519
  -- Specifically, this will clear the current room of all entities and grid entities, and then spawn
@@ -1 +1 @@
1
- {"version":3,"file":"emptyRoom.d.ts","sourceRoot":"","sources":["../../../src/functions/emptyRoom.ts"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAGhC"}
1
+ {"version":3,"file":"emptyRoom.d.ts","sourceRoot":"","sources":["../../../src/functions/emptyRoom.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAGhC"}
@@ -2,7 +2,7 @@ local ____lualib = require("lualib_bundle")
2
2
  local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
- local emptyRoomEntities, emptyRoomGridEntities, EMPTY_ROOM_BLACKLIST_ENTITY_SET, EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET
5
+ local emptyRoomEntities, emptyRoomGridEntities, EMPTY_ROOM_BLACKLIST_ENTITY_SET
6
6
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
7
  local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
8
8
  local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
@@ -16,6 +16,8 @@ local getGridEntities = ____gridEntities.getGridEntities
16
16
  local removeGridEntity = ____gridEntities.removeGridEntity
17
17
  local ____rooms = require("src.functions.rooms")
18
18
  local roomUpdateSafe = ____rooms.roomUpdateSafe
19
+ local ____roomShapeWalls = require("src.functions.roomShapeWalls")
20
+ local isVanillaWallGridIndex = ____roomShapeWalls.isVanillaWallGridIndex
19
21
  function emptyRoomEntities(self)
20
22
  local room = game:GetRoom()
21
23
  for ____, entity in ipairs(getEntities(nil)) do
@@ -41,7 +43,11 @@ function emptyRoomGridEntities(self)
41
43
  for ____, gridEntity in ipairs(getGridEntities(nil)) do
42
44
  do
43
45
  local gridEntityType = gridEntity:GetType()
44
- if EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET:has(gridEntityType) then
46
+ local gridIndex = gridEntity:GetGridIndex()
47
+ if gridEntityType == GridEntityType.WALL and isVanillaWallGridIndex(nil, gridIndex) then
48
+ goto __continue10
49
+ end
50
+ if gridEntityType == GridEntityType.DOOR then
45
51
  goto __continue10
46
52
  end
47
53
  removeGridEntity(nil, gridEntity, false)
@@ -62,7 +68,6 @@ EMPTY_ROOM_BLACKLIST_ENTITY_SET = __TS__New(Set, {
62
68
  EntityType.PROJECTILE,
63
69
  EntityType.DARK_ESAU
64
70
  })
65
- EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET = __TS__New(Set, {GridEntityType.WALL, GridEntityType.DOOR})
66
71
  --- Helper function to remove all naturally spawning entities and grid entities from a room. Notably,
67
72
  -- this will not remove players (1), tears (2), familiars (3), lasers (7), knives (8), projectiles
68
73
  -- (9), blacklisted NPCs such as Dark Esau, charmed NPCs, friendly NPCs, persistent NPCs, most
@@ -1,13 +1,4 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- /// <reference types="isaac-typescript-definitions" />
3
- /**
4
- * Helper function to determine if a given wall is a "real" wall generated by the vanilla game. This
5
- * is useful because mods can use custom spawned walls as a stand-in for custom grid entities.
6
- *
7
- * This function checks for identity via a combination of `StageAPI.IsCustomGrid` and the
8
- * `isVanillaWallGridIndex` function.
9
- */
10
- export declare function isVanillaWall(gridEntity: GridEntity): boolean;
11
2
  /**
12
3
  * Helper function to determine if a given grid index should have a wall generated by the vanilla
13
4
  * game. This is useful as a mechanism to distinguish between real walls and custom walls spawned by
@@ -1 +1 @@
1
- {"version":3,"file":"roomShapeWalls.d.ts","sourceRoot":"","sources":["../../../src/functions/roomShapeWalls.ts"],"names":[],"mappings":";;AAwTA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAQ7D;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO,CAqB9D"}
1
+ {"version":3,"file":"roomShapeWalls.d.ts","sourceRoot":"","sources":["../../../src/functions/roomShapeWalls.ts"],"names":[],"mappings":";AAwTA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO,CAqB9D"}
@@ -6,7 +6,7 @@ local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
6
6
  local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
7
7
  local Set = ____lualib.Set
8
8
  local ____exports = {}
9
- local getRoomShapeToWallGridIndexSet, getVanillaWallGridIndexSetForRoomShape, getWallGridIndexSetForRectangleRoomShape, ROOM_SHAPE_TO_WALL_GRID_INDEX_SET, HOME_CLOSET_CORNERS_SET, MOTHER_ROOM_CORNERS_SET
9
+ local getRoomShapeToWallGridIndexSet, getVanillaWallGridIndexSetForRoomShape, getWallGridIndexSetForRectangleRoomShape
10
10
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
11
11
  local BossID = ____isaac_2Dtypescript_2Ddefinitions.BossID
12
12
  local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
@@ -199,29 +199,7 @@ function getWallGridIndexSetForRectangleRoomShape(self, roomShape, corners)
199
199
  {__TS__SparseArraySpread(____array_8)}
200
200
  )
201
201
  end
202
- --- Helper function to determine if a given grid index should have a wall generated by the vanilla
203
- -- game. This is useful as a mechanism to distinguish between real walls and custom walls spawned by
204
- -- mods.
205
- --
206
- -- This function properly handles the special cases of the Mother boss room and the Home closet
207
- -- rooms, which are both non-standard room shapes.
208
- function ____exports.isVanillaWallGridIndex(self, gridIndex)
209
- local room = game:GetRoom()
210
- local roomShape = room:GetRoomShape()
211
- local wallGridIndexSet
212
- if inHomeCloset(nil) then
213
- wallGridIndexSet = HOME_CLOSET_CORNERS_SET
214
- elseif inBossRoomOf(nil, BossID.MOTHER) then
215
- wallGridIndexSet = MOTHER_ROOM_CORNERS_SET
216
- else
217
- wallGridIndexSet = ROOM_SHAPE_TO_WALL_GRID_INDEX_SET:get(roomShape)
218
- end
219
- if wallGridIndexSet == nil then
220
- error(((("Failed to find the wall grid index set for: RoomShape." .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ")")
221
- end
222
- return wallGridIndexSet:has(gridIndex)
223
- end
224
- ROOM_SHAPE_TO_WALL_GRID_INDEX_SET = getRoomShapeToWallGridIndexSet(nil)
202
+ local ROOM_SHAPE_TO_WALL_GRID_INDEX_SET = getRoomShapeToWallGridIndexSet(nil)
225
203
  --- The Home closet is is 9x3, which is different from `RoomShape.IH` (which is 13x3).
226
204
  local HOME_CLOSET_CORNERS = {
227
205
  {
@@ -245,7 +223,7 @@ local HOME_CLOSET_CORNERS = {
245
223
  position = Vector(340, 340)
246
224
  }
247
225
  }
248
- HOME_CLOSET_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(nil, RoomShape.IH, HOME_CLOSET_CORNERS)
226
+ local HOME_CLOSET_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(nil, RoomShape.IH, HOME_CLOSET_CORNERS)
249
227
  --- The Mother Boss Room is 15x11, which is different from `RoomShape.SHAPE_1x2` (which is 15x16).
250
228
  local MOTHER_ROOM_CORNERS = {
251
229
  {
@@ -269,17 +247,27 @@ local MOTHER_ROOM_CORNERS = {
269
247
  position = Vector(580, 500)
270
248
  }
271
249
  }
272
- MOTHER_ROOM_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(nil, RoomShape.SHAPE_1x2, MOTHER_ROOM_CORNERS)
273
- --- Helper function to determine if a given wall is a "real" wall generated by the vanilla game. This
274
- -- is useful because mods can use custom spawned walls as a stand-in for custom grid entities.
250
+ local MOTHER_ROOM_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(nil, RoomShape.SHAPE_1x2, MOTHER_ROOM_CORNERS)
251
+ --- Helper function to determine if a given grid index should have a wall generated by the vanilla
252
+ -- game. This is useful as a mechanism to distinguish between real walls and custom walls spawned by
253
+ -- mods.
275
254
  --
276
- -- This function checks for identity via a combination of `StageAPI.IsCustomGrid` and the
277
- -- `isVanillaWallGridIndex` function.
278
- function ____exports.isVanillaWall(self, gridEntity)
279
- local gridIndex = gridEntity:GetGridIndex()
280
- if StageAPI ~= nil and StageAPI.IsCustomGrid(gridIndex) then
281
- return false
255
+ -- This function properly handles the special cases of the Mother boss room and the Home closet
256
+ -- rooms, which are both non-standard room shapes.
257
+ function ____exports.isVanillaWallGridIndex(self, gridIndex)
258
+ local room = game:GetRoom()
259
+ local roomShape = room:GetRoomShape()
260
+ local wallGridIndexSet
261
+ if inHomeCloset(nil) then
262
+ wallGridIndexSet = HOME_CLOSET_CORNERS_SET
263
+ elseif inBossRoomOf(nil, BossID.MOTHER) then
264
+ wallGridIndexSet = MOTHER_ROOM_CORNERS_SET
265
+ else
266
+ wallGridIndexSet = ROOM_SHAPE_TO_WALL_GRID_INDEX_SET:get(roomShape)
282
267
  end
283
- return ____exports.isVanillaWallGridIndex(nil, gridIndex)
268
+ if wallGridIndexSet == nil then
269
+ error(((("Failed to find the wall grid index set for: RoomShape." .. tostring(RoomShape[roomShape])) .. " (") .. tostring(roomShape)) .. ")")
270
+ end
271
+ return wallGridIndexSet:has(gridIndex)
284
272
  end
285
273
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "13.1.0",
3
+ "version": "13.2.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -36,6 +36,7 @@ import {
36
36
  getGridEntities,
37
37
  removeGridEntity,
38
38
  setGridEntityInvisible,
39
+ spawnGridEntity,
39
40
  spawnGridEntityWithVariant,
40
41
  } from "../functions/gridEntities";
41
42
  import { getRandomJSONEntity, getRandomJSONRoom } from "../functions/jsonRoom";
@@ -145,6 +146,11 @@ function preUseItemWeNeedToGoDeeper(
145
146
  return;
146
147
  }
147
148
 
149
+ const futureRoomListIndex = getRoomListIndex();
150
+ if (futureRoomListIndex !== roomListIndex) {
151
+ return;
152
+ }
153
+
148
154
  v.room.manuallyUsingShovel = true;
149
155
  futurePlayer.UseActiveItem(CollectibleType.WE_NEED_TO_GO_DEEPER);
150
156
  v.room.manuallyUsingShovel = false;
@@ -152,7 +158,7 @@ function preUseItemWeNeedToGoDeeper(
152
158
  const decorationGridIndexes =
153
159
  v.level.roomToDecorationGridIndexesMap.getAndSetDefault(roomListIndex);
154
160
  emptyArray(decorationGridIndexes);
155
- fillRoomWithDecorations();
161
+ preventGridEntityRespawn();
156
162
  });
157
163
 
158
164
  // Cancel the original effect.
@@ -273,7 +279,7 @@ export function deployJSONRoom(
273
279
  }
274
280
 
275
281
  fixPitGraphics();
276
- fillRoomWithDecorations();
282
+ preventGridEntityRespawn();
277
283
  }
278
284
 
279
285
  /**
@@ -328,27 +334,35 @@ export function deployRandomJSONRoom(
328
334
  }
329
335
 
330
336
  /**
331
- * We removed most normal entities, which should prevent them from respawning when the player
332
- * re-enters the room. However, this is not the case for grid entities; even if they are removed,
333
- * they will come back when the player re-enters the room.
337
+ * Helper function to prevent any removed grid entities from respawning if the player re-enters the
338
+ * room.
334
339
  *
335
- * In order to prevent this from happening, we can spawn a grid entity on every tile that does not
336
- * already have a grid entity. The natural grid entity to choose for this purpose is a decoration,
337
- * since it is non-interacting.
340
+ * This is accomplished by spawning a new grid entity on every tile that does not already have a
341
+ * grid entity. This will force the game to spawn the new grid entity instead of the old one. The
342
+ * natural grid entity to choose for this purpose is a decoration, since it is non-interacting.
343
+ * Then, the decorations are made invisible and any shovel uses are intercepted to avoid creating a
344
+ * crawl space (instead of a trapdoor).
338
345
  *
339
346
  * Another option besides decorations would be to use a pressure plates with a state of 1, which is
340
347
  * a state that is normally unused by the game and makes it invisible & persistent. However, pickups
341
348
  * will not be able to spawn on pressure plates, which lead to various bugs (e.g. pickups spawning
342
- * on top of pits). Thus, we use a decoration and remove its sprite to make it invisible.
349
+ * on top of pits). Thus, using a decoration is preferable.
343
350
  *
344
- * Yet another option is to replace the room data with that of an empty room. However, the room data
345
- * must exactly match the room type, the room shape, and the doors, so this is not possible to do in
346
- * a robust way without adding empty rooms to the mod's `content` folder to draw the data from.
351
+ * Yet another option to accomplish this would be to replace the room data with that of an empty
352
+ * room. However, the room data must exactly match the room type, the room shape, and the doors, so
353
+ * this is not possible to do in a robust way without adding empty rooms to the mod's `content`
354
+ * folder to draw the data from.
347
355
  */
348
- function fillRoomWithDecorations() {
356
+ export function preventGridEntityRespawn(): void {
357
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
358
+
349
359
  const room = game.GetRoom();
350
360
  const roomListIndex = getRoomListIndex();
351
361
 
362
+ // Ensure that this room is in the deployed room set, or else the shovel interception code will
363
+ // not work properly.
364
+ v.level.deployedRoomListIndexes.add(roomListIndex);
365
+
352
366
  const decorationGridIndexes =
353
367
  v.level.roomToDecorationGridIndexesMap.getAndSetDefault(roomListIndex);
354
368
 
@@ -358,9 +372,7 @@ function fillRoomWithDecorations() {
358
372
  continue;
359
373
  }
360
374
 
361
- const position = room.GetGridPosition(gridIndex);
362
- const decoration = Isaac.GridSpawn(GridEntityType.DECORATION, 0, position);
363
-
375
+ const decoration = spawnGridEntity(GridEntityType.DECORATION, gridIndex);
364
376
  if (decoration !== undefined) {
365
377
  setGridEntityInvisible(decoration);
366
378
  }
@@ -7,6 +7,7 @@ import { game } from "../core/cachedClasses";
7
7
  import { getEntities } from "./entities";
8
8
  import { getGridEntities, removeGridEntity } from "./gridEntities";
9
9
  import { roomUpdateSafe } from "./rooms";
10
+ import { isVanillaWallGridIndex } from "./roomShapeWalls";
10
11
 
11
12
  const EMPTY_ROOM_BLACKLIST_ENTITY_SET: ReadonlySet<EntityType> = new Set([
12
13
  EntityType.PLAYER, // 1
@@ -18,12 +19,6 @@ const EMPTY_ROOM_BLACKLIST_ENTITY_SET: ReadonlySet<EntityType> = new Set([
18
19
  EntityType.DARK_ESAU, // 866
19
20
  ]);
20
21
 
21
- const EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET: ReadonlySet<GridEntityType> =
22
- new Set([
23
- GridEntityType.WALL, // 15
24
- GridEntityType.DOOR, // 16
25
- ]);
26
-
27
22
  /**
28
23
  * Helper function to remove all naturally spawning entities and grid entities from a room. Notably,
29
24
  * this will not remove players (1), tears (2), familiars (3), lasers (7), knives (8), projectiles
@@ -68,11 +63,23 @@ function emptyRoomEntities() {
68
63
  }
69
64
  }
70
65
 
66
+ /** We want to remove all grid entities except for walls and doors. */
71
67
  function emptyRoomGridEntities() {
72
68
  let removedOneOrMoreGridEntities = false;
73
69
  for (const gridEntity of getGridEntities()) {
74
70
  const gridEntityType = gridEntity.GetType();
75
- if (EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET.has(gridEntityType)) {
71
+ const gridIndex = gridEntity.GetGridIndex();
72
+
73
+ // We cannot simply check if the grid entity type is equal to a wall because other mods use
74
+ // walls as a base for custom grid entities.
75
+ if (
76
+ gridEntityType === GridEntityType.WALL &&
77
+ isVanillaWallGridIndex(gridIndex)
78
+ ) {
79
+ continue;
80
+ }
81
+
82
+ if (gridEntityType === GridEntityType.DOOR) {
76
83
  continue;
77
84
  }
78
85
 
@@ -310,23 +310,6 @@ const MOTHER_ROOM_CORNERS_SET = getWallGridIndexSetForRectangleRoomShape(
310
310
  MOTHER_ROOM_CORNERS,
311
311
  );
312
312
 
313
- /**
314
- * Helper function to determine if a given wall is a "real" wall generated by the vanilla game. This
315
- * is useful because mods can use custom spawned walls as a stand-in for custom grid entities.
316
- *
317
- * This function checks for identity via a combination of `StageAPI.IsCustomGrid` and the
318
- * `isVanillaWallGridIndex` function.
319
- */
320
- export function isVanillaWall(gridEntity: GridEntity): boolean {
321
- const gridIndex = gridEntity.GetGridIndex();
322
-
323
- if (StageAPI !== undefined && StageAPI.IsCustomGrid(gridIndex)) {
324
- return false;
325
- }
326
-
327
- return isVanillaWallGridIndex(gridIndex);
328
- }
329
-
330
313
  /**
331
314
  * Helper function to determine if a given grid index should have a wall generated by the vanilla
332
315
  * game. This is useful as a mechanism to distinguish between real walls and custom walls spawned by