Exemple #1
0
        public void OnSelectedRarity(ItemRarity rarity)
        {
            if (rarity == SelectedRarity)
            {
                return;
            }

            OnCraftCanceled();
            SelectedRarity = rarity;
            var nextButtonIndex = (int)SelectedRarity + 1;

            if (nextButtonIndex >= RarityButtons.Count)
            {
                nextButtonIndex = 0;
            }

            for (var index = 0; index < RarityButtons.Count; index++)
            {
                var rarityButton = RarityButtons[index];
                var gp           = rarityButton.GetComponent <UIGamePad>();
                if (gp != null)
                {
                    gp.enabled = index == nextButtonIndex;
                    gp.m_hint.SetActive(ZInput.IsGamepadActive() && index == RarityButtons.Count - 1);
                }
            }
        }
Exemple #2
0
            public static void Postfix(InventoryGui __instance)
            {
                var gamepadActive = ZInput.IsGamepadActive();
                var activeIndex   = 0;

                for (int i = 0; i < TabControllers.Count; i++)
                {
                    var tabController = TabControllers[i];
                    if (tabController.GamepadHint == null)
                    {
                        continue;
                    }

                    tabController.GamepadHint.SetActive(gamepadActive && (i == 0 || i == TabControllers.Count - 1));
                    if (tabController.IsActive())
                    {
                        activeIndex = i;
                    }
                }

                if (ZInput.GetButtonDown("JoyLStickLeft"))
                {
                    activeIndex--;
                    if (activeIndex < 0)
                    {
                        activeIndex = TabControllers.Count - 1;
                    }
                    OnTabPressed(TabControllers[activeIndex]);
                }
                else if (ZInput.GetButtonDown("JoyLStickRight"))
                {
                    activeIndex++;
                    if (activeIndex >= TabControllers.Count)
                    {
                        activeIndex = 0;
                    }
                    OnTabPressed(TabControllers[activeIndex]);
                }
            }
Exemple #3
0
 // Token: 0x06000AB0 RID: 2736 RVA: 0x0004D23C File Offset: 0x0004B43C
 private void Awake()
 {
     Game.m_instance = this;
     ZInput.Initialize();
     if (!global::Console.instance)
     {
         UnityEngine.Object.Instantiate <GameObject>(this.m_consolePrefab);
     }
     if (string.IsNullOrEmpty(Game.m_profileFilename))
     {
         this.m_playerProfile = new PlayerProfile("Developer");
         this.m_playerProfile.SetName("Odev");
         this.m_playerProfile.Load();
     }
     else
     {
         ZLog.Log("Loading player profile " + Game.m_profileFilename);
         this.m_playerProfile = new PlayerProfile(Game.m_profileFilename);
         this.m_playerProfile.Load();
     }
     base.InvokeRepeating("CollectResources", 600f, 600f);
     Gogan.LogEvent("Screen", "Enter", "InGame", 0L);
     Gogan.LogEvent("Game", "InputMode", ZInput.IsGamepadActive() ? "Gamepad" : "MK", 0L);
 }
