@IlliciteS
I have a main_item (parent class) that I use to create subs for different types of items. The only variables this class has are ID and Type (enum: weapons, throwables, gear, consumables, ammo etc.). From there I create a child class for each Item Type. Each type has its own specific data structures.
So basically on pickup [interact, bp interface] I check the item type and process the item through a specific event.
- Type = weapon -> process weapon [event] -> cast to weapon -> get weapon_config (struct)
- Type = throwable -> process throwable [event] -> cast to throwable -> get throwable_config (struct)
The inventory system (actor component) structure is what matters in the end.
My characters can have 2 primary weapons (guns), 1 pistol, 1 nade, 1 melee weapon in preordained “slots”. Each of these specific items will be spawned and carried on the character (visible). Because of this I can use an Object reference for them in my inventory.
e.g. Inventory
Primary Weapon Slot (Weapon Object Reference) … config struct subtype [smg/lmg/ar/dmr/sr]
Secondary Weapon Slot (Weapon Object Reference) … config struct subtype [smg/lmg/ar/dmr/sr]
Pistol Weapon Slot (Weapon Object Reference) … config struct subtype [pistol]
Throwable Slot (Throwable Object Reference) … (smoke,frag,flash,moly)
Melee Slot (Melee Object Reference)
Loose bag items like consumables, ammo, extra throwables etc don’t have heavy struct configs, just simple identifiers (in most cases). Most of which are stackable. Those are stored in a “Bag” Struct with specific slots (element) for each type. Some elements of the struct are structs, struct arrays etc.
e.g. Bag Struct
Ammo (struct)
9mm (struct) : Total(int), Stacks (TMap): ID(int), count(int)
45ACP (struct) : Total(int), Stacks (TMap): ID(int), count(int)
5.56 (struct) : Total(int), Stacks (TMap): ID(int), count(int)
7.62 (struct) : Total(int), Stacks (TMap): ID(int), count(int)
Throwables (struct)
Frag : count(int)
Smoke : count(int)
Flash : count(int)
Moly : count(int)
Meds (struct) … aka consumables
Med kit: count(int)
First Aid kit: count(int)
Bandage: count(int)
Adrenaline: count(int)
Pain Pills: count(int)
etc.