CanReceive
Jump to navigation
Jump to search
virtual bool CanReceive(Inventory item)
Usage
An Actor function that determines if a specific item can be received by that actor. Normally, this is called automatically by Inventory items from their CallTryPickup call, as soon as they're about to be received (whether by being picked up, or by being given directly).
In the base Actor class this function simply always returns true
. Can be overridden to add custom behavior.
If there's a need to add behavior after an item has been received, see HasReceived.
If there's a need to modify the pickup rules from the item rather than its recipient, see CanPickup.
Parameters
- Inventory item
- A pointer to the item that is about to be received by the calling actor.
Return values
- bool — returns
true
if the item can be received. Returningfalse
will prevent the calling actor from being able to receive this item. (If the item was a pickup, it'll stay in the world; if it was being given directly through scripts/cheats, it'll disappear).
Examples
This custom PlayerPawn will not be able to receive any items based on the DoomWeapon class:
class CustomMagePlayer : PlayerPawn
{
override bool CanReceive(Inventory item)
{
if (item && item is 'DoomWeapon')
{
return false;
}
return true;
}
// States and Default blocks omitted to keep this example short
}