private void GetTradeables(bool save = true)
        {
            if (save && cachedTradeables.Count > 0)
            {
                Store_ItemEditor.UpdateStoreItems(cachedTradeables, tradeablesPrices);
            }

            lastSearch = searchQuery;

            cachedTradeables = new List <ThingDef>();

            string searchShort = string.Join("", searchQuery.Split(' ')).ToLower();

            Helper.Log("Finding tradeables");

            IEnumerable <ThingDef> tradeableitems = from t in DefDatabase <ThingDef> .AllDefs
                                                    where (t.tradeability.TraderCanSell() || ThingSetMakerUtility.CanGenerate(t)) &&
                                                    (t.building == null || t.Minifiable || ToolkitSettings.MinifiableBuildings) &&
                                                    (t.FirstThingCategory != null || t.race != null) &&
                                                    (t.BaseMarketValue > 0) &&
                                                    (searchQuery == "" ||
                                                     (
                                                         t.defName.ToLower().Contains(searchShort) ||
                                                         string.Join("", t.label.Split(' ')).ToLower().Contains(searchShort) ||
                                                         t.defName.ToLower() == searchShort ||
                                                         string.Join("", t.label.Split(' ')).ToLower() == searchShort ||
                                                         (
                                                             (t.race != null &&
                                                              t.race.Animal &&
                                                              (t.race.ToString().ToLower().Contains(searchQuery) ||
                                                               t.race.ToString().ToLower() == searchQuery ||
                                                               "animal".Contains(searchQuery) ||
                                                               searchQuery == "animal")
                                                             )
                                                             ||
                                                             (t.race == null &&
                                                              (t.FirstThingCategory == null ||
                                                               string.Join("", t.FirstThingCategory.LabelCap.RawText.Split(' ')).ToLower().Contains(searchShort) ||
                                                               t.FirstThingCategory.LabelCap.RawText.ToLower() == searchShort)
                                                             )
                                                         )
                                                     )
                                                    ) &&
                                                    t.defName != "Human"
                                                    orderby t.LabelCap.RawText
                                                    select t;

            foreach (ThingDef item in tradeableitems)
            {
                if (item.BaseMarketValue > 0f)
                {
                    cachedTradeables.Add(item);
                }
            }

            GetTradeablesPrices();
        }
        private void GetTradeables(bool save = true)
        {
            if (save && cachedTradeables.Count > 0)
            {
                Store_ItemEditor.UpdateStoreItems(cachedTradeables, tradeablesPrices);
            }

            lastSearch = searchQuery;

            cachedTradeables = new List <ThingDef>();

            string searchShort = string.Join("", searchQuery.Split(' ')).ToLower();

            IEnumerable <ThingDef> tradeableitems = from t in DefDatabase <ThingDef> .AllDefs
                                                    where (t.tradeability.TraderCanSell() || ThingSetMakerUtility.CanGenerate(t)) &&
                                                    (t.building == null || t.Minifiable || ToolkitSettings.MinifiableBuildings) &&
                                                    (t.FirstThingCategory != null) &&
                                                    (t.BaseMarketValue > 0) &&
                                                    (searchQuery == "" ||
                                                     (
                                                         t.defName.ToLower().Contains(searchShort) ||
                                                         string.Join("", t.label.Split(' ')).ToLower().Contains(searchShort) ||
                                                         t.defName.ToLower() == searchShort ||
                                                         string.Join("", t.label.Split(' ')).ToLower() == searchShort ||
                                                         (
                                                             t.FirstThingCategory == null ||
                                                             string.Join("", t.FirstThingCategory.LabelCap.Split(' ')).ToLower().Contains(searchShort) ||
                                                             t.FirstThingCategory.LabelCap.ToLower() == searchShort
                                                         )
                                                     )
                                                    )
                                                    orderby t.LabelCap
                                                    select t;

            foreach (ThingDef item in tradeableitems)
            {
                // item needs to be worth money, also not an animal
                if (item.BaseMarketValue > 0f && item.race == null)
                {
                    cachedTradeables.Add(item);
                }
            }

            GetTradeablesPrices();
        }
Beispiel #3
0
 public override void PostClose()
 {
     Store_ItemEditor.UpdateStoreItems(cachedTradeables, tradeablesPrices);
 }