"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoomClearFrame = void 0;
const cachedClasses_1 = require("../../../core/cachedClasses");
const decorators_1 = require("../../../decorators");
const ModCallbackCustom_1 = require("../../../enums/ModCallbackCustom");
const Feature_1 = require("../../private/Feature");
const v = {
    room: {
        roomClearGameFrame: undefined,
        roomClearRenderFrame: undefined,
        roomClearRoomFrame: undefined,
    },
};
class RoomClearFrame extends Feature_1.Feature {
    /** @internal */
    v = v;
    /** @internal */
    constructor() {
        super();
        this.customCallbacksUsed = [
            [
                ModCallbackCustom_1.ModCallbackCustom.POST_ROOM_CLEAR_CHANGED,
                this.postRoomClearChangedTrue,
            ],
        ];
    }
    // ModCallbackCustom.POST_ROOM_CLEAR_CHANGED
    // true
    postRoomClearChangedTrue = () => {
        const gameFrameCount = cachedClasses_1.game.GetFrameCount();
        const room = cachedClasses_1.game.GetRoom();
        const roomFrameCount = room.GetFrameCount();
        const renderFrameCount = Isaac.GetFrameCount();
        v.room.roomClearGameFrame = gameFrameCount;
        v.room.roomClearRenderFrame = renderFrameCount;
        v.room.roomClearRoomFrame = roomFrameCount;
    };
    /**
     * Helper function to get the game frame (i.e. `Game.GetFrameCount`) of the last time that this
     * room was cleared. Returns undefined if the room has never been cleared.
     *
     * Note that if the room is left, all room clear tracking for it will be discarded.
     *
     * In order to use this function, you must upgrade your mod with `ISCFeature.ROOM_CLEAR_FRAME`.
     *
     * @public
     */
    getRoomClearGameFrame() {
        return v.room.roomClearGameFrame;
    }
    /**
     * Helper function to get the render frame (i.e. `Isaac.GetFrameCount`) of the last time that this
     * room was cleared. Returns undefined if the room has never been cleared.
     *
     * Note that if the room is left, all room clear tracking for it will be discarded.
     *
     * In order to use this function, you must upgrade your mod with `ISCFeature.ROOM_CLEAR_FRAME`.
     *
     * @public
     */
    getRoomClearRenderFrame() {
        return v.room.roomClearRenderFrame;
    }
    /**
     * Helper function to get the room frame (i.e. `Room.GetFrameCount`) of the last time that this
     * room was cleared. Returns undefined if the room has never been cleared.
     *
     * Note that if the room is left, all room clear tracking for it will be discarded.
     *
     * In order to use this function, you must upgrade your mod with `ISCFeature.ROOM_CLEAR_FRAME`.
     *
     * @public
     */
    getRoomClearRoomFrame() {
        return v.room.roomClearRoomFrame;
    }
}
exports.RoomClearFrame = RoomClearFrame;
__decorate([
    decorators_1.Exported
], RoomClearFrame.prototype, "getRoomClearGameFrame", null);
__decorate([
    decorators_1.Exported
], RoomClearFrame.prototype, "getRoomClearRenderFrame", null);
__decorate([
    decorators_1.Exported
], RoomClearFrame.prototype, "getRoomClearRoomFrame", null);
