public void Show(ItemDrop.ItemData item)
        {
            gameObject.SetActive(true);

            var rarityColor = item.IsMagic() ? item.GetRarityColor() : Color.white;

            MagicBG.enabled = item.IsMagic();
            MagicBG.color   = rarityColor;

            NameText.text    = Localization.instance.Localize(item.GetDecoratedName());
            Description.text = Localization.instance.Localize(item.GetTooltip());
            Icon.sprite      = item.GetIcon();

            if (item.IsMagic())
            {
                _audioSource.PlayOneShot(EpicLoot.GetMagicItemDropSFX(item.GetRarity()));
            }
        }
        public void Show(ItemDrop.ItemData item)
        {
            gameObject.SetActive(true);

            var rarityColor = item.IsMagic() ? item.GetRarityColor() : Color.white;

            if (MagicBG != null)
            {
                MagicBG.enabled = item.IsMagic();
                MagicBG.color   = rarityColor;
            }

            if (EpicLoot.HasAuga)
            {
                Auga.API.ComplexTooltip_SetItem(gameObject, item);
                EpicLoot.ExtendAugaTooltipForMagicItem(gameObject, item);
            }

            if (NameText != null)
            {
                NameText.text = Localization.instance.Localize(item.GetDecoratedName());
            }

            if (Description != null)
            {
                Description.text = Localization.instance.Localize(item.GetTooltip());
            }

            if (Icon != null)
            {
                Icon.sprite = item.GetIcon();
            }

            if (item.IsMagic())
            {
                _audioSource.PlayOneShot(EpicLoot.GetMagicItemDropSFX(item.GetRarity()));
            }
        }
