Search element by category

If I understand correctly you want to get a list of items in your Inventory that are part of an ItemCategory?

You'll find an example for that in the documentation. The last code example on this page:

C#:
//You can get multiple items from your item collections
//You'll need an array to store your item infos.
var array = new ItemInfo[0];
//You can use a pooled array instead of creating a new array each time. IMPORTANT: make sure to return the pooled array once you finished using it.
var pooledArray = GenericObjectPool.Get<ItemInfo[]>();

//Set your filter and sort parameters, for this example we'll filter by category.
var filterParameter = InventorySystemManager.GetItemCategory("MyCategory");

//Item info list slice will have all the itemInfos in the inventory that contain inherits the category.
//You can set whatever filter parameter you want.
var itemInfoListSlice = inventory.GetItemInfos(ref pooledArray, filterParameter,
    //Specify your filter
    (candidateItemInfo, category) => { return category.InherentlyContains(candidateItemInfo.Item); }
);

//IMPORTANT: Don't forget to return the pooled array once you finished using the array.
GenericObjectPool.Return(pooledArray);

Another way to do this is to loop over all your items in the ivnentory and check if it is part of a category.
The important part is this:
Code:
category.InherentlyContains(candidateItemInfo.Item)
 
Thanks.
I have another question is not related.
is about items with quality level

imagen_2022-07-05_130326146.png

witch is the best form to implement that? one item for each quality level? or there is another form to do that?

Thanks Again

Claudio
 
That is completely up to you. It depends on the type of game you are making, if you know how to code, etc...

Ask yourself those questions:
Are items with different quality have different attribute values?
Do they have random attribute values between certain range?
Do most of your items have multiple quality level, or just a few?
etc...

Depending on your answers you might find that a solution suits you better than another.
The solution at the top of my head are:

1) Make all items with all quality levels as ItemDefinition. This is best if you have different attribute values between quality but they are constants. You can make the higher quality versions children of the base quality version.

2) Proceduarlly make all the quality levels during initalization of the InventorySystemManager. When you load the database, you could write some custom code that automatically creates all the items of each quality level. That could save you time on manual work, but it only really works if all items are very similar

3) Procedurally make quality levels at runtime. This is the best approach if you plan to make random attributes or no attribute changes (except quality level) to your items. Essentially when you drop an item, or give an item to your player you change the quality level.

I recently added a documentation page on a custom random stat dropper so you might find that interesting:
https://opsive.com/support/document...currency-droppers/custom-random-item-dropper/


PS: you might find this video interesting for showing the quality level:

I hope that helps
 
Top