Character ammo inventory with enum

I have this enum in my character class (TestCharacter.h/.cpp):

56716-enum.png

And it’s set as a property in each weapon class (TestWeapon.h/.cpp) like so:

56717-property.png

That way, it’s easy to choose which ammo type my weapon uses in the editor:

56720-ammotypeeditor.png

My question would be, what would be the best way to make an inventory for my character that contains all the ammo types and how much he has of them. So far I don’t know if I can use my enum for that or if I have to just create an integer property for each type, like so:

56721-inventory.png

Any help would be appreciated, thanks!

You should be able to use your enum as a struct property. I’d store both the enum and the value in one struct.

You could just store an array of floats using the enum as an index and have an AMMO_TYPE_MAX as the last value in the enum. Technically enums aren’t guaranteed to be contiguous, but for most intents and purposes you can treat them that way as long as you avoid 100% assigning specific values to the enum like this:

enum someType{
    Type1,
    Type2 = 7
}

edit:
I think most games, however, attach the value and type to the gun itself rather than the player though.