Random Items From main InventoryManager

joran

New member
How can i get a random item(item definition?)(or N random items) from the InventoryManager (this is basically the random pickup script... but i really do not want to copy my entire inventoryDB to the Inventory on the gameobjects MainCollection ...

I would like to restrict the items somewhat (maybe items that have a sell price between two values or something along those lines(more realistically on ItemLevel, or ItemRarity...) Im pretty sure i can figure this part out if I can figure out how to get a random item from the inventorymanager.


so far the best i can come up with is

Code:
uint index = (uint)Random.Range(0, InventorySystemManager.ItemDefinitionRegister.Count);

but that is definitely not the item.ID, and im not sure how to use that to get a specific definition from an index...
 
ahh actually I just found this thread which may answer my question

 
You can use the InventorySytemManager to get all the ItemDefinitions in the system.
Then you filter that list using your conditions.
Then you choose one randomly
Finally you create an Item using that random definition.
var randomItem = InventorySystemManager.Create(randomItemDefintion)
 
Top