Example #1
0
        private static void On_IIDInventoryChanged(On.RoR2.UI.ItemInventoryDisplay.orig_OnInventoryChanged orig, RoR2.UI.ItemInventoryDisplay self)
        {
            orig(self);
            if (!self || !self.isActiveAndEnabled || !self.inventory)
            {
                return;
            }
            var fakeInv = self.inventory.GetComponent <FakeInventory>();

            if (!fakeInv)
            {
                return;
            }
            List <ItemIndex> newAcqOrder = self.itemOrder.Take(self.itemOrderCount).ToList();

            for (int i = 0; i < self.itemStacks.Length; i++)
            {
                if (self.itemStacks[i] == 0)
                {
                    if (fakeInv._itemStacks[i] > 0)
                    {
                        newAcqOrder.Add((ItemIndex)i);
                    }
                    else
                    {
                        newAcqOrder.Remove((ItemIndex)i);
                    }
                }

                self.itemStacks[i] += fakeInv._itemStacks[i];
            }
            newAcqOrder = newAcqOrder.Distinct().ToList();
            newAcqOrder.CopyTo(0, self.itemOrder, 0, Mathf.Min(self.itemOrder.Length, newAcqOrder.Count));
            self.itemOrderCount = newAcqOrder.Count;
        }
Example #2
0
        public void ItemInventoryDisplay_OnInventoryChanged(On.RoR2.UI.ItemInventoryDisplay.orig_OnInventoryChanged orig, RoR2.UI.ItemInventoryDisplay self)
        {
            orig(self);

            if (self.itemOrder != null && self.inventory && self.inventory.itemAcquisitionOrder.Any())
            {
                sortItems(self.inventory.itemAcquisitionOrder, self.inventory, mod.config.SortingSortOrder.Value).ToList().CopyTo(self.itemOrder);
            }
        }