I'm still learning C++ and am no way an expert so I could be conceptualizing this wrong.
I'm having trouble getting the right data structure for items in my game. I don't need actual object instance data (x, y, z locations etc. There's an "item" object that just gets filled with the data from the item table when an instance is created)
The type of system I want is similar to Bethesda's creation engine, where I could basically start an array from 0 and increment it as an item is added to the game. Then I could just make each item in the array a struct holding all the item's variables. The reason I'm doing it this way is it makes it simple to get an item variable: item[56].size
returns that item's size
variable. (Meaning its gameplay dimensions, not its memory footprint)
The issue I'm having is different types of items require different variables. So for weapons there would need to be a damage variable that wouldn't exist for say a healing potion, or a gun requires different variables than a chair. So my current solution is to have many different arrays of structs, each array containing its own struct base that has only the relevant variables for that type. This leads to an unconnected series of arrays that get called like item_weapon[22].damage. I can't do a multi-dimensional array because it requires each type to have the same amount of items which they won't.
It'd be more ideal to just have 1 unified data structure holding all the items' data. (I would think, I'm still new to programming). So my idea would be to use an enum to increment the different types, then each enum holds an array of all the items of that type and each item in the arrays is a struct that only has variables similar to those in the same enum number. However my instinct is that doing this would still require each array to be the same length, but I'm not sure.
I can't find much on enum of arrays of structs. Is there a better solution? Is this maybe too complicated or not a good idea? Any help would be appreciated!