Exemple #4
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);
            }
        }
    }
            public static bool Prefix(HotkeyBar __instance, Player player)
            {
                if (__instance.name != "QuickSlotsHotkeyBar")
                {
                    return(true);
                }

                if (player == null || player.IsDead())
                {
                    foreach (var element in __instance.m_elements)
                    {
                        Object.Destroy(element.m_go);
                    }

                    __instance.m_elements.Clear();
                }
                else
                {
                    player.GetQuickSlotInventory().GetBoundItems(__instance.m_items);
                    __instance.m_items.Sort((x, y) => x.m_gridPos.x.CompareTo(y.m_gridPos.x));
                    const int showElementCount = EquipmentAndQuickSlots.QuickSlotCount;
                    if (__instance.m_elements.Count != showElementCount)
                    {
                        foreach (var element in __instance.m_elements)
                        {
                            Object.Destroy(element.m_go);
                        }

                        __instance.m_elements.Clear();
                        for (var index = 0; index < showElementCount; ++index)
                        {
                            var elementData = new HotkeyBar.ElementData()
                            {
                                m_go = Object.Instantiate(__instance.m_elementPrefab, __instance.transform)
                            };
                            elementData.m_go.transform.localPosition = new Vector3(index * __instance.m_elementSpace, 0.0f, 0.0f);
                            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;

                            var bindingText = elementData.m_go.transform.Find("binding").GetComponent <Text>();
                            bindingText.enabled            = true;
                            bindingText.horizontalOverflow = HorizontalWrapMode.Overflow;
                            bindingText.text = EquipmentAndQuickSlots.GetBindingLabel(index);

                            __instance.m_elements.Add(elementData);
                        }
                    }

                    foreach (var element in __instance.m_elements)
                    {
                        element.m_used = false;
                    }

                    var isGamepadActive = ZInput.IsGamepadActive();
                    foreach (var itemData in __instance.m_items)
                    {
                        var element = __instance.m_elements[itemData.m_gridPos.x];
                        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.0)
                            {
                                element.m_durability.SetValue(1f);
                                element.m_durability.SetColor((double)Mathf.Sin(Time.time * 10f) > 0.0 ? 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.ToString() + "/" + itemData.m_shared.m_maxStackSize.ToString();
                        }
                        else
                        {
                            element.m_amount.gameObject.SetActive(false);
                        }
                    }

                    for (var index = 0; index < __instance.m_elements.Count; ++index)
                    {
                        var element = __instance.m_elements[index];
                        element.m_selection.SetActive(isGamepadActive && index == __instance.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);
            }
Exemple #6
0
    // Token: 0x0600052C RID: 1324 RVA: 0x0002B704 File Offset: 0x00029904
    private void UpdateGui(Player player, ItemDrop.ItemData dragItem)
    {
        RectTransform rectTransform = base.transform as RectTransform;
        int           width         = this.m_inventory.GetWidth();
        int           height        = this.m_inventory.GetHeight();

        if (this.m_selected.x >= width - 1)
        {
            this.m_selected.x = width - 1;
        }
        if (this.m_selected.y >= height - 1)
        {
            this.m_selected.y = height - 1;
        }
        if (this.m_width != width || this.m_height != height)
        {
            this.m_width  = width;
            this.m_height = height;
            foreach (InventoryGrid.Element element in this.m_elements)
            {
                UnityEngine.Object.Destroy(element.m_go);
            }
            this.m_elements.Clear();
            Vector2 widgetSize = this.GetWidgetSize();
            Vector2 a          = new Vector2(rectTransform.rect.width / 2f, 0f) - new Vector2(widgetSize.x, 0f) * 0.5f;
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Vector2    b          = new Vector3((float)j * this.m_elementSpace, (float)i * -this.m_elementSpace);
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_elementPrefab, this.m_gridRoot);
                    (gameObject.transform as RectTransform).anchoredPosition = a + b;
                    UIInputHandler componentInChildren = gameObject.GetComponentInChildren <UIInputHandler>();
                    componentInChildren.m_onRightDown = (Action <UIInputHandler>)Delegate.Combine(componentInChildren.m_onRightDown, new Action <UIInputHandler>(this.OnRightClick));
                    componentInChildren.m_onLeftDown  = (Action <UIInputHandler>)Delegate.Combine(componentInChildren.m_onLeftDown, new Action <UIInputHandler>(this.OnLeftClick));
                    Text component = gameObject.transform.Find("binding").GetComponent <Text>();
                    if (player && i == 0)
                    {
                        component.text = (j + 1).ToString();
                    }
                    else
                    {
                        component.enabled = false;
                    }
                    InventoryGrid.Element element2 = new InventoryGrid.Element();
                    element2.m_pos        = new Vector2i(j, i);
                    element2.m_go         = gameObject;
                    element2.m_icon       = gameObject.transform.Find("icon").GetComponent <Image>();
                    element2.m_amount     = gameObject.transform.Find("amount").GetComponent <Text>();
                    element2.m_quality    = gameObject.transform.Find("quality").GetComponent <Text>();
                    element2.m_equiped    = gameObject.transform.Find("equiped").GetComponent <Image>();
                    element2.m_queued     = gameObject.transform.Find("queued").GetComponent <Image>();
                    element2.m_noteleport = gameObject.transform.Find("noteleport").GetComponent <Image>();
                    element2.m_selected   = gameObject.transform.Find("selected").gameObject;
                    element2.m_tooltip    = gameObject.GetComponent <UITooltip>();
                    element2.m_durability = gameObject.transform.Find("durability").GetComponent <GuiBar>();
                    this.m_elements.Add(element2);
                }
            }
        }
        foreach (InventoryGrid.Element element3 in this.m_elements)
        {
            element3.m_used = false;
        }
        bool flag = this.m_uiGroup.IsActive() && ZInput.IsGamepadActive();

        foreach (ItemDrop.ItemData itemData in this.m_inventory.GetAllItems())
        {
            InventoryGrid.Element element4 = this.GetElement(itemData.m_gridPos.x, itemData.m_gridPos.y, width);
            element4.m_used         = true;
            element4.m_icon.enabled = true;
            element4.m_icon.sprite  = itemData.GetIcon();
            element4.m_icon.color   = ((itemData == dragItem) ? Color.grey : Color.white);
            element4.m_durability.gameObject.SetActive(itemData.m_shared.m_useDurability);
            if (itemData.m_shared.m_useDurability)
            {
                if (itemData.m_durability <= 0f)
                {
                    element4.m_durability.SetValue(1f);
                    element4.m_durability.SetColor((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f));
                }
                else
                {
                    element4.m_durability.SetValue(itemData.GetDurabilityPercentage());
                    element4.m_durability.ResetColor();
                }
            }
            element4.m_equiped.enabled    = (player && itemData.m_equiped);
            element4.m_queued.enabled     = (player && player.IsItemQueued(itemData));
            element4.m_noteleport.enabled = !itemData.m_shared.m_teleportable;
            if (dragItem == null)
            {
                this.CreateItemTooltip(itemData, element4.m_tooltip);
            }
            element4.m_quality.enabled = (itemData.m_shared.m_maxQuality > 1);
            if (itemData.m_shared.m_maxQuality > 1)
            {
                element4.m_quality.text = itemData.m_quality.ToString();
            }
            element4.m_amount.enabled = (itemData.m_shared.m_maxStackSize > 1);
            if (itemData.m_shared.m_maxStackSize > 1)
            {
                element4.m_amount.text = itemData.m_stack.ToString() + "/" + itemData.m_shared.m_maxStackSize.ToString();
            }
        }
        foreach (InventoryGrid.Element element5 in this.m_elements)
        {
            element5.m_selected.SetActive(flag && element5.m_pos == this.m_selected);
            if (!element5.m_used)
            {
                element5.m_durability.gameObject.SetActive(false);
                element5.m_icon.enabled       = false;
                element5.m_amount.enabled     = false;
                element5.m_quality.enabled    = false;
                element5.m_equiped.enabled    = false;
                element5.m_queued.enabled     = false;
                element5.m_noteleport.enabled = false;
                element5.m_tooltip.m_text     = "";
                element5.m_tooltip.m_topic    = "";
            }
        }
        float size = (float)height * this.m_elementSpace;

        this.m_gridRoot.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size);
    }
