local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local CrawlSpaceVariant = ____isaac_2Dtypescript_2Ddefinitions.CrawlSpaceVariant
local DoorVariant = ____isaac_2Dtypescript_2Ddefinitions.DoorVariant
local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
local PitVariant = ____isaac_2Dtypescript_2Ddefinitions.PitVariant
local PoopGridEntityVariant = ____isaac_2Dtypescript_2Ddefinitions.PoopGridEntityVariant
local PressurePlateVariant = ____isaac_2Dtypescript_2Ddefinitions.PressurePlateVariant
local RockVariant = ____isaac_2Dtypescript_2Ddefinitions.RockVariant
local ____gridEntities = require("functions.gridEntities")
local getGridEntities = ____gridEntities.getGridEntities
local getMatchingGridEntities = ____gridEntities.getMatchingGridEntities
local removeGridEntities = ____gridEntities.removeGridEntities
local spawnGridEntityWithVariant = ____gridEntities.spawnGridEntityWithVariant
local ____utils = require("functions.utils")
local assertDefined = ____utils.assertDefined
--- Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18) with a specific variant.
function ____exports.spawnCrawlSpaceWithVariant(self, crawlSpaceVariant, gridIndexOrPosition)
    return spawnGridEntityWithVariant(nil, GridEntityType.CRAWL_SPACE, crawlSpaceVariant, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.DOOR` (16).
function ____exports.spawnDoorWithVariant(self, doorVariant, gridIndexOrPosition)
    local gridEntity = spawnGridEntityWithVariant(nil, GridEntityType.DOOR, doorVariant, gridIndexOrPosition)
    if gridEntity == nil then
        return nil
    end
    local door = gridEntity:ToDoor()
    assertDefined(nil, door, "Failed to spawn a door.")
    return door
end
--- Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant.
function ____exports.spawnPitWithVariant(self, pitVariant, gridIndexOrPosition)
    local gridEntity = spawnGridEntityWithVariant(nil, GridEntityType.PIT, pitVariant, gridIndexOrPosition)
    if gridEntity == nil then
        return nil
    end
    local pit = gridEntity:ToPit()
    assertDefined(nil, pit, "Failed to spawn a pit.")
    return pit
end
--- Helper function to spawn a `GridEntityType.POOP` (14) with a specific variant.
function ____exports.spawnPoopWithVariant(self, poopVariant, gridIndexOrPosition)
    local gridEntity = spawnGridEntityWithVariant(nil, GridEntityType.POOP, poopVariant, gridIndexOrPosition)
    if gridEntity == nil then
        return nil
    end
    local poop = gridEntity:ToPoop()
    assertDefined(nil, poop, "Failed to spawn a poop.")
    return poop
end
--- Helper function to spawn a `GridEntityType.PRESSURE_PLATE` (20) with a specific variant.
function ____exports.spawnPressurePlateWithVariant(self, pressurePlateVariant, gridIndexOrPosition)
    local gridEntity = spawnGridEntityWithVariant(nil, GridEntityType.PRESSURE_PLATE, pressurePlateVariant, gridIndexOrPosition)
    if gridEntity == nil then
        return nil
    end
    local pressurePlate = gridEntity:ToPressurePlate()
    assertDefined(nil, pressurePlate, "Failed to spawn a pressure plate.")
    return pressurePlate
end
--- Helper function to spawn a `GridEntityType.ROCK` (2) with a specific variant.
function ____exports.spawnRockWithVariant(self, rockVariant, gridIndexOrPosition)
    local gridEntity = spawnGridEntityWithVariant(nil, GridEntityType.ROCK, rockVariant, gridIndexOrPosition)
    if gridEntity == nil then
        return nil
    end
    local rock = gridEntity:ToRock()
    assertDefined(nil, rock, "Failed to spawn a rock.")
    return rock
end
--- Helper function to spawn a `GridEntityType.SPIKES` (8) with a specific variant.
function ____exports.spawnSpikesWithVariant(self, variant, gridIndexOrPosition)
    local gridEntity = spawnGridEntityWithVariant(nil, GridEntityType.SPIKES, variant, gridIndexOrPosition)
    if gridEntity == nil then
        return nil
    end
    local spikes = gridEntity:ToSpikes()
    assertDefined(nil, spikes, "Failed to spawn spikes.")
    return spikes
end
--- Helper function to spawn a `GridEntityType.TNT` (12) with a specific variant.
function ____exports.spawnTNTWithVariant(self, variant, gridIndexOrPosition)
    local gridEntity = spawnGridEntityWithVariant(nil, GridEntityType.TNT, variant, gridIndexOrPosition)
    if gridEntity == nil then
        return nil
    end
    local tnt = gridEntity:ToTNT()
    assertDefined(nil, tnt, "Failed to spawn TNT.")
    return tnt
end
--- Helper function to spawn a `GridEntityType.TELEPORTER` (23) with a specific variant.
function ____exports.spawnTeleporterWithVariant(self, variant, gridIndexOrPosition)
    return spawnGridEntityWithVariant(nil, GridEntityType.TELEPORTER, variant, gridIndexOrPosition)
end
--- Helper function to get all of the grid entities of type `GridEntityType.CRAWL_SPACE` (18) in the
-- room.
-- 
-- @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
-- variant. Default is -1, which matches every variant.
function ____exports.getCrawlSpaces(self, crawlSpaceVariant)
    if crawlSpaceVariant == nil then
        crawlSpaceVariant = -1
    end
    if crawlSpaceVariant == -1 then
        return getGridEntities(nil, GridEntityType.CRAWL_SPACE)
    end
    return getMatchingGridEntities(nil, GridEntityType.CRAWL_SPACE, crawlSpaceVariant)
end
--- Helper function to get all of the `GridEntityPit` in the room.
-- 
-- @param pitVariant Optional. If specified, will only get the pits that match the variant. Default
-- is -1, which matches every variant.
function ____exports.getPits(self, pitVariant)
    if pitVariant == nil then
        pitVariant = -1
    end
    local pits = {}
    for ____, gridEntity in ipairs(getGridEntities(nil)) do
        local pit = gridEntity:ToPit()
        if pit ~= nil then
            local thisPitVariant = pit:GetVariant()
            if pitVariant == -1 or pitVariant == thisPitVariant then
                pits[#pits + 1] = pit
            end
        end
    end
    return pits
end
--- Helper function to get all of the `GridEntityPoop` in the room.
-- 
-- @param poopVariant Optional. If specified, will only get the poops that match the variant.
-- Default is -1, which matches every variant.
function ____exports.getPoops(self, poopVariant)
    if poopVariant == nil then
        poopVariant = -1
    end
    local poops = {}
    for ____, gridEntity in ipairs(getGridEntities(nil)) do
        local poop = gridEntity:ToPoop()
        if poop ~= nil then
            local thisPoopVariant = poop:GetVariant()
            if poopVariant == -1 or poopVariant == thisPoopVariant then
                poops[#poops + 1] = poop
            end
        end
    end
    return poops
end
--- Helper function to get all of the `GridEntityPressurePlate` in the room.
-- 
-- @param pressurePlateVariant Optional. If specified, will only get the pressure plates that match
-- the variant. Default is -1, which matches every variant.
function ____exports.getPressurePlates(self, pressurePlateVariant)
    if pressurePlateVariant == nil then
        pressurePlateVariant = -1
    end
    local pressurePlates = {}
    for ____, gridEntity in ipairs(getGridEntities(nil)) do
        local pressurePlate = gridEntity:ToPressurePlate()
        if pressurePlate ~= nil then
            local thisPressurePlateVariant = pressurePlate:GetVariant()
            if pressurePlateVariant == -1 or pressurePlateVariant == thisPressurePlateVariant then
                pressurePlates[#pressurePlates + 1] = pressurePlate
            end
        end
    end
    return pressurePlates
end
--- Helper function to get all of the `GridEntityRock` in the room.
-- 
-- @param variant Optional. If specified, will only get the rocks that match the variant. Default is
-- -1, which matches every variant. Note that this is not the same thing as the
-- `RockVariant` enum, since that only applies to `GridEntityType.ROCK`, and other
-- types of grid entities can be the `GridEntityRock` class.
function ____exports.getRocks(self, variant)
    if variant == nil then
        variant = -1
    end
    local rocks = {}
    for ____, gridEntity in ipairs(getGridEntities(nil)) do
        local rock = gridEntity:ToRock()
        if rock ~= nil then
            local thisVariant = rock:GetVariant()
            if variant == -1 or variant == thisVariant then
                rocks[#rocks + 1] = rock
            end
        end
    end
    return rocks
end
--- Helper function to get all of the `GridEntitySpikes` in the room.
function ____exports.getSpikes(self, variant)
    if variant == nil then
        variant = -1
    end
    local spikes = {}
    for ____, gridEntity in ipairs(getGridEntities(nil)) do
        local spike = gridEntity:ToSpikes()
        if spike ~= nil then
            local thisVariant = spike:GetVariant()
            if variant == -1 or variant == thisVariant then
                spikes[#spikes + 1] = spike
            end
        end
    end
    return spikes
end
--- Helper function to get all of the `GridEntityTNT` in the room.
function ____exports.getTNT(self, variant)
    if variant == nil then
        variant = -1
    end
    local tntArray = {}
    for ____, gridEntity in ipairs(getGridEntities(nil)) do
        local tnt = gridEntity:ToTNT()
        if tnt ~= nil then
            local thisVariant = tnt:GetVariant()
            if variant == -1 or variant == thisVariant then
                tntArray[#tntArray + 1] = tnt
            end
        end
    end
    return tntArray
end
--- Helper function to get all of the grid entities of type `GridEntityType.TELEPORTER` (23) in the
-- room.
-- 
-- @param variant Optional. If specified, will only get the teleporters that match the variant.
-- Default is -1, which matches every variant.
function ____exports.getTeleporters(self, variant)
    if variant == nil then
        variant = -1
    end
    if variant == -1 then
        return getGridEntities(nil, GridEntityType.TELEPORTER)
    end
    return getMatchingGridEntities(nil, GridEntityType.TELEPORTER, variant)
end
--- Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` (17) in the
-- room. Specify a specific trapdoor variant to select only trapdoors of that variant.
-- 
-- @param trapdoorVariant Optional. If specified, will only get the trapdoors that match the
-- variant. Default is -1, which matches every variant.
function ____exports.getTrapdoors(self, trapdoorVariant)
    if trapdoorVariant == nil then
        trapdoorVariant = -1
    end
    if trapdoorVariant == -1 then
        return getGridEntities(nil, GridEntityType.TRAPDOOR)
    end
    return getMatchingGridEntities(nil, GridEntityType.TRAPDOOR, trapdoorVariant)
end
--- Helper function to remove all of the `GridEntityType.CRAWL_SPACE` (18) in the room.
-- 
-- @param crawlSpaceVariant Optional. If specified, will only remove the crawl spaces that match
-- this variant. Default is -1, which matches every variant.
-- @param updateRoom Optional. Whether to update the room after the crawl spaces are removed.
-- Default is false. For more information, see the description of the
-- `removeGridEntities` helper function.
-- @param cap Optional. If specified, will only remove the given amount of crawl spaces.
-- @returns The crawl spaces that were removed.
function ____exports.removeAllCrawlSpaces(self, crawlSpaceVariant, updateRoom, cap)
    if crawlSpaceVariant == nil then
        crawlSpaceVariant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local crawlSpaces = ____exports.getCrawlSpaces(nil, crawlSpaceVariant)
    return removeGridEntities(nil, crawlSpaces, updateRoom, cap)
end
--- Helper function to remove all of the `GridEntityPit` in the room.
-- 
-- @param pitVariant Optional. If specified, will only remove the pits that match this variant.
-- Default is -1, which matches every variant.
-- @param updateRoom Optional. Whether to update the room after the pits are removed. Default is
-- false. For more information, see the description of the `removeGridEntities`
-- helper function.
-- @param cap Optional. If specified, will only remove the given amount of pits.
-- @returns The pits that were removed.
function ____exports.removeAllPits(self, pitVariant, updateRoom, cap)
    if pitVariant == nil then
        pitVariant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local pits = ____exports.getPits(nil, pitVariant)
    return removeGridEntities(nil, pits, updateRoom, cap)
end
--- Helper function to remove all of the `GridEntityPoop` in the room.
-- 
-- Note that poops can either be an entity or a grid entity, depending on the situation. This
-- function will only remove the grid entity poops.
-- 
-- @param poopVariant Optional. If specified, will only remove the poops that match this variant.
-- Default is -1, which matches every variant.
-- @param updateRoom Optional. Whether to update the room after the poops are removed. Default is
-- false. For more information, see the description of the `removeGridEntities`
-- helper function.
-- @param cap Optional. If specified, will only remove the given amount of poops.
-- @returns The poops that were removed.
function ____exports.removeAllPoops(self, poopVariant, updateRoom, cap)
    if poopVariant == nil then
        poopVariant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local poops = ____exports.getPoops(nil, poopVariant)
    return removeGridEntities(nil, poops, updateRoom, cap)
end
--- Helper function to remove all of the `GridEntityPressurePlate` in the room.
-- 
-- @param pressurePlateVariant Optional. If specified, will only remove the pressure plates that
-- match this variant. Default is -1, which matches every variant.
-- @param updateRoom Optional. Whether to update the room after the pressure plates are removed.
-- Default is false. For more information, see the description of the
-- `removeGridEntities` helper function.
-- @param cap Optional. If specified, will only remove the given amount of pressure plates.
-- @returns The pressure plates that were removed.
function ____exports.removeAllPressurePlates(self, pressurePlateVariant, updateRoom, cap)
    if pressurePlateVariant == nil then
        pressurePlateVariant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local pressurePlates = ____exports.getPressurePlates(nil, pressurePlateVariant)
    return removeGridEntities(nil, pressurePlates, updateRoom, cap)
end
--- Helper function to remove all of the `GridEntityRock` in the room.
-- 
-- @param variant Optional. If specified, will only remove the rocks that match this variant.
-- Default is -1, which matches every variant. Note that this is not the same thing
-- as the `RockVariant` enum, since that only applies to `GridEntityType.ROCK`, and
-- other types of grid entities can be the `GridEntityRock` class.
-- @param updateRoom Optional. Whether to update the room after the rocks are removed. Default is
-- false. For more information, see the description of the `removeGridEntities`
-- helper function.
-- @param cap Optional. If specified, will only remove the given amount of rocks.
-- @returns The rocks that were removed.
function ____exports.removeAllRocks(self, variant, updateRoom, cap)
    if variant == nil then
        variant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local rocks = ____exports.getRocks(nil, variant)
    return removeGridEntities(nil, rocks, updateRoom, cap)
end
--- Helper function to remove all of the `GridEntitySpikes` in the room.
-- 
-- @param variant Optional. If specified, will only remove the spikes that match this variant.
-- Default is -1, which matches every variant.
-- @param updateRoom Optional. Whether to update the room after the spikes are removed. Default is
-- false. For more information, see the description of the `removeGridEntities`
-- helper function.
-- @param cap Optional. If specified, will only remove the given amount of spikes.
-- @returns The spikes that were removed.
function ____exports.removeAllSpikes(self, variant, updateRoom, cap)
    if variant == nil then
        variant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local spikes = ____exports.getSpikes(nil, variant)
    return removeGridEntities(nil, spikes, updateRoom, cap)
end
--- Helper function to remove all of the `GridEntityTNT` in the room.
-- 
-- @param variant Optional. If specified, will only remove the TNTs that match this variant. Default
-- is -1, which matches every variant.
-- @param updateRoom Optional. Whether to update the room after the TNTs are removed. Default is
-- false. For more information, see the description of the `removeGridEntities`
-- helper function.
-- @param cap Optional. If specified, will only remove the given amount of TNTs.
-- @returns The TNTs that were removed.
function ____exports.removeAllTNT(self, variant, updateRoom, cap)
    if variant == nil then
        variant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local tnt = ____exports.getTNT(nil, variant)
    return removeGridEntities(nil, tnt, updateRoom, cap)
end
--- Helper function to remove all of the `GridEntityType.TELEPORTER` (23) in the room.
-- 
-- @param variant Optional. If specified, will only remove the teleporters that match this variant.
-- Default is -1, which matches every variant.
-- @param updateRoom Optional. Whether to update the room after the teleporters are removed. Default
-- is false. For more information, see the description of the `removeGridEntities`
-- helper function.
-- @param cap Optional. If specified, will only remove the given amount of teleporters.
-- @returns The teleporters that were removed.
function ____exports.removeAllTeleporters(self, variant, updateRoom, cap)
    if variant == nil then
        variant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local teleporters = ____exports.getTeleporters(nil, variant)
    return removeGridEntities(nil, teleporters, updateRoom, cap)
end
--- Helper function to remove all of the `GridEntityType.TRAPDOOR` (17) in the room.
-- 
-- @param trapdoorVariant Optional. If specified, will only remove the trapdoors that match this
-- variant. Default is -1, which matches every variant.
-- @param updateRoom Optional. Whether to update the room after the trapdoors are removed. Default
-- is false. For more information, see the description of the `removeGridEntities`
-- helper function.
-- @param cap Optional. If specified, will only remove the given amount of trapdoors.
-- @returns The trapdoors that were removed.
function ____exports.removeAllTrapdoors(self, trapdoorVariant, updateRoom, cap)
    if trapdoorVariant == nil then
        trapdoorVariant = -1
    end
    if updateRoom == nil then
        updateRoom = false
    end
    local trapdoors = ____exports.getTrapdoors(nil, trapdoorVariant)
    return removeGridEntities(nil, trapdoors, updateRoom, cap)
end
--- Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18).
function ____exports.spawnCrawlSpace(self, gridIndexOrPosition)
    return ____exports.spawnCrawlSpaceWithVariant(nil, CrawlSpaceVariant.NORMAL, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant.
function ____exports.spawnDoor(self, gridIndexOrPosition)
    return ____exports.spawnDoorWithVariant(nil, DoorVariant.UNSPECIFIED, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant.
function ____exports.spawnPit(self, gridIndexOrPosition)
    return ____exports.spawnPitWithVariant(nil, PitVariant.NORMAL, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.POOP` (14).
function ____exports.spawnPoop(self, gridIndexOrPosition)
    return ____exports.spawnPoopWithVariant(nil, PoopGridEntityVariant.NORMAL, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.PRESSURE_PLATE` (20).
function ____exports.spawnPressurePlate(self, gridIndexOrPosition)
    return ____exports.spawnPressurePlateWithVariant(nil, PressurePlateVariant.PRESSURE_PLATE, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.ROCK` (2).
function ____exports.spawnRock(self, gridIndexOrPosition)
    return ____exports.spawnRockWithVariant(nil, RockVariant.NORMAL, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.SPIKES` (8).
function ____exports.spawnSpikes(self, gridIndexOrPosition)
    return ____exports.spawnSpikesWithVariant(nil, 0, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.TNT` (12).
function ____exports.spawnTNT(self, gridIndexOrPosition)
    return ____exports.spawnTNTWithVariant(nil, 0, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.TELEPORTER` (23).
function ____exports.spawnTeleporter(self, gridIndexOrPosition)
    return ____exports.spawnTeleporterWithVariant(nil, 0, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.TRAPDOOR` (17).
function ____exports.spawnTrapdoor(self, gridIndexOrPosition)
    return ____exports.spawnCrawlSpaceWithVariant(nil, CrawlSpaceVariant.NORMAL, gridIndexOrPosition)
end
--- Helper function to spawn a `GridEntityType.TRAPDOOR` (17) with a specific variant.
function ____exports.spawnTrapdoorWithVariant(self, trapdoorVariant, gridIndexOrPosition)
    return spawnGridEntityWithVariant(nil, GridEntityType.TRAPDOOR, trapdoorVariant, gridIndexOrPosition)
end
return ____exports
