Feature Request - Choose ingredient collections for crafting

Beor Games

New member
Hey there!

I wrote on Discord already that I need to prevent the crafting system from using equipped items. That's because now, if I end up using an equipped items as a material it gets destroyed and the new item isn't awarded to the players.

It would be great if we could choose which collections the crafter can select items.
 
So this was a bit more complicated than I thought it would be.

It required me to change the SimpleCraftingProcessor and the ItemCollectionGroup script. You can find the scripts attached.
So now you can define your ItemCollections here. (if empty it will use the entire inventory like it does now)
1670322796918.png



Also, the UI doesn't know about the amount that can be crafted. So you'll need to make sure your prefab for your Ingredient ItemView, has an ItemViewModule to compare the amounts with a list of ItemCollections that matches to one from the crafter:
1670322746591.png
I hope that helps, I haven't tested it thouroughly, so if you find any bugs do let me know
 

Attachments

  • ItemCollectionGroup.cs
    30 KB · Views: 2
  • SimpleCraftingProcessor.cs
    27.1 KB · Views: 2
Hey thanks for working on this! I'm sorry to cause more trouble :X

Right from the start when I switched the script I got the following error:

1670347495475.png

So I commented that line and moved forward.
1670347511788.png

I set up the Crafter with the inventory
1670348045271.png

And prepared the ingredient view with the requirements, but I get this error at the bottom if I try to modify the quantity I can craft. It lets me raise from 1 to 2, but won't craft the items.
1670347965245.png
 
I guess I must have added ListSlice<T>.Empty more recently than I thought.

You can remplace it by
Code:
new ListSlice<ItemInfo>();

And could you also replace the 47-51 by
Code:
 protected List<ItemCollection> m_ItemCollections = new List<ItemCollection>();
 protected List<ItemCollection> m_IgnoreCollections = new List<ItemCollection>();
 protected List<ItemStack> m_AllItemStacks = new List<ItemStack>();
 protected List<ItemInfo> m_AllItemInfos = new List<ItemInfo>();

That should prevent getting a null reference.
 
Top