mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-22 19:01:12 +00:00
Added ShouldShareItem virtual
Allows for easier customizing of whether or not an item should be shared with players upon pickup in co-op (e.g. it allows it to be expanded to weapons with custom cvars).
This commit is contained in:
parent
12d0c946f0
commit
b43c440552
2 changed files with 16 additions and 1 deletions
|
@ -43,6 +43,11 @@ class Key : Inventory
|
|||
static native clearscope Color GetMapColorForKey(Key key);
|
||||
static native clearscope int GetKeyTypeCount();
|
||||
static native clearscope class<Key> GetKeyType(int index);
|
||||
|
||||
override bool ShouldShareItem(Actor giver)
|
||||
{
|
||||
return sv_coopsharekeys;
|
||||
}
|
||||
|
||||
override bool HandlePickup (Inventory item)
|
||||
{
|
||||
|
@ -113,6 +118,11 @@ class PuzzleItem : Inventory
|
|||
PuzzleItem.FailMessage("$TXT_USEPUZZLEFAILED");
|
||||
PuzzleItem.FailSound "*puzzfail";
|
||||
}
|
||||
|
||||
override bool ShouldShareItem(Actor giver)
|
||||
{
|
||||
return sv_coopsharekeys;
|
||||
}
|
||||
|
||||
override bool HandlePickup (Inventory item)
|
||||
{
|
||||
|
|
|
@ -261,6 +261,11 @@ class Inventory : Actor
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool ShouldShareItem(Actor giver)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void ShareItemWithPlayers(Actor giver)
|
||||
{
|
||||
if (bSharingItem)
|
||||
|
@ -695,7 +700,7 @@ class Inventory : Actor
|
|||
toucher.HasReceived(self);
|
||||
|
||||
// If the item can be shared, make sure every player gets a copy.
|
||||
if (multiplayer && !deathmatch && sv_coopsharekeys && bIsKeyItem)
|
||||
if (multiplayer && !deathmatch && ShouldShareItem(toucher))
|
||||
ShareItemWithPlayers(toucher);
|
||||
}
|
||||
return res, toucher;
|
||||
|
|
Loading…
Reference in a new issue