Beispiel #3
0
    // Token: 0x060004F3 RID: 1267 RVA: 0x00028F64 File Offset: 0x00027164
    private void UpdateIcons(Player player)
    {
        if (!player || player.IsDead())
        {
            foreach (HotkeyBar.ElementData elementData in this.m_elements)
            {
                UnityEngine.Object.Destroy(elementData.m_go);
            }
            this.m_elements.Clear();
            return;
        }
        player.GetInventory().GetBoundItems(this.m_items);
        this.m_items.Sort((ItemDrop.ItemData x, ItemDrop.ItemData y) => x.m_gridPos.x.CompareTo(y.m_gridPos.x));
        int num = 0;

        foreach (ItemDrop.ItemData itemData in this.m_items)
        {
            if (itemData.m_gridPos.x + 1 > num)
            {
                num = itemData.m_gridPos.x + 1;
            }
        }
        if (this.m_elements.Count != num)
        {
            foreach (HotkeyBar.ElementData elementData2 in this.m_elements)
            {
                UnityEngine.Object.Destroy(elementData2.m_go);
            }
            this.m_elements.Clear();
            for (int i = 0; i < num; i++)
            {
                HotkeyBar.ElementData elementData3 = new HotkeyBar.ElementData();
                elementData3.m_go = UnityEngine.Object.Instantiate <GameObject>(this.m_elementPrefab, base.transform);
                elementData3.m_go.transform.localPosition = new Vector3((float)i * this.m_elementSpace, 0f, 0f);
                elementData3.m_go.transform.Find("binding").GetComponent <Text>().text = (i + 1).ToString();
                elementData3.m_icon       = elementData3.m_go.transform.transform.Find("icon").GetComponent <Image>();
                elementData3.m_durability = elementData3.m_go.transform.Find("durability").GetComponent <GuiBar>();
                elementData3.m_amount     = elementData3.m_go.transform.Find("amount").GetComponent <Text>();
                elementData3.m_equiped    = elementData3.m_go.transform.Find("equiped").gameObject;
                elementData3.m_queued     = elementData3.m_go.transform.Find("queued").gameObject;
                elementData3.m_selection  = elementData3.m_go.transform.Find("selected").gameObject;
                this.m_elements.Add(elementData3);
            }
        }
        foreach (HotkeyBar.ElementData elementData4 in this.m_elements)
        {
            elementData4.m_used = false;
        }
        bool flag = ZInput.IsGamepadActive();

        for (int j = 0; j < this.m_items.Count; j++)
        {
            ItemDrop.ItemData     itemData2    = this.m_items[j];
            HotkeyBar.ElementData elementData5 = this.m_elements[itemData2.m_gridPos.x];
            elementData5.m_used = true;
            elementData5.m_icon.gameObject.SetActive(true);
            elementData5.m_icon.sprite = itemData2.GetIcon();
            elementData5.m_durability.gameObject.SetActive(itemData2.m_shared.m_useDurability);
            if (itemData2.m_shared.m_useDurability)
            {
                if (itemData2.m_durability <= 0f)
                {
                    elementData5.m_durability.SetValue(1f);
                    elementData5.m_durability.SetColor((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f));
                }
                else
                {
                    elementData5.m_durability.SetValue(itemData2.GetDurabilityPercentage());
                    elementData5.m_durability.ResetColor();
                }
            }
            elementData5.m_equiped.SetActive(itemData2.m_equiped);
            elementData5.m_queued.SetActive(player.IsItemQueued(itemData2));
            if (itemData2.m_shared.m_maxStackSize > 1)
            {
                elementData5.m_amount.gameObject.SetActive(true);
                elementData5.m_amount.text = itemData2.m_stack.ToString() + "/" + itemData2.m_shared.m_maxStackSize.ToString();
            }
            else
            {
                elementData5.m_amount.gameObject.SetActive(false);
            }
        }
        for (int k = 0; k < this.m_elements.Count; k++)
        {
            HotkeyBar.ElementData elementData6 = this.m_elements[k];
            elementData6.m_selection.SetActive(flag && k == this.m_selected);
            if (!elementData6.m_used)
            {
                elementData6.m_icon.gameObject.SetActive(false);
                elementData6.m_durability.gameObject.SetActive(false);
                elementData6.m_equiped.SetActive(false);
                elementData6.m_queued.SetActive(false);
                elementData6.m_amount.gameObject.SetActive(false);
            }
        }
    }
        private void UpdateIcons(Player player)
        {
            if (!player || player.IsDead())
            {
                foreach (ElementData elementData in m_elements)
                {
                    Destroy(elementData.m_go);
                }
                m_elements.Clear();
                return;
            }

            m_items.Clear();

            Inventory inv = player.GetInventory();

            if (inv.GetItemAt(5, inv.GetHeight() - 1) != null)
            {
                m_items.Add(inv.GetItemAt(5, inv.GetHeight() - 1));
            }
            if (inv.GetItemAt(6, inv.GetHeight() - 1) != null)
            {
                m_items.Add(inv.GetItemAt(6, inv.GetHeight() - 1));
            }
            if (inv.GetItemAt(7, inv.GetHeight() - 1) != null)
            {
                m_items.Add(inv.GetItemAt(7, inv.GetHeight() - 1));
            }

            m_items.Sort((ItemDrop.ItemData x, ItemDrop.ItemData y) => x.m_gridPos.x.CompareTo(y.m_gridPos.x));
            int num = 0;

            foreach (ItemDrop.ItemData itemData in m_items)
            {
                if (itemData.m_gridPos.x - 4 > num)
                {
                    num = itemData.m_gridPos.x - 4;
                }
            }

            if (m_elements.Count != num)
            {
                foreach (ElementData elementData in m_elements)
                {
                    Destroy(elementData.m_go);
                }
                m_elements.Clear();
                for (int i = 0; i < num; i++)
                {
                    ElementData elementData = new ElementData();
                    elementData.m_go = Instantiate(m_elementPrefab, transform);
                    elementData.m_go.transform.localPosition = new Vector3(i * m_elementSpace, 0f, 0f);
                    elementData.m_go.transform.Find("binding").GetComponent <Text>().text = BepInExPlugin.hotkeys[i].Value;
                    elementData.m_icon       = elementData.m_go.transform.transform.Find("icon").GetComponent <Image>();
                    elementData.m_durability = elementData.m_go.transform.Find("durability").GetComponent <GuiBar>();
                    elementData.m_amount     = elementData.m_go.transform.Find("amount").GetComponent <Text>();
                    elementData.m_equiped    = elementData.m_go.transform.Find("equiped").gameObject;
                    elementData.m_queued     = elementData.m_go.transform.Find("queued").gameObject;
                    elementData.m_selection  = elementData.m_go.transform.Find("selected").gameObject;
                    m_elements.Add(elementData);
                }
            }

            foreach (ElementData elementData in m_elements)
            {
                elementData.m_used = false;
            }
            bool flag = ZInput.IsGamepadActive();

            for (int j = 0; j < m_items.Count; j++)
            {
                ItemDrop.ItemData itemData2   = m_items[j];
                ElementData       elementData = m_elements[itemData2.m_gridPos.x - 5];
                elementData.m_used = true;
                elementData.m_icon.gameObject.SetActive(true);
                elementData.m_icon.sprite = itemData2.GetIcon();
                elementData.m_durability.gameObject.SetActive(itemData2.m_shared.m_useDurability);
                if (itemData2.m_shared.m_useDurability)
                {
                    if (itemData2.m_durability <= 0f)
                    {
                        elementData.m_durability.SetValue(1f);
                        elementData.m_durability.SetColor((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f));
                    }
                    else
                    {
                        elementData.m_durability.SetValue(itemData2.GetDurabilityPercentage());
                        elementData.m_durability.ResetColor();
                    }
                }
                elementData.m_equiped.SetActive(itemData2.m_equiped);
                elementData.m_queued.SetActive(player.IsItemQueued(itemData2));
                if (itemData2.m_shared.m_maxStackSize > 1)
                {
                    elementData.m_amount.gameObject.SetActive(true);
                    elementData.m_amount.text = itemData2.m_stack.ToString() + "/" + itemData2.m_shared.m_maxStackSize.ToString();
                }
                else
                {
                    elementData.m_amount.gameObject.SetActive(false);
                }
            }

            for (int k = 0; k < m_elements.Count; k++)
            {
                ElementData elementData = m_elements[k];
                elementData.m_selection.SetActive(flag && k == m_selected);
                if (!elementData.m_used)
                {
                    elementData.m_icon.gameObject.SetActive(false);
                    elementData.m_durability.gameObject.SetActive(false);
                    elementData.m_equiped.SetActive(false);
                    elementData.m_queued.SetActive(false);
                    elementData.m_amount.gameObject.SetActive(false);
                }
            }
        }
