Download

What to use instead of maps for getting an asset from name?

Say I have an inventory system, which adds images of the items to inventory widget according to their name, is there a better way to do this than have a Map(string, image) and then finding from that map with the name?

What’s wrong with doing it with a map, just out of interest?

You could just give the items an integer ID, and then use simple arrays. It can lead to easier code later, when comparing IDs for example.

I feel like it will be too complicated to add a new item since currently I use maps for what animation to use when holding an item, which socket to attach to and the description of the item all in different maps, I think I could use data tables for the descriptions and sockets but things like animations I don’t know what I should do

Data tables might be a good choice for me, after looking into it a little bit

I use structs in the parent class. Create a child class and fill in the structs. For the structs themselves I break the data down into categories and create a struct for each category. Base data, Animation, FX, Specifications etc. In the animation struct I’ll have socket names, offsets, play rates, montages etc.

How do you query a specific entry?

I use a direct reference. Item -> base data -> icon