local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local __TS__DecorateLegacy = ____lualib.__TS__DecorateLegacy
local __TS__ArrayAt = ____lualib.__TS__ArrayAt
local ____exports = {}
local ____cachedClasses = require("core.cachedClasses")
local game = ____cachedClasses.game
local ____decorators = require("decorators")
local Exported = ____decorators.Exported
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
local ____dimensions = require("functions.dimensions")
local getDimension = ____dimensions.getDimension
local ____roomData = require("functions.roomData")
local getRoomGridIndex = ____roomData.getRoomGridIndex
local getRoomListIndex = ____roomData.getRoomListIndex
local getRoomName = ____roomData.getRoomName
local getRoomStageID = ____roomData.getRoomStageID
local getRoomSubType = ____roomData.getRoomSubType
local getRoomVariant = ____roomData.getRoomVariant
local getRoomVisitedCount = ____roomData.getRoomVisitedCount
local ____Feature = require("classes.private.Feature")
local Feature = ____Feature.Feature
local v = {run = {roomHistory = {}}}
____exports.RoomHistory = __TS__Class()
local RoomHistory = ____exports.RoomHistory
RoomHistory.name = "RoomHistory"
__TS__ClassExtends(RoomHistory, Feature)
function RoomHistory.prototype.____constructor(self)
    Feature.prototype.____constructor(self)
    self.v = v
    self.postNewRoomEarly = function()
        local level = game:GetLevel()
        local stage = level:GetStage()
        local stageType = level:GetStageType()
        local room = game:GetRoom()
        local roomType = room:GetType()
        local seeds = game:GetSeeds()
        local startSeedString = seeds:GetStartSeedString()
        local stageID = getRoomStageID(nil)
        local dimension = getDimension(nil)
        local roomVariant = getRoomVariant(nil)
        local roomSubType = getRoomSubType(nil)
        local roomName = getRoomName(nil)
        local roomGridIndex = getRoomGridIndex(nil)
        local roomListIndex = getRoomListIndex(nil)
        local roomVisitedCount = getRoomVisitedCount(nil)
        local roomDescription = {
            startSeedString = startSeedString,
            stage = stage,
            stageType = stageType,
            stageID = stageID,
            dimension = dimension,
            roomType = roomType,
            roomVariant = roomVariant,
            roomSubType = roomSubType,
            roomName = roomName,
            roomGridIndex = roomGridIndex,
            roomListIndex = roomListIndex,
            roomVisitedCount = roomVisitedCount
        }
        local ____v_run_roomHistory_0 = v.run.roomHistory
        ____v_run_roomHistory_0[#____v_run_roomHistory_0 + 1] = roomDescription
    end
    self.customCallbacksUsed = {{ModCallbackCustom.POST_NEW_ROOM_EARLY, self.postNewRoomEarly}}
end
function RoomHistory.prototype.deleteLastRoomDescription(self)
    table.remove(v.run.roomHistory)
end
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "deleteLastRoomDescription", true)
function RoomHistory.prototype.getNumRoomsEntered(self)
    return #v.run.roomHistory
end
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "getNumRoomsEntered", true)
function RoomHistory.prototype.getRoomHistory(self)
    return v.run.roomHistory
end
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "getRoomHistory", true)
function RoomHistory.prototype.getPreviousRoomDescription(self)
    local previousRoomDescription = __TS__ArrayAt(v.run.roomHistory, -2)
    if previousRoomDescription ~= nil then
        return previousRoomDescription
    end
    local startingRoomDescription = v.run.roomHistory[1]
    if startingRoomDescription ~= nil then
        return startingRoomDescription
    end
    error("Failed to find a room description for any rooms thus far on this run.")
end
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "getPreviousRoomDescription", true)
function RoomHistory.prototype.getLatestRoomDescription(self)
    return __TS__ArrayAt(v.run.roomHistory, -1)
end
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "getLatestRoomDescription", true)
function RoomHistory.prototype.inFirstRoom(self)
    return #v.run.roomHistory == 1
end
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "inFirstRoom", true)
function RoomHistory.prototype.isLeavingRoom(self)
    local level = game:GetLevel()
    local stage = level:GetStage()
    local stageType = level:GetStageType()
    local seeds = game:GetSeeds()
    local startSeedString = seeds:GetStartSeedString()
    local roomListIndex = getRoomListIndex(nil)
    local roomVisitedCount = getRoomVisitedCount(nil)
    local latestRoomDescription = self:getLatestRoomDescription()
    if latestRoomDescription == nil then
        return false
    end
    return startSeedString ~= latestRoomDescription.startSeedString or stage ~= latestRoomDescription.stage or stageType ~= latestRoomDescription.stageType or roomListIndex ~= latestRoomDescription.roomListIndex or roomVisitedCount ~= latestRoomDescription.roomVisitedCount
end
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "isLeavingRoom", true)
return ____exports