Beispiel #5
0
        /**
         * loop the inventory hotbar and set corresponding item icons + activate equipped layers
         */
        public override void refreshItems()
        {
            if (Player.m_localPlayer == null)
            {
                return;
            }

            elementCount = 0;
            var inventory = Player.m_localPlayer.GetInventory();

            for (int i = 0; i < 8; i++)
            {
                ItemDrop.ItemData item = inventory?.GetItemAt(i, 0);

                if (item == null)
                {
                    continue;
                }

                switch (item.m_shared.m_itemType)
                {
                case ItemDrop.ItemData.ItemType.Tool:
                case ItemDrop.ItemData.ItemType.Torch:
                case ItemDrop.ItemData.ItemType.OneHandedWeapon:
                case ItemDrop.ItemData.ItemType.TwoHandedWeapon:
                    elements[elementCount].transform.GetChild(1).gameObject.SetActive(item.m_equiped || item.m_durability == 0);
                    if (item.m_durability == 0)
                    {
                        elements[elementCount].transform.GetChild(1).GetComponent <SpriteRenderer>().color = Color.red;
                    }
                    else
                    {
                        elements[elementCount].transform.GetChild(1).GetComponent <SpriteRenderer>().color = Color.white;
                    }
                    elements[elementCount].transform.GetChild(2).GetComponent <SpriteRenderer>().sprite = item.GetIcon();
                    elements[elementCount].name = i.ToString();
                    elementCount++;
                    break;
                }
            }

            reorderElements();
        }
