Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
 private static string CostToMakeString(ThingDef d, bool real = false)
 {
     if (d.recipeMaker == null)
     {
         return("-");
     }
     return(DebugOutputsEconomy.CostToMake(d, real).ToString("F1"));
 }
Пример #4
0
        private static float CheapestProductsValue(RecipeDef d)
        {
            float num = 0f;

            foreach (ThingDefCountClass current in d.products)
            {
                num += current.thingDef.GetStatValueAbstract(StatDefOf.MarketValue, DebugOutputsEconomy.CheapestNonDerpStuff(d)) * (float)current.count;
            }
            return(num);
        }
Пример #5
0
        private static float CheapestIngredientValue(RecipeDef d)
        {
            float num = 0f;

            foreach (Pair <ThingDef, float> current in DebugOutputsEconomy.CheapestIngredients(d))
            {
                num += current.First.BaseMarketValue * current.Second;
            }
            return(num);
        }
Пример #6
0
 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));
 }
Пример #7
0
        public static void Drugs()
        {
            Func <ThingDef, float> realIngredientCost = (ThingDef d) => DebugOutputsEconomy.CostToMake(d, true);
            Func <ThingDef, float> realSellPrice      = (ThingDef d) => d.BaseMarketValue * 0.6f;
            Func <ThingDef, float> realBuyPrice       = (ThingDef d) => d.BaseMarketValue * 1.4f;
            IEnumerable <ThingDef> arg_197_0          = from d in DefDatabase <ThingDef> .AllDefs
                                                        where d.IsWithinCategory(ThingCategoryDefOf.Medicine) || d.IsWithinCategory(ThingCategoryDefOf.Drugs)
                                                        select d;

            TableDataGetter <ThingDef>[] expr_9C = new TableDataGetter <ThingDef> [8];
            expr_9C[0] = new TableDataGetter <ThingDef>("name", (ThingDef d) => d.defName);
            expr_9C[1] = new TableDataGetter <ThingDef>("ingredients", (ThingDef d) => DebugOutputsEconomy.CostListString(d, true, true));
            expr_9C[2] = new TableDataGetter <ThingDef>("work amount", (ThingDef d) => DebugOutputsEconomy.WorkToProduceBest(d).ToString("F0"));
            expr_9C[3] = new TableDataGetter <ThingDef>("real ingredient cost", (ThingDef d) => realIngredientCost(d).ToString("F1"));
            expr_9C[4] = new TableDataGetter <ThingDef>("real sell price", (ThingDef d) => realSellPrice(d).ToString("F1"));
            expr_9C[5] = new TableDataGetter <ThingDef>("real profit per item", (ThingDef d) => (realSellPrice(d) - realIngredientCost(d)).ToString("F1"));
            expr_9C[6] = new TableDataGetter <ThingDef>("real profit per day's work", (ThingDef d) => ((realSellPrice(d) - realIngredientCost(d)) / DebugOutputsEconomy.WorkToProduceBest(d) * 30000f).ToString("F1"));
            expr_9C[7] = new TableDataGetter <ThingDef>("real buy price", (ThingDef d) => realBuyPrice(d).ToString("F1"));
            DebugTables.MakeTablesDialog <ThingDef>(arg_197_0, expr_9C);
        }
