I am running into an issue of trying to implement an inventory system within XNA (doesn't really matter, could be any platform) but so far. Here is the issue I am trying to wrap my head around:
How can I get an item from the world (think when you kill a monster it drops armor) and get it into my player's inventory?
If an inventory is just a list of items, technically, how could I get Steel Sword from the world into my player's inventory without having a class do more than one thing?
I currently have an item struct, which contains a unique hex value, a count of how many items there are (for stackables, like arrows) and a Texture for rendering within the inventory, and some other unimportant properties (name, description, etc).
It would be bad design if I had to modify my existing item class to house a world position, along with collision detection (don't want the item falling through the earth).
Thanks for any considerations!
WorldItem
which is seperate to yourInventoryItem
? (Maybe theWorldItem
has anInventoryItem
template that's put into the player's inventory when picked up). \$\endgroup\$Inventory
that takes aWorldItem
and adds it asInventoryItem
. So that it could also handle cases where items need to stack (eg. Arrows). \$\endgroup\$