I have an Inventory System, where only certain types of Items should be able to be filled into predetermined Slots.
For the first basic Prototype I was using an ItemType : Scriptable Object, of which an item can have multiple of, for example “weapon, usable, equip” or “backpack”.
I’ve been thinking about actually implementing the feature now, and I like the flexibility of being able to create a new ItemType in such a fast way, but the problem I’m facing, is that I would like to implement some additional functionality to certain types of Items, for example “consumables” being able to have a “consume” function.
A solution would be to inherit from the base ItemData class and provide the function in a new “ConsumableItem” Class. This doesn’t allow for Items to be able to have multiple “tags” anymore though, if more than one provides functions.
I thought about using Interfaces in some way, but this wouldn’t help me, if I wanted a single Instantiated Consumable to implement an Interface all of the other consumables don’t need.
I like to keep the code very adaptable and futureproof. I’ve been watching a few gdc talks and videos on the topic and liked the functionality the Scriptable Objects provide me in this scenario.
Do any of you have any advice on this?
This is pretty much my first bigger scale project and the first time I’ve been using Scriptable Objects in this way, so please go easy on me.