Exemple #7
0
    // Token: 0x0600051A RID: 1306 RVA: 0x0002AB7C File Offset: 0x00028D7C
    private void UpdateBuild(Player player, bool forceUpdateAllBuildStatuses)
    {
        if (!player.InPlaceMode())
        {
            this.m_buildHud.SetActive(false);
            this.m_pieceSelectionWindow.SetActive(false);
            return;
        }
        if (this.m_closePieceSelection > 0)
        {
            this.m_closePieceSelection--;
            if (this.m_closePieceSelection <= 0 && this.m_pieceSelectionWindow.activeSelf)
            {
                this.m_pieceSelectionWindow.SetActive(false);
            }
        }
        Piece      piece;
        Vector2Int selectedNr;
        int        num;

        Piece.PieceCategory pieceCategory;
        bool flag;

        player.GetBuildSelection(out piece, out selectedNr, out num, out pieceCategory, out flag);
        this.m_buildHud.SetActive(true);
        if (this.m_pieceSelectionWindow.activeSelf)
        {
            this.UpdatePieceList(player, selectedNr, pieceCategory, forceUpdateAllBuildStatuses);
            this.m_pieceCategoryRoot.SetActive(flag);
            if (flag)
            {
                for (int i = 0; i < this.m_pieceCategoryTabs.Length; i++)
                {
                    GameObject gameObject = this.m_pieceCategoryTabs[i];
                    Transform  transform  = gameObject.transform.Find("Selected");
                    string     text       = string.Concat(new object[]
                    {
                        this.m_buildCategoryNames[i],
                        " [<color=yellow>",
                        player.GetAvailableBuildPiecesInCategory((Piece.PieceCategory)i),
                        "</color>]"
                    });
                    if (i == (int)pieceCategory)
                    {
                        transform.gameObject.SetActive(true);
                        transform.GetComponentInChildren <Text>().text = text;
                    }
                    else
                    {
                        transform.gameObject.SetActive(false);
                        gameObject.GetComponentInChildren <Text>().text = text;
                    }
                }
            }
        }
        if (this.m_hoveredPiece && (ZInput.IsGamepadActive() || !player.IsPieceAvailable(this.m_hoveredPiece)))
        {
            this.m_hoveredPiece = null;
        }
        if (this.m_hoveredPiece)
        {
            this.SetupPieceInfo(this.m_hoveredPiece);
            return;
        }
        this.SetupPieceInfo(piece);
    }
