private void PrepareLootItems(IChest chest) { int[] lootItems = chest.data.items; int[] mineItems = character.status.items; InventorySlot[] lootButtons = FillItemsTo(lootSlotsParent, lootItems); InventorySlot[] mineButtons = FillItemsTo(lootMineSlotsParent, mineItems); for (int i = 0; i < mineButtons.Length; i++) { int index = i; mineButtons [i].button.onClick.RemoveAllListeners(); mineButtons [i].button.onClick.AddListener(delegate { chest.AddFrom(character, character.status.GetItemByID(mineButtons[index].id)); }); } for (int i = 0; i < lootButtons.Length; i++) { int index = i; lootButtons [i].button.onClick.RemoveAllListeners(); lootButtons [i].button.onClick.AddListener(delegate { chest.CastTo(character, chest.GetItemByID(lootButtons[index].id)); }); } lootableChest = chest; }