Now we’re talking. So far we’ve got the following:
Item, an abstract ScriptableObject
public abstract class Item : ScriptableObject
{
// Future fields here
}
Ingredient, inherits Item and represents a collectible ingredient
public class Ingredient : Item
{
// Future fields here specific to ingredients
}
(I’m skipping UsableItem because we don’t have information on how it works right now, we can leave that for future design when we have more requirements. Conversely, we can just make Ingredients Items and not bother with the abstract, or use an interface as suggested by @DaSerialGenius )
ItemInstance, the game world representation of an item (sound right @MUGIK ?)
public class ItemInstance : MonoBehaviour
{
[SerializeField] private Item _item;
public Item Item => _item;
}
Inventory, a ScriptableObject that represents a collection of items belonging to an entity.
public class Inventory : ScriptableObject
{
[SerializeField] private Dictionary<Item, int> _items;
public void Add(Item item, int count = 1)
{
// todo: code
}
public void Remove(Item item, int count = 1)
{
// todo: code
}
public bool Contains(Item item)
{
// todo: code
}
}
InventoryController (my naming, I’m definitely amenable to changing it - @SideSwipe9th recommended InventoryManager but I was thinking that Manager is more of a global object, whereas Controller is more of an entity-level object, I am down with whatever y’all prefer though), MonoBehaviour that allows an entity to have access to an inventory (and temporarily allows us to pick it up via a TriggerEnter)
public class InventoryController : MonoBehaviour
{
[SerializeField] private Inventory _inventory;
private void OnTriggerEnter(Collider other)
{
// Check to see if it was an ItemInstance, if so add it and destroy
}
}