Exemplo n.º 1
0
        private void ItemIcon_SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, RoR2.UI.ItemIcon self, ItemIndex newItemIndex, int newItemCount)
        {
            orig(self, newItemIndex, newItemCount);

            if (newItemIndex == itemDef.itemIndex)
            {
                Transform parent = self.transform.parent;
                if (parent)
                {
                    RoR2.UI.ItemInventoryDisplay itemInventoryDisplay = parent.GetComponent <RoR2.UI.ItemInventoryDisplay>();
                    if (itemInventoryDisplay && itemInventoryDisplay.inventory)
                    {
                        MysticsItemsManuscript manuscript = itemInventoryDisplay.inventory.GetComponent <MysticsItemsManuscript>();
                        if (manuscript)
                        {
                            globalStringBuilder.Clear();
                            globalStringBuilder.Append(Language.GetString(self.tooltipProvider.bodyToken) + "\r\n");
                            globalStringBuilder.Append("\r\n");
                            globalStringBuilder.Append(Language.GetString("MYSTICSITEMS_STATCHANGE_LIST_HEADER"));
                            foreach (var buffType in manuscript.buffOrder)
                            {
                                globalStringBuilder.Append("\r\n");
                                globalStringBuilder.Append(
                                    Language.GetStringFormatted(
                                        "MYSTICSITEMS_STATCHANGE_LIST_" + buffType.ToString().ToUpperInvariant(),
                                        "+" + (manuscript.buffStacks[buffType] * statBonus).ToString(System.Globalization.CultureInfo.InvariantCulture)
                                        )
                                    );
                            }
                            globalStringBuilder.Append(tooltipString);
                            self.tooltipProvider.overrideBodyText = globalStringBuilder.ToString();
                            globalStringBuilder.Clear();
                        }
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(self.tooltipProvider.overrideBodyText) && self.tooltipProvider.overrideBodyText.Contains(tooltipString))
                {
                    self.tooltipProvider.overrideBodyText = "";
                }
            }
        }
Exemplo n.º 2
0
        private void ItemIcon_SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, RoR2.UI.ItemIcon self, ItemIndex newItemIndex, int newItemCount)
        {
            orig(self, newItemIndex, newItemCount);

            if (newItemIndex == itemDef.itemIndex)
            {
                Transform parent = self.transform.parent;
                if (parent)
                {
                    RoR2.UI.ItemInventoryDisplay itemInventoryDisplay = parent.GetComponent <RoR2.UI.ItemInventoryDisplay>();
                    if (itemInventoryDisplay && itemInventoryDisplay.inventory)
                    {
                        MysticsItemsMysticSwordBehaviour swordBehaviour = itemInventoryDisplay.inventory.GetComponent <MysticsItemsMysticSwordBehaviour>();
                        if (swordBehaviour)
                        {
                            globalStringBuilder.Clear();
                            globalStringBuilder.Append(Language.GetString(self.tooltipProvider.bodyToken) + "\r\n");
                            globalStringBuilder.Append("\r\n");
                            globalStringBuilder.Append(Language.GetString("MYSTICSITEMS_STATCHANGE_LIST_HEADER"));
                            globalStringBuilder.Append("\r\n");
                            globalStringBuilder.Append(
                                Language.GetStringFormatted(
                                    "MYSTICSITEMS_STATCHANGE_LIST_DAMAGE",
                                    "+" + (Mathf.RoundToInt(swordBehaviour.damageBonus * 100f)).ToString(System.Globalization.CultureInfo.InvariantCulture)
                                    )
                                );
                            globalStringBuilder.Append(tooltipString);
                            self.tooltipProvider.overrideBodyText = globalStringBuilder.ToString();
                            globalStringBuilder.Clear();
                        }
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(self.tooltipProvider.overrideBodyText) && self.tooltipProvider.overrideBodyText.Contains(tooltipString))
                {
                    self.tooltipProvider.overrideBodyText = "";
                }
            }
        }
Exemplo n.º 3
0
        private static void On_IIDUpdateDisplay(On.RoR2.UI.ItemInventoryDisplay.orig_UpdateDisplay orig, RoR2.UI.ItemInventoryDisplay self)
        {
            orig(self);
            Inventory inv = self.inventory;

            if (!inv)
            {
                return;
            }
            var fakeInv = inv.gameObject.GetComponent <FakeInventory>();

            if (!fakeInv)
            {
                return;
            }
            foreach (var icon in self.itemIcons)
            {
                var fakeCount = fakeInv.GetItemCount(icon.itemIndex);
                if (fakeCount == 0)
                {
                    continue;
                }
                var realCount = fakeInv.GetRealItemCount(icon.itemIndex);
                icon.stackText.enabled = true;
                icon.stackText.text    = $"x{realCount}\n<color=#C18FE0>+{fakeCount}</color>";
            }
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
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);
            }
        }