Пример #8
0
 public static void Terrains()
 {
     DebugTables.MakeTablesDialog(DefDatabase <TerrainDef> .AllDefs, new TableDataGetter <TerrainDef>("defName", (TerrainDef d) => d.defName), new TableDataGetter <TerrainDef>("work", (TerrainDef d) => d.GetStatValueAbstract(StatDefOf.WorkToBuild).ToString()), new TableDataGetter <TerrainDef>("beauty", (TerrainDef d) => d.GetStatValueAbstract(StatDefOf.Beauty).ToString()), new TableDataGetter <TerrainDef>("cleanliness", (TerrainDef d) => d.GetStatValueAbstract(StatDefOf.Cleanliness).ToString()), new TableDataGetter <TerrainDef>("path\ncost", (TerrainDef d) => d.pathCost.ToString()), new TableDataGetter <TerrainDef>("fertility", (TerrainDef d) => d.fertility.ToStringPercentEmptyZero()), new TableDataGetter <TerrainDef>("acceptance\nmask", (TerrainDef d) => string.Join(",", (from e in d.filthAcceptanceMask.GetAllSelectedItems <FilthSourceFlags>()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                select e.ToString()).ToArray())), new TableDataGetter <TerrainDef>("generated\nfilth", (TerrainDef d) => (d.generatedFilth == null) ? "" : d.generatedFilth.defName), new TableDataGetter <TerrainDef>("hold\nsnow", (TerrainDef d) => d.holdSnow.ToStringCheckBlank()), new TableDataGetter <TerrainDef>("take\nfootprints", (TerrainDef d) => d.takeFootprints.ToStringCheckBlank()), new TableDataGetter <TerrainDef>("avoid\nwander", (TerrainDef d) => d.avoidWander.ToStringCheckBlank()), new TableDataGetter <TerrainDef>("buildable", (TerrainDef d) => d.BuildableByPlayer.ToStringCheckBlank()), new TableDataGetter <TerrainDef>("cost\nlist", (TerrainDef d) => DebugOutputsEconomy.CostListString(d, divideByVolume: false, starIfOnlyBuyable: false)), new TableDataGetter <TerrainDef>("research", (TerrainDef d) => (d.researchPrerequisites == null) ? "" : d.researchPrerequisites.Select((ResearchProjectDef pr) => pr.defName).ToCommaList()), new TableDataGetter <TerrainDef>("affordances", (TerrainDef d) => d.affordances.Select((TerrainAffordanceDef af) => af.defName).ToCommaList()));
 }
Пример #9
0
 private static float WorkValueEstimate(RecipeDef d)
 {
     return(DebugOutputsEconomy.TrueWorkWithCarryTime(d) * 0.01f);
 }
Пример #10
0
        private static float TrueWorkWithCarryTime(RecipeDef d)
        {
            ThingDef stuffDef = DebugOutputsEconomy.CheapestNonDerpStuff(d);

            return((float)d.ingredients.Count * 90f + d.WorkAmountTotal(stuffDef) + 90f);
        }
Пример #11
0
        public static void Recipes()
        {
            IEnumerable <RecipeDef> arg_229_0 = from d in DefDatabase <RecipeDef> .AllDefs
                                                where !d.products.NullOrEmpty <ThingDefCountClass>() && !d.ingredients.NullOrEmpty <IngredientCount>()
                                                select d;

            TableDataGetter <RecipeDef>[] expr_2E = new TableDataGetter <RecipeDef> [12];
            expr_2E[0]  = new TableDataGetter <RecipeDef>("defName", (RecipeDef d) => d.defName);
            expr_2E[1]  = new TableDataGetter <RecipeDef>("work /w carry", (RecipeDef d) => DebugOutputsEconomy.TrueWorkWithCarryTime(d).ToString("F0"));
            expr_2E[2]  = new TableDataGetter <RecipeDef>("work seconds", (RecipeDef d) => (DebugOutputsEconomy.TrueWorkWithCarryTime(d) / 60f).ToString("F0"));
            expr_2E[3]  = new TableDataGetter <RecipeDef>("cheapest products value", (RecipeDef d) => DebugOutputsEconomy.CheapestProductsValue(d).ToString("F1"));
            expr_2E[4]  = new TableDataGetter <RecipeDef>("cheapest ingredients value", (RecipeDef d) => DebugOutputsEconomy.CheapestIngredientValue(d).ToString("F1"));
            expr_2E[5]  = new TableDataGetter <RecipeDef>("work value", (RecipeDef d) => DebugOutputsEconomy.WorkValueEstimate(d).ToString("F1"));
            expr_2E[6]  = new TableDataGetter <RecipeDef>("profit raw", (RecipeDef d) => (DebugOutputsEconomy.CheapestProductsValue(d) - DebugOutputsEconomy.CheapestIngredientValue(d)).ToString("F1"));
            expr_2E[7]  = new TableDataGetter <RecipeDef>("profit with work", (RecipeDef d) => (DebugOutputsEconomy.CheapestProductsValue(d) - DebugOutputsEconomy.WorkValueEstimate(d) - DebugOutputsEconomy.CheapestIngredientValue(d)).ToString("F1"));
            expr_2E[8]  = new TableDataGetter <RecipeDef>("profit per work day", (RecipeDef d) => ((DebugOutputsEconomy.CheapestProductsValue(d) - DebugOutputsEconomy.CheapestIngredientValue(d)) * 60000f / DebugOutputsEconomy.TrueWorkWithCarryTime(d)).ToString("F0"));
            expr_2E[9]  = new TableDataGetter <RecipeDef>("min skill", (RecipeDef d) => (!d.skillRequirements.NullOrEmpty <SkillRequirement>()) ? d.skillRequirements[0].Summary : string.Empty);
            expr_2E[10] = new TableDataGetter <RecipeDef>("cheapest stuff", (RecipeDef d) => (DebugOutputsEconomy.CheapestNonDerpStuff(d) == null) ? string.Empty : DebugOutputsEconomy.CheapestNonDerpStuff(d).defName);
            expr_2E[11] = new TableDataGetter <RecipeDef>("cheapest ingredients", (RecipeDef d) => (from pa in DebugOutputsEconomy.CheapestIngredients(d)
                                                                                                    select pa.First.defName + " x" + pa.Second).ToCommaList(false));
            DebugTables.MakeTablesDialog <RecipeDef>(arg_229_0, expr_2E);
        }
