Beispiel #1
0
        private void RefreshCategories()
        {
            foreach (CategorySlot slot in slots)
            {
                slot.Hide();
            }

            PlayerCharacter player = parent_ui.GetPlayer();

            if (player != null)
            {
                int index = 0;
                List <GroupData> groups = player.Crafting.GetCraftGroups();

                foreach (GroupData group in groups)
                {
                    if (index < slots.Length)
                    {
                        CategorySlot     slot  = (CategorySlot)slots[index];
                        List <CraftData> items = CraftData.GetAllCraftableInGroup(parent_ui.GetPlayer(), group);
                        if (items.Count > 0)
                        {
                            slot.SetSlot(group);
                            index++;
                        }
                    }
                }

                CraftSubPanel.Get(GetPlayerID())?.Hide();
            }
        }
Beispiel #2
0
        public void RefreshCraftPanel()
        {
            foreach (ItemSlot slot in slots)
            {
                slot.Hide();
            }

            if (current_category == null || !IsVisible())
            {
                return;
            }

            //Show all items of a category
            PlayerCharacter player = GetPlayer();

            if (player != null)
            {
                List <CraftData> items = CraftData.GetAllCraftableInGroup(parent_ui.GetPlayer(), current_category);

                //Sort list
                items.Sort((p1, p2) =>
                {
                    return((p1.craft_sort_order == p2.craft_sort_order)
                        ? p1.title.CompareTo(p2.title) : p1.craft_sort_order.CompareTo(p2.craft_sort_order));
                });

                for (int i = 0; i < items.Count; i++)
                {
                    if (i < slots.Length)
                    {
                        CraftData item = items[i];
                        ItemSlot  slot = (ItemSlot)slots[i];
                        slot.SetSlot(item, 1, false);
                        slot.AnimateGain();
                    }
                }
            }
        }