diff --git a/packages/isaacscript-common/src/classes/features/other/CustomPickups.ts b/packages/isaacscript-common/src/classes/features/other/CustomPickups.ts index 5ee2a5bb7..e9cc67a93 100644 --- a/packages/isaacscript-common/src/classes/features/other/CustomPickups.ts +++ b/packages/isaacscript-common/src/classes/features/other/CustomPickups.ts @@ -14,8 +14,12 @@ import { spawnEffect } from "../../../functions/entitiesSpecific"; import { Feature } from "../../private/Feature"; interface CustomPickupFunctions { - collectFunc: (this: void, player: EntityPlayer) => void; - collisionFunc: (this: void, player: EntityPlayer) => boolean; + collectFunc: (this: void, pickup: EntityPickup, player: EntityPlayer) => void; + collisionFunc: ( + this: void, + pickup: EntityPickup, + player: EntityPlayer, + ) => boolean | undefined; } /** @@ -69,9 +73,9 @@ export class CustomPickups extends Feature { return undefined; } - const shouldPickup = customPickupFunctions.collisionFunc(player); - if (!shouldPickup) { - return undefined; + const shouldPickup = customPickupFunctions.collisionFunc(pickup, player); + if (shouldPickup !== undefined) { + return shouldPickup; } pickup.Remove(); @@ -88,7 +92,7 @@ export class CustomPickups extends Feature { effectSprite.Load(fileName, true); effectSprite.Play("Collect", true); - customPickupFunctions.collectFunc(player); + customPickupFunctions.collectFunc(pickup, player); return undefined; }; @@ -128,18 +132,27 @@ export class CustomPickups extends Feature { * @param subType The sub-type for the corresponding custom pickup. * @param collectFunc The function to run when the player collects this pickup. * @param collisionFunc Optional. The function to run when a player collides with the pickup. - * Default is a function that always returns true, meaning that the player - * will always immediately collect the pickup when they collide with it. - * Specify this function if your pickup should only be able to be collected - * under certain conditions. + * Default is a function that always returns undefined, meaning that the + * player will always immediately collect the pickup when they collide with + * it. Specify this function if your pickup should only be able to be + * collected under certain conditions. Return value acts similar to + * `ModCallback.PRE_PICKUP_COLLISION`. * @public */ @Exported public registerCustomPickup( pickupVariantCustom: PickupVariant, subType: int, - collectFunc: (this: void, player: EntityPlayer) => void, - collisionFunc: (this: void, player: EntityPlayer) => boolean = () => true, + collectFunc: ( + this: void, + pickup: EntityPickup, + player: EntityPlayer, + ) => void, + collisionFunc: ( + this: void, + pickup: EntityPickup, + player: EntityPlayer, + ) => boolean | undefined = () => undefined, ): void { const entityID = getEntityIDFromConstituents( EntityType.PICKUP, diff --git a/packages/isaacscript-common/src/functions/playerCollectibles.ts b/packages/isaacscript-common/src/functions/playerCollectibles.ts index 8edce98ae..e6ecd9877 100644 --- a/packages/isaacscript-common/src/functions/playerCollectibles.ts +++ b/packages/isaacscript-common/src/functions/playerCollectibles.ts @@ -78,9 +78,7 @@ export function getActiveItemSlots( */ export function getAdjustedPrice(basePrice: int): int { const numSteamSales = getTotalPlayerCollectibles(CollectibleType.STEAM_SALE); - return numSteamSales > 0 - ? Math.floor(basePrice / (numSteamSales + 1)) - : basePrice; + return Math.ceil(basePrice / (numSteamSales + 1)); } /**