Custom Crafting UI based off drag and drop

nathanj

Active member
Hello,

Sorry for all the questions at once. Last one for the day ;)

I want to have a crafting UI that can open with the main inventory window where the play is able to drag items from their inventory into the crafting window and the ui will automatically check which crafting options are available based on the items they add.

You mind giving me an outline of how you would approach this?

Thanks again,
Nathan
 
Just to clarify, instead of selecting a crafting recipe you wish to mix&match items which may or may not be in a recipe? Similar to something like cooking in Zelda Breath of the Wild? Or do you want to Mix&Match items and then it gives you a list of possible recipes as you add more items?

The first thing I would do is create a custom CraftingProcessor and CraftingMenu. You can make your crafting menu from scratch using the default one as inspiration. You should use at least one custom ItemViewSlotContainer where you plan to drag and drop the items you select for crafting. You may have to create a custom drag&drop action, but I'm not sure that is necessary.

In your custom Crafting Processor I would find all the recipes for the selected Item. For that you can use the InventoryDatabaseUtility class
Code:
InventoryDatabaseUtility.DirectItemDefinitionRecipes(m_InventoryDatabase.CraftingRecipes, itemDefinition);
InventoryDatabaseUtility.InheritedItemDefinitionRecipes(m_InventoryDatabase.CraftingRecipes, itemDefinition);

You should be able to get the database from the InventorySystemManager, or instead you should be able to get all craftingRecipes directly from the InventorySystemManager, that might be better actually.

Make sure to cache the result since the function to find those recipes are quite slow.
Then you can compare the recipes between the items you've selected and keep a list of all the recipes that match. Then you can use the Crafting Processor to actually craft your item.

If you plan to have recipes that give you different results or better quality with luck, etc... then you'll be able to do it in the craftingprocessor. You may want to create a custom CraftingRecipe class but that shouldn't be necessary

I hope that helps
 
Top