Associate Ammo with Weapon?

Have the base weapon class store a reference to its owning player when it is added to the player’s inventory.
Have the player have its inventory of ammo in whatever method you like, be it an array of structs or just a dictionary sorted on an enum or whatever.
Have the player have a public “decrement ammo” or “Adjust inventory” or whatever method that takes appropriate arguments to its data type (ie a key value pair or a, object reference and an argument structure like in C# delegates).

When the weapon fires have it call the decrement ammo method on the player as appropriate.

Something like this but reworked for your actual codebase



//weapon class
playerClass owner = this.owner;
FiringArgs ammoToUse = new FiringArgs(AmmoClassorName, Amount);

void onFire()
{
//projectile spawn logic here
owner.UseAmmo(this, ammoToUse);

}



If you plan on having multiple ammo types used per shot type just add an additional call to decrement the ammo with a second FiringArgs struct.