peter-kish / gloot

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

Trying to implement nested inventories. #217

Closed BadMachine closed 4 months ago

BadMachine commented 4 months ago

Hey. First of all: Great project. Thank u.

I was able to initialize item with inventory as a child node, made some tweaks for can_hold and can_add methods, but faced with a strange bug - child inventory reflects all the changes from the parent. On the top of the grid there is inventory id the grid holds. As you can see its different, the nested inventory grid opens in a separate window. Is there any propagation logic in the base implementation I missed? https://github.com/peter-kish/gloot/assets/50546204/0a504b30-82a2-4de1-8db9-2d11971184d2

peter-kish commented 4 months ago

Hi,

I didn't play around with nested inventories, so I'm not aware of the problems one might run into while trying to implement them.

I can only assume that it has something to do with how item nodes are added to inventories: they are "registered" in an inventory when the NOTIFICATION_PARENTED gets triggered (caught via Object._notification()). Even though this method is supposed to register the item only for its direct parent, it could be that somehow it gets registered in both inventories.

I will hopefully release version 3.0 soon, where inventory items are no longer nodes and there's a bit more control over item management, which should greatly simplify implementing nested inventories (I might even add some "official" support for it).

BadMachine commented 4 months ago

Wow, great! I'm looking forward to this features) Until then I'll try to follow the tip and fix that. Thank u!