"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderTextOnEntity = exports.renderScaledTextOnEntity = exports.isReflectionRender = void 0;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const cachedClasses_1 = require("../core/cachedClasses");
/**
 * Helper function to see if the current render callback is rendering a water reflection.
 *
 * When the player is in a room with water, things will be rendered twice: once for the normal
 * rendering, and once for the reflecting rendering. Thus, any mod code in a render callback will
 * run twice per frame in these situations, which may be unexpected or cause bugs.
 *
 * This function is typically used to early return from a render function if it returns true.
 */
function isReflectionRender() {
    const room = cachedClasses_1.game.GetRoom();
    const renderMode = room.GetRenderMode();
    return renderMode === isaac_typescript_definitions_1.RenderMode.WATER_REFLECT;
}
exports.isReflectionRender = isReflectionRender;
function renderScaledTextOnEntity(entity, text, scaleX, scaleY) {
    if (isReflectionRender()) {
        return;
    }
    const position = Isaac.WorldToScreen(entity.Position);
    Isaac.RenderScaledText(text, position.X, position.Y, scaleX, scaleY, 1, 1, 1, 1);
}
exports.renderScaledTextOnEntity = renderScaledTextOnEntity;
function renderTextOnEntity(entity, text) {
    if (isReflectionRender()) {
        return;
    }
    const position = Isaac.WorldToScreen(entity.Position);
    Isaac.RenderText(text, position.X, position.Y, 1, 1, 1, 1);
}
exports.renderTextOnEntity = renderTextOnEntity;