Exemple #8
0
 // Token: 0x0600024C RID: 588 RVA: 0x00012B4C File Offset: 0x00010D4C
 private bool TakeInput()
 {
     return(!GameCamera.InFreeFly() && ((!Chat.instance || !Chat.instance.HasFocus()) && !Menu.IsVisible() && !global::Console.IsVisible() && !TextInput.IsVisible() && !Minimap.InTextInput() && (!ZInput.IsGamepadActive() || !Minimap.IsOpen()) && (!ZInput.IsGamepadActive() || !InventoryGui.IsVisible()) && (!ZInput.IsGamepadActive() || !StoreGui.IsVisible())) && (!ZInput.IsGamepadActive() || !Hud.IsPieceSelectionVisible()));
 }
        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);
                }
            }
        }
        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);
        }
Exemple #11
0
    // Token: 0x060002E2 RID: 738 RVA: 0x0001770C File Offset: 0x0001590C
    public bool Start(Humanoid character, Rigidbody body, ZSyncAnimation zanim, CharacterAnimEvent animEvent, VisEquipment visEquipment, ItemDrop.ItemData weapon, Attack previousAttack, float timeSinceLastAttack, float attackDrawPercentage)
    {
        if (this.m_attackAnimation == "")
        {
            return(false);
        }
        this.m_character            = character;
        this.m_baseAI               = this.m_character.GetComponent <BaseAI>();
        this.m_body                 = body;
        this.m_zanim                = zanim;
        this.m_animEvent            = animEvent;
        this.m_visEquipment         = visEquipment;
        this.m_weapon               = weapon;
        this.m_attackDrawPercentage = attackDrawPercentage;
        if (Attack.m_attackMask == 0)
        {
            Attack.m_attackMask = LayerMask.GetMask(new string[]
            {
                "Default",
                "static_solid",
                "Default_small",
                "piece",
                "piece_nonsolid",
                "character",
                "character_net",
                "character_ghost",
                "hitbox",
                "character_noenv",
                "vehicle"
            });
            Attack.m_attackMaskTerrain = LayerMask.GetMask(new string[]
            {
                "Default",
                "static_solid",
                "Default_small",
                "piece",
                "piece_nonsolid",
                "terrain",
                "character",
                "character_net",
                "character_ghost",
                "hitbox",
                "character_noenv",
                "vehicle"
            });
        }
        float staminaUsage = this.GetStaminaUsage();

        if (staminaUsage > 0f && !character.HaveStamina(staminaUsage + 0.1f))
        {
            if (character.IsPlayer())
            {
                Hud.instance.StaminaBarNoStaminaFlash();
            }
            return(false);
        }
        if (!Attack.HaveAmmo(character, this.m_weapon))
        {
            return(false);
        }
        Attack.EquipAmmoItem(character, this.m_weapon);
        if (this.m_attackChainLevels > 1)
        {
            if (previousAttack != null && previousAttack.m_attackAnimation == this.m_attackAnimation)
            {
                this.m_currentAttackCainLevel = previousAttack.m_nextAttackChainLevel;
            }
            if (this.m_currentAttackCainLevel >= this.m_attackChainLevels || timeSinceLastAttack > 0.2f)
            {
                this.m_currentAttackCainLevel = 0;
            }
            this.m_zanim.SetTrigger(this.m_attackAnimation + this.m_currentAttackCainLevel);
        }
        else if (this.m_attackRandomAnimations >= 2)
        {
            int num = UnityEngine.Random.Range(0, this.m_attackRandomAnimations);
            this.m_zanim.SetTrigger(this.m_attackAnimation + num);
        }
        else
        {
            this.m_zanim.SetTrigger(this.m_attackAnimation);
        }
        if (character.IsPlayer() && this.m_attackType != Attack.AttackType.None && this.m_currentAttackCainLevel == 0)
        {
            if (ZInput.IsMouseActive() || this.m_attackType == Attack.AttackType.Projectile)
            {
                character.transform.rotation = character.GetLookYaw();
                this.m_body.rotation         = character.transform.rotation;
            }
            else if (ZInput.IsGamepadActive() && !character.IsBlocking() && character.GetMoveDir().magnitude > 0.3f)
            {
                character.transform.rotation = Quaternion.LookRotation(character.GetMoveDir());
                this.m_body.rotation         = character.transform.rotation;
            }
        }
        weapon.m_lastAttackTime = Time.time;
        this.m_animEvent.ResetChain();
        return(true);
    }