public static string CostListString(BuildableDef d, bool divideByVolume, bool starIfOnlyBuyable) { if (!DebugOutputsEconomy.Producible(d)) { return(string.Empty); } List <string> list = new List <string>(); if (d.costList != null) { foreach (ThingDefCountClass current in d.costList) { float num = (float)current.count; if (divideByVolume) { num /= current.thingDef.VolumePerUnit; } string text = current.thingDef + " x" + num; if (starIfOnlyBuyable && DebugOutputsEconomy.RequiresBuying(current.thingDef)) { text += "*"; } list.Add(text); } } if (d.MadeFromStuff) { list.Add("stuff x" + d.costStuffCount); } return(list.ToCommaList(false)); }
public static void ItemAndBuildingAcquisition() { Func <ThingDef, string> recipes = delegate(ThingDef d) { List <string> list = new List <string>(); foreach (RecipeDef current in DefDatabase <RecipeDef> .AllDefs) { if (!current.products.NullOrEmpty <ThingDefCountClass>()) { for (int i = 0; i < current.products.Count; i++) { if (current.products[i].thingDef == d) { list.Add(current.defName); } } } } if (list.Count == 0) { return(string.Empty); } return(list.ToCommaList(false)); }; Func <ThingDef, string> workAmountSources = delegate(ThingDef d) { List <string> list = new List <string>(); if (d.StatBaseDefined(StatDefOf.WorkToMake)) { list.Add("WorkToMake(" + d.GetStatValueAbstract(StatDefOf.WorkToMake, null) + ")"); } if (d.StatBaseDefined(StatDefOf.WorkToBuild)) { list.Add("WorkToBuild(" + d.GetStatValueAbstract(StatDefOf.WorkToBuild, null) + ")"); } foreach (RecipeDef current in DefDatabase <RecipeDef> .AllDefs) { if (current.workAmount > 0f && !current.products.NullOrEmpty <ThingDefCountClass>()) { for (int i = 0; i < current.products.Count; i++) { if (current.products[i].thingDef == d) { list.Add(string.Concat(new object[] { "RecipeDef-", current.defName, "(", current.workAmount, ")" })); } } } } if (list.Count == 0) { return(string.Empty); } return(list.ToCommaList(false)); }; Func <ThingDef, string> calculatedMarketValue = delegate(ThingDef d) { if (!DebugOutputsEconomy.Producible(d)) { return("not producible"); } if (!d.StatBaseDefined(StatDefOf.MarketValue)) { return("used"); } string text = StatWorker_MarketValue.CalculatedBaseMarketValue(d, null).ToString("F1"); if (StatWorker_MarketValue.CalculableRecipe(d) != null) { return(text + " (recipe)"); } return(text); }; IEnumerable <ThingDef> arg_333_0 = from d in DefDatabase <ThingDef> .AllDefs where (d.category == ThingCategory.Item && d.BaseMarketValue > 0.01f) || (d.category == ThingCategory.Building && (d.BuildableByPlayer || d.Minifiable)) orderby d.BaseMarketValue select d; TableDataGetter <ThingDef>[] expr_BF = new TableDataGetter <ThingDef> [16]; expr_BF[0] = new TableDataGetter <ThingDef>("cat.", (ThingDef d) => d.category.ToString().Substring(0, 1).CapitalizeFirst()); expr_BF[1] = new TableDataGetter <ThingDef>("defName", (ThingDef d) => d.defName); expr_BF[2] = new TableDataGetter <ThingDef>("mobile", (ThingDef d) => (d.category == ThingCategory.Item || d.Minifiable).ToStringCheckBlank()); expr_BF[3] = new TableDataGetter <ThingDef>("base\nmarket value", (ThingDef d) => d.BaseMarketValue.ToString("F1")); expr_BF[4] = new TableDataGetter <ThingDef>("calculated\nmarket value", (ThingDef d) => calculatedMarketValue(d)); expr_BF[5] = new TableDataGetter <ThingDef>("cost to make", (ThingDef d) => DebugOutputsEconomy.CostToMakeString(d, false)); expr_BF[6] = new TableDataGetter <ThingDef>("work to produce", (ThingDef d) => (DebugOutputsEconomy.WorkToProduceBest(d) <= 0f) ? "-" : DebugOutputsEconomy.WorkToProduceBest(d).ToString("F1")); expr_BF[7] = new TableDataGetter <ThingDef>("profit", (ThingDef d) => (d.BaseMarketValue - DebugOutputsEconomy.CostToMake(d, false)).ToString("F1")); expr_BF[8] = new TableDataGetter <ThingDef>("profit\nrate", (ThingDef d) => (d.recipeMaker == null) ? "-" : ((d.BaseMarketValue - DebugOutputsEconomy.CostToMake(d, false)) / DebugOutputsEconomy.WorkToProduceBest(d) * 10000f).ToString("F0")); expr_BF[9] = new TableDataGetter <ThingDef>("market value\ndefined", (ThingDef d) => d.statBases.Any((StatModifier st) => st.stat == StatDefOf.MarketValue).ToStringCheckBlank()); expr_BF[10] = new TableDataGetter <ThingDef>("producible", (ThingDef d) => DebugOutputsEconomy.Producible(d).ToStringCheckBlank()); expr_BF[11] = new TableDataGetter <ThingDef>("thing set\nmaker tags", (ThingDef d) => (!d.thingSetMakerTags.NullOrEmpty <string>()) ? d.thingSetMakerTags.ToCommaList(false) : string.Empty); expr_BF[12] = new TableDataGetter <ThingDef>("made\nfrom\nstuff", (ThingDef d) => d.MadeFromStuff.ToStringCheckBlank()); expr_BF[13] = new TableDataGetter <ThingDef>("cost list", (ThingDef d) => DebugOutputsEconomy.CostListString(d, false, false)); expr_BF[14] = new TableDataGetter <ThingDef>("recipes", (ThingDef d) => recipes(d)); expr_BF[15] = new TableDataGetter <ThingDef>("work amount\nsources", (ThingDef d) => workAmountSources(d)); DebugTables.MakeTablesDialog <ThingDef>(arg_333_0, expr_BF); }