Repository navigation
Store InventoryItems as separate resource files - #2689
Conversation
|
Play this branch at https://play.threadbare.game/branches/endlessm/wjt/store-inventoryitems-as-separate-resource-files/. (This launches the game from the start, not directly at the change(s) in this pull request.) |
c1eb4b2 to
5dc4280
Compare
d55808a to
2a35b3b
Compare
Previously we defined InventoryItem resources inline in every scene that uses them; and we hardcoded the world texture, HUD texture, and colour for each in the script. Turn these into properties of the resource. Create 3 on-disk resources for the memory, imagination, and spirit threads. Add migration code to collectible_item.gd which updates the property so that loading & saving a scene using this script does the migration. Leave the migration code in-place so that as out-of-tree quests are merged we can easily update them. Change the inventory storage to refer to those, rather than saving just the item type name and reconstructing resources on load. I think this will make it easier to add collectibles which are not threads in future, and also to remember which threads have been collected when loading or replaying a quest, though I haven't attempted to do that here.
2a35b3b to
955144c
Compare
|
Rebased and re-rewrote all the scenes. I think this change makes sense. It does increase the chance of someone accidentally editing the text of one of the three threads rather than making a bespoke one. However we don't currently support collecting anything except these three items. And actually I think this is a useful step towards more generic collectibles. |
|
Personally I would recommend tagging a release before merging this and #2693! |
| func _get_item() -> InventoryItem: | ||
| # Replace anonymous resource stored in scene file with separately-stored resource. | ||
| # Can be removed when we don't expect to have to rewrite any new quests being merged. | ||
| if item and item.is_built_in(): |
There was a problem hiding this comment.
This is smart! Great way of doing the migration.
|
I solved conflicts and did a full playthrough. All looks fine. |

Previously we defined InventoryItem resources inline in every scene that
uses them; and we hardcoded the world texture, HUD texture, and colour
for each in the script.
Turn these into properties of the resource. Create 3 on-disk resources
for the memory, imagination, and spirit threads. Add migration code to
collectible_item.gd which updates the property so that loading & saving
a scene using this script does the migration. Leave the migration code
in-place so that as out-of-tree quests are merged we can easily update
them.
Change the inventory storage to refer to those, rather than saving just
the item type name and reconstructing resources on load.
I think this will make it easier to add collectibles which are not
threads in future, and also to remember which threads have been
collected when loading or replaying a quest, though I haven't attempted
to do that here.