Beispiel #6
0
        public static bool Prefix(HotkeyBar __instance, Player player, List <HotkeyBar.ElementData> ___m_elements, List <ItemDrop.ItemData> ___m_items, int ___m_selected)
        {
            if (!EquipmentAndQuickSlots.QuickSlotsEnabled.Value)
            {
                return(true);
            }

            if (player == null || player.IsDead())
            {
                foreach (HotkeyBar.ElementData element in ___m_elements)
                {
                    UnityEngine.Object.Destroy((UnityEngine.Object)element.m_go);
                }
                ___m_elements.Clear();
            }
            else
            {
                player.GetInventory().GetBoundItems(___m_items);
                ___m_items.Sort((Comparison <ItemDrop.ItemData>)((a, b) => a.m_gridPos.y == b.m_gridPos.y ? a.m_gridPos.x.CompareTo(b.m_gridPos.x) : a.m_gridPos.y.CompareTo(b.m_gridPos.y)));
                int num = player.GetInventory().m_width + EquipmentAndQuickSlots.QuickUseSlotCount;
                if (___m_elements.Count != num)
                {
                    foreach (HotkeyBar.ElementData element in ___m_elements)
                    {
                        UnityEngine.Object.Destroy((UnityEngine.Object)element.m_go);
                    }
                    ___m_elements.Clear();
                    for (int index = 0; index < num; ++index)
                    {
                        var parent = __instance.transform;
                        if (index >= 8)
                        {
                            parent = __instance.transform.parent.Find("healthpanel");
                        }
                        HotkeyBar.ElementData elementData = new HotkeyBar.ElementData()
                        {
                            m_go = UnityEngine.Object.Instantiate <GameObject>(__instance.m_elementPrefab, parent)
                        };

                        if (index < 8)
                        {
                            elementData.m_go.transform.localPosition = new Vector3(index * __instance.m_elementSpace, 0.0f, 0.0f);
                            elementData.m_go.transform.Find("binding").GetComponent <Text>().text = (index + 1).ToString();
                        }
                        else
                        {
                            var offset         = new Vector2(100, -150);
                            var quickSlotIndex = index - 8;
                            elementData.m_go.transform.localPosition    = new Vector3(offset.x, offset.y - quickSlotIndex * __instance.m_elementSpace, 0.0f);
                            elementData.m_go.transform.localEulerAngles = new Vector3(0, 0, -90);
                            string label       = EquipmentAndQuickSlots.GetBindingLabel(quickSlotIndex);
                            var    bindingText = elementData.m_go.transform.Find("binding").GetComponent <Text>();
                            bindingText.text = label;
                            bindingText.horizontalOverflow = HorizontalWrapMode.Overflow;
                        }
                        elementData.m_icon       = elementData.m_go.transform.transform.Find("icon").GetComponent <Image>();
                        elementData.m_durability = elementData.m_go.transform.Find("durability").GetComponent <GuiBar>();
                        elementData.m_amount     = elementData.m_go.transform.Find("amount").GetComponent <Text>();
                        elementData.m_equiped    = elementData.m_go.transform.Find("equiped").gameObject;
                        elementData.m_queued     = elementData.m_go.transform.Find("queued").gameObject;
                        elementData.m_selection  = elementData.m_go.transform.Find("selected").gameObject;
                        ___m_elements.Add(elementData);
                    }
                }

                foreach (HotkeyBar.ElementData element in ___m_elements)
                {
                    element.m_used = false;
                }

                bool isGamepadActive = ZInput.IsGamepadActive();
                for (int index = 0; index < ___m_items.Count; ++index)
                {
                    ItemDrop.ItemData     itemData = ___m_items[index];
                    HotkeyBar.ElementData element  = GetElementForItem(___m_elements, itemData);
                    element.m_used = true;
                    element.m_icon.gameObject.SetActive(true);
                    element.m_icon.sprite = itemData.GetIcon();
                    element.m_durability.gameObject.SetActive(itemData.m_shared.m_useDurability);
                    if (itemData.m_shared.m_useDurability)
                    {
                        if (itemData.m_durability <= 0.0f)
                        {
                            element.m_durability.SetValue(1.0f);
                            element.m_durability.SetColor(Mathf.Sin(Time.time * 10.0f) > 0.0f ? Color.red : new Color(0.0f, 0.0f, 0.0f, 0.0f));
                        }
                        else
                        {
                            element.m_durability.SetValue(itemData.GetDurabilityPercentage());
                            element.m_durability.ResetColor();
                        }
                    }
                    element.m_equiped.SetActive(itemData.m_equiped);
                    element.m_queued.SetActive(player.IsItemQueued(itemData));
                    if (itemData.m_shared.m_maxStackSize > 1)
                    {
                        element.m_amount.gameObject.SetActive(true);
                        element.m_amount.text = $"{itemData.m_stack}/{itemData.m_shared.m_maxStackSize}";
                    }
                    else
                    {
                        element.m_amount.gameObject.SetActive(false);
                    }
                }

                for (int index = 0; index < ___m_elements.Count; ++index)
                {
                    HotkeyBar.ElementData element = ___m_elements[index];
                    element.m_selection.SetActive(isGamepadActive && index == ___m_selected);
                    if (!element.m_used)
                    {
                        element.m_icon.gameObject.SetActive(false);
                        element.m_durability.gameObject.SetActive(false);
                        element.m_equiped.SetActive(false);
                        element.m_queued.SetActive(false);
                        element.m_amount.gameObject.SetActive(false);
                    }
                }
            }

            return(false);
        }
            static bool Prefix(Character __instance, ItemDrop.ItemData item, int amount)
            {
                if (!modEnabled.Value || !IsDoorKey(item))
                {
                    return(true);
                }

                __instance.Message(MessageHud.MessageType.TopLeft, "$msg_added " + string.Format(keyName.Value, GetDoorName(item.m_crafterName), amount, item.GetIcon()));
                return(false);
            }
        public override void refreshItems()
        {
            if (Player.m_localPlayer == null)
            {
                return;
            }

            elementCount = 0;
            var inventory = Player.m_localPlayer.GetInventory();

            for (int i = 0; i < 8; i++)
            {
                ItemDrop.ItemData item = inventory.GetItemAt(i, 0);

                if (item == null)
                {
                    continue;
                }

                switch (item.m_shared.m_itemType)
                {
                case ItemDrop.ItemData.ItemType.Tool:
                case ItemDrop.ItemData.ItemType.Torch:
                case ItemDrop.ItemData.ItemType.OneHandedWeapon:
                case ItemDrop.ItemData.ItemType.TwoHandedWeapon:
                    break;

                default:

                    elements[elementCount].transform.GetChild(1).gameObject.SetActive(item.m_equiped || item.m_durability == 0);
                    if (item.m_durability == 0)
                    {
                        elements[elementCount].transform.GetChild(1).GetComponent <SpriteRenderer>().color = Color.red;
                    }
                    else
                    {
                        elements[elementCount].transform.GetChild(1).GetComponent <SpriteRenderer>().color = Color.white;
                    }
                    elements[elementCount].transform.GetChild(2).GetComponent <SpriteRenderer>().sprite = item.GetIcon();
                    elements[elementCount].name = i.ToString();
                    elementCount++;
                    break;
                }
            }

            StatusEffect se;
            float        cooldown;

            Player.m_localPlayer.GetGuardianPowerHUD(out se, out cooldown);
            if (se)
            {
                hasGPower = true;
                elements[elementCount].transform.GetChild(2).GetComponent <SpriteRenderer>().sprite = se.m_icon;
                elementCount++;
            }

            elements[elementCount].transform.GetChild(2).GetComponent <SpriteRenderer>().sprite = Sprite.Create(sitTexture,
                                                                                                                new Rect(0.0f, 0.0f, sitTexture.width, sitTexture.height),
                                                                                                                new Vector2(0.5f, 0.5f), 500);
            elementCount++;

            elements[elementCount].transform.GetChild(2).GetComponent <SpriteRenderer>().sprite = Sprite.Create(mapTexture,
                                                                                                                new Rect(0.0f, 0.0f, mapTexture.width, mapTexture.height),
                                                                                                                new Vector2(0.5f, 0.5f), 500);
            elementCount++;

            reorderElements();
        }