I'm currently working on an inventory and item management system that uses a sort of loot table system for all possible items. The loot "table" is quite simple, it's just an array of my InventoryItem objects that I want to define in the Inspector.
Hypothetically, if I wanted to add one of those items to my player's inventory, through some sort of function like this:
inventory.AddItem(lootTable[1]);
It would just pass the reference to the same object in memory, so both my inventory class and my loot table class would be pointing at the same object.
Is there an easy way to clone that object, short of making an entirely new function to copy all the parameters to a new one?
Or, if there's a better way to implement a loot table like this I'm all ears.
↧