local ____lualib = require("lualib_bundle")
local __TS__Iterator = ____lualib.__TS__Iterator
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
local ____cachedClasses = require("core.cachedClasses")
local game = ____cachedClasses.game
local ____HealthType = require("enums.HealthType")
local HealthType = ____HealthType.HealthType
local ____direction = require("functions.direction")
local directionToVector = ____direction.directionToVector
local ____gridEntities = require("functions.gridEntities")
local spawnGridEntity = ____gridEntities.spawnGridEntity
local ____levelGrid = require("functions.levelGrid")
local getRoomAdjacentGridIndexes = ____levelGrid.getRoomAdjacentGridIndexes
local getRoomGridIndexesForType = ____levelGrid.getRoomGridIndexesForType
local ____logEntities = require("functions.logEntities")
local logAllEntities = ____logEntities.logAllEntities
local logAllGridEntities = ____logEntities.logAllGridEntities
local ____playerHealth = require("functions.playerHealth")
local addPlayerHealthType = ____playerHealth.addPlayerHealthType
local ____roomData = require("functions.roomData")
local getRoomData = ____roomData.getRoomData
local getRoomDescriptor = ____roomData.getRoomDescriptor
local ____rooms = require("functions.rooms")
local changeRoom = ____rooms.changeRoom
local ____roomTypeNames = require("objects.roomTypeNames")
local ROOM_TYPE_NAMES = ____roomTypeNames.ROOM_TYPE_NAMES
local DEFAULT_MOVE_UNITS = 0.5
function ____exports.addHeart(self, params, healthType)
    local numHearts = healthType == HealthType.MAX_HEARTS and 2 or 1
    if params ~= "" then
        local num = tonumber(params)
        if num == nil then
            print("That is an invalid amount of hearts to add.")
            return
        end
        numHearts = num
    end
    local player = Isaac.GetPlayer()
    addPlayerHealthType(nil, player, healthType, numHearts)
end
function ____exports.devilAngel(self, useDevil)
    local level = game:GetLevel()
    local devilAngelRoomData = getRoomData(nil, GridRoom.DEVIL)
    if devilAngelRoomData ~= nil then
        local roomType = devilAngelRoomData.Type
        local conflictingType = useDevil and RoomType.ANGEL or RoomType.DEVIL
        if roomType == conflictingType then
            local roomDescriptor = getRoomDescriptor(nil, GridRoom.DEVIL)
            roomDescriptor.Data = nil
        end
    end
    if useDevil then
        level:InitializeDevilAngelRoom(false, true)
    else
        level:InitializeDevilAngelRoom(true, false)
    end
    changeRoom(nil, GridRoom.DEVIL)
end
function ____exports.listEntities(self, params, includeBackgroundEffects)
    local entityTypeFilter
    if params ~= "" then
        entityTypeFilter = tonumber(params)
        if entityTypeFilter == nil then
            print("That is an invalid entity type to filter by.")
            return
        end
    end
    logAllEntities(includeBackgroundEffects, entityTypeFilter)
    print("Logged the entities in the room to the \"log.txt\" file.")
end
function ____exports.listGridEntities(self, params, includeWalls)
    local gridEntityTypeFilter
    if params ~= "" then
        gridEntityTypeFilter = tonumber(params)
        if gridEntityTypeFilter == nil then
            print("That is an invalid grid entity type to filter by.")
            return
        end
    end
    logAllGridEntities(includeWalls, gridEntityTypeFilter)
    print("Logged the grid entities in the room to the \"log.txt\" file.")
end
function ____exports.movePlayer(self, params, direction)
    local amount = DEFAULT_MOVE_UNITS
    if params ~= "" then
        local num = tonumber(params)
        if num == nil then
            print("That is an invalid amount of units to move.")
            return
        end
        amount = num
    end
    local player = Isaac.GetPlayer()
    local vector = directionToVector(nil, direction)
    local modifiedVector = vector * amount
    player.Position = player.Position + modifiedVector
end
function ____exports.spawnTrapdoorOrCrawlSpace(self, trapdoor)
    local room = game:GetRoom()
    local player = Isaac.GetPlayer()
    local position = room:FindFreeTilePosition(player.Position, 0)
    local gridEntityType = trapdoor and GridEntityType.TRAPDOOR or GridEntityType.CRAWL_SPACE
    spawnGridEntity(nil, gridEntityType, position)
end
function ____exports.warpToRoomType(self, roomType)
    local roomTypeName = ROOM_TYPE_NAMES[roomType]
    local gridIndexes = getRoomGridIndexesForType(nil, roomType)
    local firstGridIndex = gridIndexes[1]
    if firstGridIndex == nil then
        print(("There are no " .. roomTypeName) .. "s on this floor.")
        return
    end
    changeRoom(nil, firstGridIndex)
    print(((("Warped to room type: " .. roomTypeName) .. " (") .. tostring(roomType)) .. ")")
end
function ____exports.warpNextToRoomType(self, roomType)
    local roomTypeName = ROOM_TYPE_NAMES[roomType]
    local gridIndexes = getRoomGridIndexesForType(nil, roomType)
    local firstGridIndex = gridIndexes[1]
    if firstGridIndex == nil then
        print(("There are no " .. roomTypeName) .. "s on this floor.")
        return
    end
    local adjacentRoomGridIndexes = getRoomAdjacentGridIndexes(nil, firstGridIndex)
    for ____, ____value in __TS__Iterator(adjacentRoomGridIndexes) do
        local _doorSlot = ____value[1]
        local roomGridIndex = ____value[2]
        local roomData = getRoomData(nil, roomGridIndex)
        if roomData ~= nil and roomData.Type == RoomType.DEFAULT then
            changeRoom(nil, roomGridIndex)
            print(((("Warped next to room type: " .. roomTypeName) .. " (") .. tostring(roomType)) .. ")")
            return
        end
    end
    print(((("Failed to find the room next to room type: " .. roomTypeName) .. " (") .. tostring(roomType)) .. ")")
end
return ____exports
