Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions EXILED/Exiled.API/Enums/AmmoType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ public enum AmmoType
/// Used by <see cref="ItemType.GunRevolver"/>
/// </summary>
Ammo44Cal,

/// <summary>
/// Custom has been modified by a plugin
/// </summary>
Custom,
}
}
3 changes: 2 additions & 1 deletion EXILED/Exiled.API/Extensions/ItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public static int GetMaxAmmo(this FirearmType item)
ItemType.Ammo762x39 => AmmoType.Nato762,
ItemType.Ammo12gauge => AmmoType.Ammo12Gauge,
ItemType.Ammo44cal => AmmoType.Ammo44Cal,
_ => AmmoType.None,
ItemType.None => AmmoType.None,
_ => AmmoType.Custom,
};

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions EXILED/Exiled.API/Features/Items/Firearm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ internal override void ReadPickupInfoBefore(Pickup pickup)
if (pickup is FirearmPickup firearmPickup)
{
PrimaryMagazine.MaxAmmo = firearmPickup.MaxAmmo;
PrimaryMagazine.AmmoItemType = firearmPickup.AmmoItemType;
AmmoDrain = firearmPickup.AmmoDrain;
Damage = firearmPickup.Damage;
Inaccuracy = firearmPickup.Inaccuracy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public override AmmoType AmmoType
set => CylinderModule.AmmoType = value.GetItemType();
}

/// <inheritdoc/>
public override ItemType AmmoItemType
{
get => Magazine.AmmoType;
set => CylinderModule.AmmoType = value;
}

/// <summary>
/// Gets a <see cref="IEnumerable{T}"/> of chambers in cylindric magazine.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ public override int Ammo
public override AmmoType AmmoType
{
get => Magazine.AmmoType.GetAmmoType();

set => MagazineModule._ammoType = value.GetItemType();
}

/// <inheritdoc/>
public override ItemType AmmoItemType
{
get => Magazine.AmmoType;
set => MagazineModule._ammoType = value;
}

/// <summary>
/// Gets or sets a value indicating whether magazine is inserted.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Exiled.API.Features.Items.FirearmModules.Primary
using System;

using Exiled.API.Enums;
using Exiled.API.Extensions;

using InventorySystem.Items.Firearms.Modules;

Expand Down Expand Up @@ -59,5 +58,10 @@ public override int Ammo
/// Gets or sets an used <see cref="Exiled.API.Enums.AmmoType"/> for this magazine.
/// </summary>
public abstract AmmoType AmmoType { get; set; }

/// <summary>
/// Gets or sets an used <see cref="ItemType"/> for this magazine.
/// </summary>
public abstract ItemType AmmoItemType { get; set; }
}
}
17 changes: 17 additions & 0 deletions EXILED/Exiled.API/Features/Pickups/FirearmPickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Exiled.API.Features.Pickups
{
using System;

using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Interfaces;
using InventorySystem.Items;
using InventorySystem.Items.Firearms;
Expand Down Expand Up @@ -54,6 +56,20 @@ internal FirearmPickup(ItemType type)
[Obsolete("Feature deprecated")]
public bool IsDistributed { get; }

/// <summary>
/// Gets or sets the <see cref="Enums.AmmoType"/>.
/// </summary>
public AmmoType AmmoType
{
get => AmmoItemType.GetAmmoType();
set => AmmoItemType = value.GetItemType();
}

/// <summary>
/// Gets or sets the <see cref="ItemType"/>.
/// </summary>
public ItemType AmmoItemType { get; set; }

/// <summary>
/// Gets or sets a value indicating how much ammo can contain this <see cref="FirearmPickup"/>.
/// </summary>
Expand Down Expand Up @@ -154,6 +170,7 @@ internal override void ReadItemInfo(Items.Item item)
if (item is Items.Firearm firearm)
{
MaxAmmo = firearm.PrimaryMagazine.ConstantMaxAmmo;
AmmoItemType = firearm.PrimaryMagazine.AmmoItemType;
AmmoDrain = firearm.AmmoDrain;
Damage = firearm.Damage;
Inaccuracy = firearm.Inaccuracy;
Expand Down
Loading