fix: Correctly get inventory objects registered in other rooms #608
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.
This fixes godot-escoria/escoria-issues#280
As I mentioned on Discord, when an object is added to the inventory it is added to an array for the room the player is currently in. When
get_object
got called, it would only look in the current room, skipping all possible inventory items from other rooms.This fix gets around that, specifically for items that are registered in the inventory.
I'm opening this as a draft because I'm not 100% this is the entirely correct solution. (and on top of that, I'm not 100% I followed the contribution guidelines correctly)
A better approach could be to have a separate array for inventory items. I noticed it's not there, and I don't know the history of the reasoning why.
Alternatively, yet another approach could be to have a similar loop through the objects in the rooms, but to wrap that in a
func
in the inventory manager, to "hide" its implementation details from the object manager.