Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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();
Expand All @@ -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;
};
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
Loading