Blockquote You’ve released on a specific slot, but there is already a stack on another. The code you’ve highlighted will notice this and put the item in the stack if one exists.
I kind of understood this when watching the video but wasn’t sure, thank you for making it clear for me. I fully understand now what it’s doing.
The thing is I’m not sure this is an ideal behavior in a game in my opinion.
first, how would it be possible to have two separate stacks of the same item whilst our system is built in a way that this situation will never happen.
Then, if we take an example where is can of scenario can happen, the resident evil kind of inventory, they have a space management inventory system where it is possible to have to stacks of the same item. though if you move one of the stacks around, it won’t go looking for the stack that is not in the slot you’ve just released on, but rather put in exactly where you wanted to put it, and if you put one stack on top of the other, only then it will be merged under one big stack.
Here is an image from Deus Ex game which is similar to resident evil, illustrating the inventory management I’m referring to :
Of course each game can have it’s own mechanics, but I can’t see an example where the player would be forced to combine two stacks when he clearly is just moving one of the stacks to an empty slot rather then on top of the second stack, where in my opinion is the ideal scenario for this behavior.
Just sharing my idea here and would love to hear your thoughts
Thanks again for answering my question