Little TakeInventory refactoring.
Introduce AActor::TakeInventory, which unifies DoTakeInv from ACS and DoTakeInventory from Decorate, and AInventory::DepleteOrDestroy, which is extracted from the DoTakeInv core function, and use both where they're needed. I don't know if the differences between DoTakeInv and DoTakeInventory were intentional, so I kept both behaviors.
This commit is contained in:
parent
a93c30238b
commit
b51fac344d
10 changed files with 92 additions and 107 deletions
|
|
@ -1052,24 +1052,7 @@ void cht_Take (player_t *player, const char *name, int amount)
|
|||
}
|
||||
else
|
||||
{
|
||||
AInventory *inventory = player->mo->FindInventory (type);
|
||||
|
||||
if (inventory != NULL)
|
||||
{
|
||||
inventory->Amount -= amount ? amount : 1;
|
||||
|
||||
if (inventory->Amount <= 0)
|
||||
{
|
||||
if (inventory->ItemFlags & IF_KEEPDEPLETED)
|
||||
{
|
||||
inventory->Amount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory->Destroy ();
|
||||
}
|
||||
}
|
||||
}
|
||||
player->mo->TakeInventory(type, amount ? amount : 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue