"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PostRoomClearChanged = void 0;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const cachedClasses_1 = require("../../core/cachedClasses");
const ModCallbackCustom_1 = require("../../enums/ModCallbackCustom");
const CustomCallback_1 = require("../private/CustomCallback");
const v = {
    room: {
        cleared: false,
    },
};
class PostRoomClearChanged extends CustomCallback_1.CustomCallback {
    v = v;
    constructor() {
        super();
        this.callbacksUsed = [
            // 1
            [isaac_typescript_definitions_1.ModCallback.POST_UPDATE, this.postUpdate],
        ];
        this.customCallbacksUsed = [
            [ModCallbackCustom_1.ModCallbackCustom.POST_NEW_ROOM_REORDERED, this.postNewRoomReordered],
        ];
    }
    shouldFire = (fireArgs, optionalArgs) => {
        const [roomClear] = fireArgs;
        const [callbackRoomClear] = optionalArgs;
        return callbackRoomClear === undefined || callbackRoomClear === roomClear;
    };
    // ModCallback.POST_UPDATE (1)
    postUpdate = () => {
        const room = cachedClasses_1.game.GetRoom();
        const roomClear = room.IsClear();
        if (roomClear !== v.room.cleared) {
            v.room.cleared = roomClear;
            this.fire(roomClear);
        }
    };
    // ModCallbackCustom.POST_NEW_ROOM_REORDERED
    postNewRoomReordered = () => {
        const room = cachedClasses_1.game.GetRoom();
        const roomClear = room.IsClear();
        v.room.cleared = roomClear;
    };
}
exports.PostRoomClearChanged = PostRoomClearChanged;
