local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
local ____constants = require("src.core.constants")
local VectorZero = ____constants.VectorZero
local ____collectibleTag = require("src.functions.collectibleTag")
local isQuestCollectible = ____collectibleTag.isQuestCollectible
local ____collectibles = require("src.functions.collectibles")
local setCollectibleEmpty = ____collectibles.setCollectibleEmpty
local ____entitiesSpecific = require("src.functions.entitiesSpecific")
local spawnPickupWithSeed = ____entitiesSpecific.spawnPickupWithSeed
local ____players = require("src.functions.players")
local anyPlayerIs = ____players.anyPlayerIs
local ____rng = require("src.functions.rng")
local getRandomSeed = ____rng.getRandomSeed
local isRNG = ____rng.isRNG
--- Helper function to spawn a collectible.
-- 
-- Use this instead of the `Game.Spawn` method because it handles the cases of Tainted Keeper
-- collectibles costing coins.
-- 
-- This function is unsafe because it will not correctly handle quest items being rotated by Tainted
-- Isaac's rotation mechanic. To handle that, use the `spawnCollectible` helper function instead
-- (which is provided by `ISCFeature.SPAWN_COLLECTIBLE`).
-- 
-- If you want to spawn an unseeded collectible, you must explicitly pass `undefined` to the
-- `seedOrRNG` parameter.
-- 
-- @param collectibleType The collectible type to spawn.
-- @param positionOrGridIndex The position or grid index to spawn the collectible at.
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
-- a random seed.
-- @param options Optional. Set to true to make the collectible a "There's Options" style
-- collectible. Default is false.
-- @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
-- Tainted Keeper. Default is false.
-- @param spawner Optional.
function ____exports.spawnCollectibleUnsafe(self, collectibleType, positionOrGridIndex, seedOrRNG, options, forceFreeItem, spawner)
    if options == nil then
        options = false
    end
    if forceFreeItem == nil then
        forceFreeItem = false
    end
    if seedOrRNG == nil then
        seedOrRNG = getRandomSeed(nil)
    end
    local seed = isRNG(nil, seedOrRNG) and seedOrRNG:Next() or seedOrRNG
    local collectible = spawnPickupWithSeed(
        nil,
        PickupVariant.COLLECTIBLE,
        collectibleType,
        positionOrGridIndex,
        seed,
        VectorZero,
        spawner
    )
    if options then
        collectible.OptionsPickupIndex = 1
    end
    if anyPlayerIs(nil, PlayerType.KEEPER_B) and not isQuestCollectible(nil, collectibleType) and not forceFreeItem then
        collectible.ShopItemId = -1
        collectible.Price = 15
    end
    return collectible
end
--- Helper function to spawn an empty collectible. Doing this is tricky since spawning a collectible
-- with `CollectibleType.NULL` will result in spawning a collectible with a random type from the
-- current room's item pool.
-- 
-- Instead, this function arbitrarily spawns a collectible with `CollectibleType.BROKEN_SHOVEL_1`,
-- and then converts it to an empty pedestal afterward. (Broken Shovel is used instead of e.g. Sad
-- Onion because it is a quest collectible and quest collectibles will prevent Damocles from
-- duplicating the pedestal.)
-- 
-- If you want to spawn an unseeded collectible, you must explicitly pass `undefined` to the
-- `seedOrRNG` parameter.
-- 
-- @param positionOrGridIndex The position or grid index to spawn the empty collectible at.
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
-- a random seed.
function ____exports.spawnEmptyCollectible(self, positionOrGridIndex, seedOrRNG)
    local collectible = ____exports.spawnCollectibleUnsafe(
        nil,
        CollectibleType.BROKEN_SHOVEL_1,
        positionOrGridIndex,
        seedOrRNG,
        false,
        true
    )
    setCollectibleEmpty(nil, collectible)
    return collectible
end
return ____exports
