Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item stacking (again) #233

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

NancokPS2
Copy link
Contributor

@NancokPS2 NancokPS2 commented Jan 27, 2024

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.

@NancokPS2 NancokPS2 marked this pull request as ready for review January 28, 2024 14:39
@jonathaneeckhout
Copy link
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.

@NancokPS2 NancokPS2 marked this pull request as ready for review February 25, 2024 23:01
@jonathaneeckhout
Copy link
Owner

jonathaneeckhout commented Mar 5, 2024

Testing it, however when dropping the stacks it goes wrong.

Buying health pots from milklady did work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants