mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-18 23:52:02 +00:00
Add Actor.CanReceive (#2295)
Adds CanReceive() to Actor, called by items from CallTryPickup(). This will let actors themselves determine if they can receive the item before any other checks. Co-authored-by: Rachael Alexanderson <18584402+madame-rachelle@users.noreply.github.com>
This commit is contained in:
parent
1a860185ee
commit
d0288264a2
2 changed files with 19 additions and 3 deletions
|
@ -510,7 +510,15 @@ class Actor : Thinker native
|
|||
return true;
|
||||
}
|
||||
|
||||
// Called in TryMove if the mover ran into another Actor. This isn't called on players
|
||||
// [AA] Called by inventory items in CallTryPickup to see if this actor needs
|
||||
// to process them in some way before they're received. Gets called before
|
||||
// the item's TryPickup, allowing fully customized handling of all items.
|
||||
virtual bool CanReceive(Inventory item)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called in TryMove if the mover ran into another Actor. This isn't called on players
|
||||
// if they're currently predicting. Guarantees collisions unlike CanCollideWith.
|
||||
virtual void CollidedWith(Actor other, bool passive) {}
|
||||
|
||||
|
|
|
@ -597,8 +597,16 @@ class Inventory : Actor
|
|||
// unmorphed versions of a currently morphed actor cannot pick up anything.
|
||||
if (bUnmorphed) return false, null;
|
||||
|
||||
bool res;
|
||||
if (CanPickup(toucher))
|
||||
//[AA] starting with true, so that CanReceive can unset it,
|
||||
// if necessary:
|
||||
bool res = true;
|
||||
// [AA] CanReceive lets the actor receiving the item process it first.
|
||||
if (!toucher.CanReceive(self))
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
// CanPickup processes restrictions by player class.
|
||||
else if (CanPickup(toucher))
|
||||
{
|
||||
res = TryPickup(toucher);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue