peter-kish / gloot

A universal inventory system for the Godot game engine.
MIT License
527 stars 20 forks source link

Nested inventories #208

Open Nordsoft91 opened 3 months ago

Nordsoft91 commented 3 months ago

Implement nested inventories, where InventoryItem can have Inventory as well (e.g. bag to carry extra items) or Slots (e.g. sword with slots for gems)

peter-kish commented 3 months ago

I know a lot of games do these sort of things, but I still think it's an exotic feature and I'm not sure if it's worth investing time into... That said, I still want the user to be able to implement features like these.

The first one could perhaps be implemented by extending the InventoryItem class and adding a child Inventory Node. This of course gets a bit more complicated if the bag weight needs to be adjusted when adding items, the parent inventory capacity needs to be checked when adding items etc.

Items with slots could be done in a similar way, though the UI could be difficult to implement as the gloot UI classes currently don't support displaying anything other than the item image.

I'll spend some time thinking about this. Hopefully I'll come up with something that makes things like this easily implementable by the user.

Nordsoft91 commented 3 months ago

Actually, what prevents of making all InventoryItems deriving Inventory? Of course there are difficulties, and probably redesigning of signals system will be needed, but in general it could be a concept.

peter-kish commented 3 months ago

I think that would be a bit to much.. Deriving from a whole class (that is quite complex to begin with) for just a few features sounds like bad design and introduces a lot of unnecessary complexity.