Hey everybody!
I’m attempting to implement a “Storage Item” into my game. But I’m having trouble planning out how it would work. I already have an Inventory System made, but this Storage Item is giving me trouble.
The Storage Item basically acts as a pouch you hold in your inventory. Like a coin purse that holds your money, or a Potion sack that holds your potions. Like a mini inventory you hold in your actual inventory.
So far I have the following:
public class Inventory{
public ItemStack[] inventory;
}
public class ItemStack{
public Item item;
publin int amount;
}
public abstract class StorageItem : Item{
public Item storedItem; //Specific Item the StorageItem can contain.
public int storedMax; //Maximum amount the StorageItem can contain
//StorageItem's Item.maxStack = 1; Should never be stackeable, but should hold stacks of storedItem
}
public abstract class Item{
public int id;
public string name;
public int maxStack;
}
Does anyone have an idea how they would get ItemStack and StorageItem to work together in an inventory System?
Example:
If I wanted to add a health potion, my inventory would search through, find all existing stacks, (Including StorageItems holding health potions), and attempt to fill them.
But the ItemStack that holds the StorageItem already has an amount, which corresponds to the actual StorageItem rather than the item it stores. And Since StorageItem should never be stack on itself (but stacks other items in itself), it is always ‘full’.