Adds OnDrop virtual to inventory items. Called on the dropped item at the end of AActor::DropInventory.

This commit is contained in:
Marisa Kirisame 2018-09-16 15:05:57 +02:00 committed by Christoph Oelckers
parent 4c13a8df6e
commit 38c8f0d585
2 changed files with 19 additions and 1 deletions

View File

@ -1158,6 +1158,14 @@ AInventory *AActor::DropInventory (AInventory *item, int amt)
drop->Vel += Vel;
drop->flags &= ~MF_NOGRAVITY; // Don't float
drop->ClearCounters(); // do not count for statistics again
{
// [MK] call OnDrop so item can change its drop behaviour
IFVIRTUALPTR(drop, AInventory, OnDrop)
{
VMValue params[] = { drop, this };
VMCall(func, params, 2, nullptr, 0);
}
}
return drop;
}

View File

@ -906,7 +906,17 @@ class Inventory : Actor native
return item;
}
//===========================================================================
//
// AInventory :: OnDrop
//
// Called by AActor::DropInventory. Allows items to modify how they behave
// after being dropped.
//
//===========================================================================
virtual void OnDrop (Actor dropper) {}
}
//===========================================================================