Best way to equip multiple of an equipment type?

I would really like my game will probably feature some sort of made up creature (as soon as I can find the right asset pack) as the main character. They will probably wear multiple rings or charms or similar rather than traditional weapon, armor, etc. But even with a human, games like Dragon Age for example allow the character to wear 2 rings. The dictionary seems incompatible with this. I also think that the “stackable” equipment type also would not be a great fit for this experience.

My idea was to create my own equipment script and more or less “hard code” it. e.g. 3 rings, 1 headgear piece, 2 charms. I think the interface methods would stay (almost) identical but the logic and backing store would just be different to accommodate what I want.

EDIT: I am thinking there will be some similarity of my Equipment with Inventory. An array of EquipmentSlot, which are each structs containing the EquipableItem and the EquipLocation. EquipmentSlotUI will be like InventorySlotUI in that it will have an index and map back to the Equipment script. None of the equipment slots will be stackable (though an individual Inventory item might be stackable in the inventory). It’s basically an inventory where each slot can only take a single type of item, but there may be multiple slots that can each take a common type.

Am I thinking about this straight?

I’ve played around with this idea before.

You want to maintain a fixed amount of slots for some items, and flexibilty for others… Here’s one idea that might work:

        [SerializeField] EquipLocation[] slotConfiguration;
        private Dictionary<int, EquipableItem> slots;

In the Equipment component (StatsEquipment) on the player, we would need to assign each EquipLocation to each available slot. This will allow you to have multiple EquipSlot.Ring slots.

EquipSlotUI would be changed to take in an int instead of an EquipLocation.

When checking to see if an item can be added to a slot, you would check the slotConfiguration[slot] to get the allowed Equip location.

2 Likes

Thanks. I’m curious why you opted for a Dictionary with int’s as keys instead of an array to parallel the slotConfiguration array. It seems Dictionary would be great if you have a wide range of non-sequential int’s (which is not the case here). Curious if they’re some other benefit I’m missing or if it’s just 6 of one and 1/2 dozen of the other.

Mostly reducing the volume of changes required to the system.

Cool thanks. I am in the midst of the ActionItem stuff now and seeing we use a Dictionary there too with int keys. I can see some value in having consistency.

In my rewrite of the Inventory, I actually use a Dictionary<int, InventorySlot> as well. I’m very fond of Dictionaries.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Can you please lead me through the changes I need to make to implement this idea? I also wanted to use two slots of the same type(e.g. weapons) but the current system duplicates a single item and fills both slots of the same type with it.

The answer I used for this question was theoretical, sort of off the cuff… it might be a few days, but I’ll see if i can flesh it out into something more useable.

1 Like

Thank you, any help is appreciated. As I stated in another post regarding multiple characters (with the risk of being redundant), i got the same duplication problem so hopefully one solution will tackle both problems.

Privacy & Terms