private static bool SpawnableThingDefsPredicate(ThingDef thingDef) { return( (thingDef.tradeability.TraderCanSell() || ThingSetMakerUtility.CanGenerate(thingDef)) && (thingDef.building == null || thingDef.Minifiable) && thingDef.BaseMarketValue > 0 && thingDef.race != null ); }
public static IEnumerable <ThingDef> GetDefaultItems() { return(from t in DefDatabase <ThingDef> .AllDefs where (t.tradeability.TraderCanSell() || ThingSetMakerUtility.CanGenerate(t)) && (t.building == null || t.Minifiable || ToolkitSettings.MinifiableBuildings) && (t.BaseMarketValue > 0) orderby t.LabelCap select t); }
public static IEnumerable <ThingDef> GetDefaultItems() { return(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) orderby t.LabelCap.RawText select t); //return from t in DefDatabase<ThingDef>.AllDefs // where (t.tradeability.TraderCanSell() || ThingSetMakerUtility.CanGenerate(t)) && // (t.building == null || t.Minifiable || ToolkitSettings.MinifiableBuildings) && // (t.BaseMarketValue > 0) // orderby t.LabelCap // select t; }
private void GetTradeables() { if (cachedTradeables.Count > 0) { Store_ItemEditor.UpdateStoreItems(cachedTradeables, tradeablesPrices); } lastSearch = searchQuery; cachedTradeables = new List <ThingDef>(); string searchShort = string.Join("", searchQuery.Split(' ')).ToLower(); Log.Warning("Search " + searchShort); 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 || string.Join("", t.FirstThingCategory.LabelCap.Split(' ')).ToLower().Contains(searchShort) || t.FirstThingCategory.LabelCap.ToLower() == searchShort) ) orderby t.LabelCap select t; Helper.Log("Found " + tradeableitems.Count() + " items"); 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(); }
public static void TryMakeAllItems() { IEnumerable <ThingDef> tradeableitems = from t in DefDatabase <ThingDef> .AllDefs where (t.tradeability.TraderCanSell() || ThingSetMakerUtility.CanGenerate(t)) && (t.building == null || t.Minifiable || ToolkitSettings.MinifiableBuildings) select t; Helper.Log("Found " + tradeableitems.Count() + " items"); foreach (ThingDef item in tradeableitems) { string label = string.Join("", item.label.Split(' ')).ToLower(); Item checkforexistingitembydefname = Item.GetItemFromDefName(item.defName); Item checkforexistingitembylabel = Item.GetItemFromAbr(label); if (checkforexistingitembydefname == null && checkforexistingitembylabel == null) { try { // item needs to be worth money, also not an animal if (item.BaseMarketValue > 0f && item.race == null) { int id = StoreInventory.items.Count(); StoreInventory.items.Add(new Item(Convert.ToInt32(item.BaseMarketValue * 10 / 6), label, item.defName)); } } catch (InvalidCastException e) { Helper.Log("Existing item exception " + e.Message); } } } }
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.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.Split(' ')).ToLower().Contains(searchShort) || t.FirstThingCategory.LabelCap.ToLower() == searchShort) ) ) ) ) orderby t.LabelCap select t; foreach (ThingDef item in tradeableitems) { if (item.BaseMarketValue > 0f) { cachedTradeables.Add(item); } } GetTradeablesPrices(); }