Пример #12
0
        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);
        }
Пример #13
0
        public static void AnimalBreeding()
        {
            IEnumerable <ThingDef> arg_14B_0 = (from d in DefDatabase <ThingDef> .AllDefs
                                                where d.category == ThingCategory.Pawn && d.race.IsFlesh
                                                select d).OrderByDescending(new Func <ThingDef, float>(DebugOutputsEconomy.GestationDaysEach));

            TableDataGetter <ThingDef>[] expr_4F = new TableDataGetter <ThingDef> [6];
            expr_4F[0] = new TableDataGetter <ThingDef>(string.Empty, (ThingDef d) => d.defName);
            expr_4F[1] = new TableDataGetter <ThingDef>("gestDaysEach", (ThingDef d) => DebugOutputsEconomy.GestationDaysEach(d).ToString("F2"));
            expr_4F[2] = new TableDataGetter <ThingDef>("avgOffspring", (ThingDef d) => (!d.HasComp(typeof(CompEggLayer))) ? ((d.race.litterSizeCurve == null) ? 1f : Rand.ByCurveAverage(d.race.litterSizeCurve)).ToString("F2") : d.GetCompProperties <CompProperties_EggLayer>().eggCountRange.Average.ToString("F2"));
            expr_4F[3] = new TableDataGetter <ThingDef>("gestDaysRaw", (ThingDef d) => (!d.HasComp(typeof(CompEggLayer))) ? d.race.gestationPeriodDays.ToString("F1") : d.GetCompProperties <CompProperties_EggLayer>().eggLayIntervalDays.ToString("F1"));
            expr_4F[4] = new TableDataGetter <ThingDef>("growth per 30d", delegate(ThingDef d)
            {
                float f    = 1f + ((!d.HasComp(typeof(CompEggLayer))) ? ((d.race.litterSizeCurve == null) ? 1f : Rand.ByCurveAverage(d.race.litterSizeCurve)) : d.GetCompProperties <CompProperties_EggLayer>().eggCountRange.Average);
                float num  = d.race.lifeStageAges[d.race.lifeStageAges.Count - 1].minAge * 60f;
                float num2 = num + ((!d.HasComp(typeof(CompEggLayer))) ? d.race.gestationPeriodDays : d.GetCompProperties <CompProperties_EggLayer>().eggLayIntervalDays);
                float p    = 30f / num2;
                return(Mathf.Pow(f, p).ToString("F2"));
            });
            expr_4F[5] = new TableDataGetter <ThingDef>("growth per 60d", delegate(ThingDef d)
            {
                float f    = 1f + ((!d.HasComp(typeof(CompEggLayer))) ? ((d.race.litterSizeCurve == null) ? 1f : Rand.ByCurveAverage(d.race.litterSizeCurve)) : d.GetCompProperties <CompProperties_EggLayer>().eggCountRange.Average);
                float num  = d.race.lifeStageAges[d.race.lifeStageAges.Count - 1].minAge * 60f;
                float num2 = num + ((!d.HasComp(typeof(CompEggLayer))) ? d.race.gestationPeriodDays : d.GetCompProperties <CompProperties_EggLayer>().eggLayIntervalDays);
                float p    = 60f / num2;
                return(Mathf.Pow(f, p).ToString("F2"));
            });
            DebugTables.MakeTablesDialog <ThingDef>(arg_14B_0, expr_4F);
        }