"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.inDimension = exports.getDimension = void 0;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const cachedClasses_1 = require("../core/cachedClasses");
const constants_1 = require("../core/constants");
const roomData_1 = require("./roomData");
/**
 * Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
 * but it can change if e.g. the player is in the mirror world of Downpour/Dross.
 */
function getDimension() {
    const level = cachedClasses_1.game.GetLevel();
    const roomGridIndex = (0, roomData_1.getRoomGridIndex)();
    const roomDescription = level.GetRoomByIdx(roomGridIndex, isaac_typescript_definitions_1.Dimension.CURRENT);
    const currentRoomHash = GetPtrHash(roomDescription);
    for (const dimension of constants_1.DIMENSIONS) {
        const dimensionRoomDescription = level.GetRoomByIdx(roomGridIndex, dimension);
        const dimensionRoomHash = GetPtrHash(dimensionRoomDescription);
        if (dimensionRoomHash === currentRoomHash) {
            return dimension;
        }
    }
    error("Failed to get the current dimension.");
}
exports.getDimension = getDimension;
function inDimension(dimension) {
    return dimension === getDimension();
}
exports.inDimension = inDimension;
