44 lines
732 B
C#
44 lines
732 B
C#
public class vp_AmmoPickup : vp_Pickup
|
|
{
|
|
public int GiveAmount = 1;
|
|
|
|
protected override bool TryGive(vp_FPPlayerEventHandler player)
|
|
{
|
|
if (player.Dead.Active)
|
|
{
|
|
return false;
|
|
}
|
|
for (int i = 0; i < GiveAmount; i++)
|
|
{
|
|
if (!base.TryGive(player))
|
|
{
|
|
if (TryReloadIfEmpty(player))
|
|
{
|
|
base.TryGive(player);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
TryReloadIfEmpty(player);
|
|
return true;
|
|
}
|
|
|
|
private bool TryReloadIfEmpty(vp_FPPlayerEventHandler player)
|
|
{
|
|
if (player.CurrentWeaponAmmoCount.Get() > 0)
|
|
{
|
|
return false;
|
|
}
|
|
if (player.CurrentWeaponClipType.Get() != InventoryName)
|
|
{
|
|
return false;
|
|
}
|
|
if (!player.Reload.TryStart())
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|