I’ve been working on my first game, a survival game, and it’s been going pretty well but my item management(code wise) is pretty bad in my opinion. Each item is an actor, and I have an inventory array that I add each item there for the player. I also have chests, a hotbar array and an equipment array for armors. It’s a bit hard to track which item is where, my code is way too complicated, I’d like some advice from some more experienced developers. For example, I have an event to move an item between a chest and the player inventory.
Take a look at this:
I am not talking about the lines but the logic behind it, like I have to check 3 arrays, check if its found and removed, then add it to another array, update, change ownership blah blah, and the more things I add, the more complicated will get. Can you help me find a better way of handling items? I am thinking of making a variable in each item with the actor that has the item, and if it’s a character, save if it’s in the hotbar, inventory or equipment slot to create an icon in the right spot.