コード例 #1
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);
        }
コード例 #2
0
 private static string CostToMakeString(ThingDef d, bool real = false)
 {
     if (d.recipeMaker == null)
     {
         return("-");
     }
     return(DebugOutputsEconomy.CostToMake(d, real).ToString("F1"));
 }
コード例 #3
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);
        }
コード例 #4
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);
        }