Trying to create a simple item shop

I would have some kind of inventory attached to the player that keeps track of items they have. Likely in a component. Items would be kept in an array as a struct of Item Name, ID, Is Purchased, and Is Equipped + any other data you need.

When creating the widgets on store load, you should be looping through all available “items” in the datable and creating widgets from that. During that loop, for each item, I would also check the inventory of the Player to see if they have the item, & if it’s equipped. You’ll query their Inventory Component for that. It would probably be better for performance if you simply use a list of “Equipped” & “Purchased” id’s. Create a function in the inventory that returns these values, save them as a variable in the item shop ui, then use them on the loop. Saves you from casting to an inventory an unnecessary amount of times.

If it is equipped/owned, you would set the text data right then. You could easily keep the inventory & UI in sync afterwards. You can also save the inventory data to save-game for persistence through sessions.

As for one item at a time, make a function that loops through all items the player owns looking for “is equipped”. Make that function switch the value to false & equip the new item.

Good luck!