Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
Finish FirearmPickup fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xNexusACS committed Dec 3, 2024
1 parent 8c2b705 commit 004a1ab
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions Exiled.API/Features/Pickups/FirearmPickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ internal FirearmPickup(ItemType type)
public FirearmType FirearmType => Type.GetFirearmType();

/// <summary>
/// Gets or sets the <see cref="Enums.AmmoType"/> of the firearm.
/// Gets the <see cref="Enums.AmmoType"/> of the firearm.
/// </summary>
[EProperty(category: nameof(FirearmPickup))]
public AmmoType AmmoType { get; set; }
public AmmoType AmmoType { get; private set; }

/// <summary>
/// Gets or sets a value indicating how many ammo have this <see cref="FirearmPickup"/>.
Expand Down Expand Up @@ -103,10 +103,9 @@ internal override void ReadItemInfo(Item item)
{
base.ReadItemInfo(item);

if (item is Items.Firearm firearm)
if (item is Firearm firearm)
{
MaxAmmo = firearm.MaxAmmo;
AmmoType = firearm.AmmoType;
}
}

Expand All @@ -117,14 +116,8 @@ protected override void InitializeProperties(ItemBase itemBase)

if (itemBase is FirearmItem firearm)
{
MaxAmmo = firearm switch
{
AutomaticFirearm autoFirearm => autoFirearm._baseMaxAmmo,
Revolver => 6,
Shotgun shotgun => shotgun._ammoCapacity,
_ => 0
};
AmmoType = firearm is AutomaticFirearm automaticFirearm ? automaticFirearm._ammoType.GetAmmoType() : firearm.ItemTypeId.GetAmmoType();
MaxAmmo = firearm.GetTotalMaxAmmo();
AmmoType = (firearm.Modules.OfType<MagazineModule>().FirstOrDefault()?.AmmoType ?? ItemType.None).GetAmmoType();
}
}
}
Expand Down

0 comments on commit 004a1ab

Please sign in to comment.