"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PreGetPedestal = void 0;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const shouldFire_1 = require("../../shouldFire");
const CustomCallback_1 = require("../private/CustomCallback");
class PreGetPedestal extends CustomCallback_1.CustomCallback {
    constructor() {
        super();
        this.callbacksUsed = [
            // 38
            [
                isaac_typescript_definitions_1.ModCallback.PRE_PICKUP_COLLISION,
                this.prePickupCollision,
                [isaac_typescript_definitions_1.PickupVariant.COLLECTIBLE],
            ],
        ];
    }
    shouldFire = shouldFire_1.shouldFirePlayer;
    // ModCallback.PRE_PICKUP_COLLISION (35)
    prePickupCollision = (pickup, collider, _low) => {
        const collectible = pickup;
        if (collectible.SubType === isaac_typescript_definitions_1.CollectibleType.NULL) {
            return undefined;
        }
        const player = collider.ToPlayer();
        if (player === undefined) {
            return undefined;
        }
        const numCoins = player.GetNumCoins();
        if (collectible.Price > numCoins) {
            return undefined;
        }
        // Collectibles have a special variable to prevent them from being picked up for a certain time.
        // Players have special variable to prevent them from picking up a collectible for a certain
        // time.
        if (collectible.Wait > 0 || player.ItemHoldCooldown > 0) {
            return undefined;
        }
        if (player.IsHoldingItem()) {
            return undefined;
        }
        return this.fire(player, collectible);
    };
}
exports.PreGetPedestal = PreGetPedestal;
