mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 04:01:31 +00:00
Added itemcls to HasReceived
CallTryPickup will cache the item's class and pass it to HasReceived, so the latter will know what item was received even if the item has been destroyed by the time it's called.
This commit is contained in:
parent
1b20c92ca5
commit
108ad7736a
2 changed files with 7 additions and 4 deletions
|
@ -534,7 +534,9 @@ class Actor : Thinker native
|
|||
// [AA] Called by inventory items at the end of CallTryPickup to let actors
|
||||
// do something with the items they've received. 'Item' might be null for
|
||||
// items that disappear on pickup.
|
||||
virtual void HasReceived(Inventory item) {}
|
||||
// 'itemcls' is passed unconditionally, so it can still be read even if
|
||||
// 'item' is null due to being destroyed with GoAwayAndDie() on pickup.
|
||||
virtual void HasReceived(Inventory item, class<Inventory> itemcls) {}
|
||||
|
||||
// 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.
|
||||
|
@ -705,7 +707,7 @@ class Actor : Thinker native
|
|||
native void SoundAlert(Actor target, bool splash = false, double maxdist = 0);
|
||||
native void ClearBounce();
|
||||
native TerrainDef GetFloorTerrain();
|
||||
native bool CheckLocalView(int consoleplayer = -1 /* parameter is not used anymore but needed for backward compatibilityö. */);
|
||||
native bool CheckLocalView(int consoleplayer = -1 /* parameter is not used anymore but needed for backward compatibility<EFBFBD>. */);
|
||||
native bool CheckNoDelay();
|
||||
native bool UpdateWaterLevel (bool splash = true);
|
||||
native bool IsZeroDamage();
|
||||
|
|
|
@ -647,9 +647,10 @@ class Inventory : Actor
|
|||
// unmorphed versions of a currently morphed actor cannot pick up anything.
|
||||
if (bUnmorphed) return false, null;
|
||||
|
||||
//[AA] starting with true, so that CanReceive can unset it,
|
||||
// [AA] starting with true, so that CanReceive can unset it,
|
||||
// if necessary:
|
||||
bool res = true;
|
||||
class<Inventory> cls = self.GetClass();
|
||||
// [AA] CanReceive lets the actor receiving the item process it first.
|
||||
if (!toucher.CanReceive(self))
|
||||
{
|
||||
|
@ -696,7 +697,7 @@ class Inventory : Actor
|
|||
}
|
||||
}
|
||||
// [AA] Let the toucher do something with the item they've just received:
|
||||
toucher.HasReceived(self);
|
||||
toucher.HasReceived(self, cls);
|
||||
|
||||
// If the item can be shared, make sure every player gets a copy.
|
||||
if (multiplayer && !deathmatch && !bDropped && ShouldShareItem(toucher))
|
||||
|
|
Loading…
Reference in a new issue