What is the best method of storing data for a weapons crafting system?

Hello all,

I have been trying to figure out the best method of doing a weapons crafting system (where a user uses parts to build a weapon). However, barring using DBs or having a giant array of possible combos, there are not many options for storing necessary relationship data.

I was thinking that maybe if I prefab all of the weapons with a parts list attached to it I could check against that and the player’s inventory. However, I have not been able to decipher a way to check details about a prefab BEFORE it is instantiated. Is there a way of doing this? Is there a better method all together (or am I left with options stated in the first paragraph)?

I don’t believe you are able to check properties about prefabs before instantiation. I could be wrong though.

The database problem is only very inefficient if the user can craft weapons they don’t know about by combining materials and seeing what’s created. If the users has to select the “recipe” to make, you can do a simple check for it’s ingredients against the player’s inventory or ingredient storage. Each recipe would have a list of separate ingredients (either by string id’s or integer id’s in an array) and these are checked when the user wants to create such an item. Not terrible hard however.

You can also use more efficient data structures, such as hash tables, binary search trees, AVL trees, or a linked hash map to store your data. If it’s for desktop, you don’t have to optimize here however, as this won’t be that performance hogging of a check to do on a desktop. If it’s for mobile i would probably try an AVL or binary tree if you can, but data base searching is still not horrendous as the user isn’t going to be doing a crap ton else while crafting these guns.