"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PostCollectibleEmpty = void 0;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const CustomCallback_1 = require("../private/CustomCallback");
const v = {
    room: {
        collectibleTypeMap: new Map(),
    },
};
class PostCollectibleEmpty extends CustomCallback_1.CustomCallback {
    v = v;
    constructor() {
        super();
        this.callbacksUsed = [
            // 35
            [
                isaac_typescript_definitions_1.ModCallback.POST_PICKUP_UPDATE,
                this.postPickupUpdateCollectible,
                [isaac_typescript_definitions_1.PickupVariant.COLLECTIBLE],
            ],
        ];
    }
    shouldFire = (fireArgs, optionalArgs) => {
        const [_collectible, oldCollectibleType] = fireArgs;
        const [callbackCollectibleType] = optionalArgs;
        return (callbackCollectibleType === undefined ||
            callbackCollectibleType === oldCollectibleType);
    };
    // ModCallback.POST_PICKUP_UPDATE (35)
    // PickupVariant.COLLECTIBLE (100)
    postPickupUpdateCollectible = (pickup) => {
        const collectible = pickup;
        const ptrHash = GetPtrHash(collectible);
        let oldCollectibleType = v.room.collectibleTypeMap.get(ptrHash);
        if (oldCollectibleType === undefined) {
            oldCollectibleType = collectible.SubType;
        }
        v.room.collectibleTypeMap.set(ptrHash, collectible.SubType);
        if (oldCollectibleType !== collectible.SubType) {
            this.collectibleTypeChanged(collectible, oldCollectibleType);
        }
    };
    collectibleTypeChanged(collectible, oldCollectibleType) {
        if (collectible.SubType === isaac_typescript_definitions_1.CollectibleType.NULL) {
            this.fire(collectible, oldCollectibleType);
        }
    }
}
exports.PostCollectibleEmpty = PostCollectibleEmpty;
