This can’t possibly be as hard as I’m making it in my head, but I’m having a heck of a time working out how to structure items in my game. Every item needs both a physical model, generic data that is common to all items (name, value, description), and functionality which is unique to that item/item class. The latter two are easy enough to accomplish with a generic class to hold the common data and maintain an empty Use() function, and subclasses that override Use in specific ways (to differentiate consumables from weapons from inert loot).
Thus far everything I’ve described could be accomplished in an empty data class, but I can’t figure out what the best option is to actually associate that data with a model. The most straightforward approach would be to make the item class an Actor with a public UStaticMesh* to set in the editor, but if the player ends up with 30-40 items in their inventory, that’s 30-40 meshes I’m turning invisible and holding in memory without using. An alternative would be to make items an empty data class and create some ItemHolder actor which only has a ItemData* reference and a PickMeUp(ACharacter* looter) function, but after the item is looted, and its holder runs Destroy(), I’m still going to need a reference to the item’s model, since he’ll want to equip/unequip/drop it at a whim.
Am I overcomplicating this? It feels like making every item an Actor is the best solution, but I hate the idea of forcing what should be a small Struct() to carry geometry around with it in memory.