private static float CostToMake(ThingDef d, bool real = false) { if (d.recipeMaker == null) { return(d.BaseMarketValue); } float num = 0f; if (d.costList != null) { foreach (ThingDefCountClass current in d.costList) { float num2 = 1f; if (real) { num2 = ((!DebugOutputsEconomy.RequiresBuying(current.thingDef)) ? 0.6f : 1.4f); } num += (float)current.count * DebugOutputsEconomy.CostToMake(current.thingDef, true) * num2; } } if (d.costStuffCount > 0) { ThingDef thingDef = GenStuff.DefaultStuffFor(d); num += (float)d.costStuffCount * thingDef.BaseMarketValue; } return(num); }
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)); }
private static bool RequiresBuying(ThingDef def) { if (def.costList != null) { foreach (ThingDefCountClass current in def.costList) { if (DebugOutputsEconomy.RequiresBuying(current.thingDef)) { return(true); } } return(false); } return(!DefDatabase <ThingDef> .AllDefs.Any((ThingDef d) => d.plant != null && d.plant.harvestedThingDef == def && d.plant.Sowable)); }