예제 #1
0
 public static void Trash()
 {
     if (HamHelpers.InValidSellArea() &&
         ToggleAutoSell && ToggleVendorTrash && Mod.Enabled)
     {
         long gold = 0;
         foreach (ItemEntity item in ItemSlotHelper.ItemsToRemove(out gold))
         {
             if (TrashItemsKeep.ContainsKey(item.Blueprint.AssetGuid))
             {
                 Game.Instance.Player.Inventory.Remove(item, item.Count - TrashItemsKeep[item.Blueprint.AssetGuid]);
             }
             else
             {
                 Game.Instance.Player.Inventory.Remove(item, item.Count);
             }
         }
         Game.Instance.Player.GainMoney(gold);
         LogItemData data = new LogItemData($"{gold} gold made from autoselling trash loot!", GameLogStrings.Instance.DefaultColor, null, PrefixIcon.None, new List <LogChannel>
         {
             LogChannel.None
         });
         Game.Instance.UI.BattleLogManager.LogView.AddLogEntry(data, false);
     }
 }
예제 #2
0
        public static List <ItemEntity> ItemsToRemove(out long gold)
        {
            Dictionary <string, int> keepCount = new Dictionary <string, int>();
            List <ItemEntity>        listSell  = new List <ItemEntity>();

            gold = 0;
            foreach (ItemEntity item in Game.Instance.Player.Inventory)
            {
                if (VendorTrashItems.Contains(item.Blueprint.AssetGuid) && item.IsInStash)
                {
                    if (keepCount.ContainsKey(item.Blueprint.AssetGuid))
                    {
                        if (keepCount[item.Blueprint.AssetGuid] >= TrashItemsKeep[item.Blueprint.AssetGuid])
                        {
                            continue;
                        }
                    }

                    gold += (item.Blueprint.SellPrice * (long)item.Count);

                    listSell.Add(item);
                    if (TrashItemsKeep.ContainsKey(item.Blueprint.AssetGuid))
                    {
                        if (keepCount.ContainsKey(item.Blueprint.AssetGuid))
                        {
                            keepCount[item.Blueprint.AssetGuid]++;
                        }
                        else
                        {
                            keepCount.Add(item.Blueprint.AssetGuid, 1);
                        }
                    }
                }
            }

            return(listSell);
        }
예제 #3
0
        public void OnGUI(UnityModManager.ModEntry modEntry)
        {
            if (!Mod.Enabled)
            {
                return;
            }
            if (toggleStyle == null)
            {
                toggleStyle = new GUIStyle(GUI.skin.toggle)
                {
                    wordWrap = true
                }
            }
            ;

            using (new GL.VerticalScope("box"))
            {
                ToggleVendorProgression = GL.Toggle(ToggleVendorProgression, Local["Menu_Tog_VenProgress"], Array.Empty <GLO>());
            }
            using (new GL.VerticalScope("box"))
            {
                ToggleHighlightScrolls = GL.Toggle(ToggleHighlightScrolls, Local["Menu_Tog_HLScrolls"], Array.Empty <GLO>());
                using (new GUISubScope())
                    ScrollColor = OnGUIColorSlider(ScrollColor, Local["Menu_Txt_Unlearned"]);
            }
            using (new GL.VerticalScope("box"))
            {
                ToggleVendorTrash = GL.Toggle(ToggleVendorTrash, Local["Menu_Tog_VendorTrash"], toggleStyle, GL.ExpandWidth(false));
                using (new GUISubScope())
                {
                    TrashColor     = OnGUIColorSlider(TrashColor, Local["Menu_Txt_VendorTrash"]);
                    ToggleAutoSell = GL.Toggle(ToggleAutoSell, Local["Menu_Tog_AutoSell"], toggleStyle, GL.ExpandWidth(false));
                    using (new GL.HorizontalScope())
                    {
                        if (GL.Button(ToggleShowTrash ? Local["Menu_Tog_HideTrash"] : Local["Menu_Tog_ShowTrash"], GL.ExpandWidth(false)))
                        {
                            ToggleShowTrash = !ToggleShowTrash;
                        }
                        if (GL.Button(Local["Menu_Btn_ClearTrash"], GL.ExpandWidth(false)))
                        {
                            VendorTrashItems.Clear();
                        }
                    }
                    if (ToggleShowTrash)
                    {
                        using (new GUISubScope())
                        {
                            string remove = "";

                            foreach (string trash in VendorTrashItems)
                            {
                                using (new GL.VerticalScope("box", GL.ExpandWidth(false)))
                                {
                                    using (new GL.HorizontalScope())
                                    {
                                        bool hasKeep = TrashItemsKeep.ContainsKey(trash);
                                        GL.Label($"{library.Get<BlueprintItem>(trash).Name} x{((hasKeep) ? TrashItemsKeep[trash] : 0)} {Local["Menu_Txt_Kept"]}", GL.MaxHeight(screenWidth), GL.MaxHeight(lineHeight));
                                        if (GL.Button("+", GL.ExpandWidth(false)))
                                        {
                                            if (hasKeep)
                                            {
                                                TrashItemsKeep[trash]++;
                                            }
                                            else
                                            {
                                                TrashItemsKeep.Add(trash, 1);
                                            }
                                        }
                                        if (GL.Button("-", GL.ExpandWidth(false)))
                                        {
                                            if (hasKeep && TrashItemsKeep[trash] > 0)
                                            {
                                                TrashItemsKeep[trash]--;
                                            }
                                            else if (hasKeep)
                                            {
                                                TrashItemsKeep.Remove(trash);
                                            }
                                        }

                                        if (GL.Button(Local["Menu_Btn_Remove"], GL.ExpandWidth(false)))
                                        {
                                            remove = trash;
                                        }

                                        if (Event.current.type == EventType.Repaint)
                                        {
                                            screenWidth = GUILayoutUtility.GetLastRect().width;
                                        }
                                    }
                                }
                            }
                            if (remove != "")
                            {
                                VendorTrashItems.Remove(remove);
                            }
                        }
                    }
                }
            }
            using (new GL.VerticalScope("box"))
            {
                using (new GUISubScope())
                    OnGUILang();
            }
        }