Keep the information stored as a struct in an inventory component and put that component on your pawn. Anything dynamic goes in that struct. anything constant goes in a datatable. spawned “items” such as weapons don’t hold state relevant to the inventory.
I don’t think you need to mix structs for anything in the inventory. If you have a rifle that requires 3 bullets to shoot you just let the rifle check the inventory component for the rifle and reserve 3 bullets?
I got very far by using a generic sounding attribute like “durability” for cases such as water in a bucket and durability on a rifle. Anything non generic would bloat the entire system but can probably be avoided.
- Edit
What about using JSON? This is one of those very rare cases I’d just like the flexibility of javascript to build structures / objects from scratch without being bound to a certain format. You will want it when you want the possibility for 9999 item types without pre programming them into a framework bloating it just in case.
I must say I haven’t tried this in c++ but why not . I’m making the assumption this does not require you to convert between struct and json.
How to retrieve single text field from Json? - #3 by GraeChan
What I did was linking datatables. If an item’s datatable entry contains a pointer to another datatable “weapon datatable” containing the weapon specs, it is a weapon. The downside is this assumes there will be weapons in the game it is used in, making it less fit as a generic framework. Upside is you have all the data linked, bit like expanding data on the original struct into sub categories of an item.