Open
Conversation
Owner
|
I am currently finishing the inventory part in the web port. I will probably port this code into the web branch as I will probably make the web port the mainline soon. |
Owner
|
Testing it, however when dropping the stacks it goes wrong. Buying health pots from milklady did work properly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an item is added, it will attempt to stack it onto another item whose amount does not match or exceed Item.amount_max.
Refactored Item.use() and related functions to no longer forcibly remove used items, now it depends on the item being used and the amount remaining.
Consumables remove a single unit from their stack on use (and get fully removed when the last one is used).
Equipment is removed from the inventory directly, but their amount does not change (this allows for weapons that use the "amount" property, like throwing knives or something).
The amount of an item is now displayed in their InventoryPanel, unless there is only 1 item left in the stack. (Values of 0 and lower values are still drawn to make bugs easier to spot)
This PR also comes with a new "InventorySynchronizerComponent.update_inventory()" function that updates all panels as performantly as possible by reading the inventory directly. This should be considerably faster than adding/removing items individually since it only combs trough the panels once for all of the items.
If this method can be queued to run once per frame once the inventory changes ( similar to queue_redraw() ), it should be a considerable speed up (and more reliable) for most inventory-related operations.
All items have an amount_max of 1 right now, except for potions who have a value of 6.