Added CanTouchItem virtual.

- Allows an actor with +PICKUP flag to determine if it can pick up specific items or not.
This commit is contained in:
Major Cooke 2019-03-03 13:26:00 -06:00 committed by Christoph Oelckers
parent 0fb940632a
commit 6327734659
2 changed files with 12 additions and 0 deletions

View file

@ -460,6 +460,15 @@ class Actor : Thinker native
native void Substitute(Actor replacement);
native ui void DisplayNameTag();
// Called by inventory items to see if this actor is capable of touching them.
// If true, the item will attempt to be picked up. Useful for things like
// allowing morphs to pick up limited items such as keys while preventing
// them from picking other items up.
virtual bool CanTouchItem(Inventory item)
{
return true;
}
// Called by PIT_CheckThing to check if two actors actually can collide.
virtual bool CanCollideWith(Actor other, bool passive)
{

View file

@ -768,6 +768,9 @@ class Inventory : Actor
bool localview = toucher.CheckLocalView();
if (!toucher.CanTouchItem(self))
return;
bool res;
[res, toucher] = CallTryPickup(toucher);
if (!res) return;