Ejemplo n.º 1
0
        public static float CalculatedMarketValue(BuildableDef def, ThingDef stuffDef)
        {
            float     num       = 0f;
            RecipeDef recipeDef = StatWorker_MarketValue.CalculableRecipe(def);
            float     num2;
            int       num3;

            if (recipeDef != null)
            {
                num2 = recipeDef.workAmount;
                num3 = recipeDef.products[0].count;
                if (recipeDef.ingredients != null)
                {
                    for (int i = 0; i < recipeDef.ingredients.Count; i++)
                    {
                        IngredientCount ingredientCount = recipeDef.ingredients[i];
                        int             num4            = ingredientCount.CountRequiredOfFor(ingredientCount.FixedIngredient, recipeDef);
                        num += (float)num4 * ingredientCount.FixedIngredient.BaseMarketValue;
                    }
                }
            }
            else
            {
                num2 = Mathf.Max(def.GetStatValueAbstract(StatDefOf.WorkToMake, stuffDef), def.GetStatValueAbstract(StatDefOf.WorkToBuild, stuffDef));
                num3 = 1;
                if (def.costList != null)
                {
                    for (int j = 0; j < def.costList.Count; j++)
                    {
                        ThingDefCountClass thingDefCountClass = def.costList[j];
                        num += (float)thingDefCountClass.count * thingDefCountClass.thingDef.BaseMarketValue;
                    }
                }
                if (def.costStuffCount > 0)
                {
                    if (stuffDef != null)
                    {
                        num += (float)def.costStuffCount / stuffDef.VolumePerUnit * stuffDef.GetStatValueAbstract(StatDefOf.MarketValue, null);
                    }
                    else
                    {
                        num += (float)def.costStuffCount * 2f;
                    }
                }
            }
            if (num2 > 2f)
            {
                num += num2 * 0.0036f;
            }
            return(num / (float)num3);
        }
Ejemplo n.º 2
0
        public override float GetValueUnfinalized(StatRequest req, bool applyPostProcess = true)
        {
            float result;

            if (req.HasThing && req.Thing is Pawn)
            {
                result = base.GetValueUnfinalized(StatRequest.For(req.Def, req.StuffDef, QualityCategory.Normal), applyPostProcess) * PriceUtility.PawnQualityPriceFactor((Pawn)req.Thing);
            }
            else if (req.Def.statBases.StatListContains(StatDefOf.MarketValue))
            {
                result = base.GetValueUnfinalized(req, true);
            }
            else
            {
                result = StatWorker_MarketValue.CalculatedMarketValue(req.Def, req.StuffDef);
            }
            return(result);
        }
 public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
 {
     if (req.HasThing && req.Thing is Pawn)
     {
         Pawn          pawn          = (Pawn)req.Thing;
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.Append(base.GetExplanationUnfinalized(req, numberSense));
         stringBuilder.AppendLine();
         PriceUtility.PawnQualityPriceFactor(pawn, stringBuilder);
         PriceUtility.PawnQualityPriceOffset(pawn, stringBuilder);
         return(stringBuilder.ToString());
     }
     if (req.Def.statBases.StatListContains(StatDefOf.MarketValue))
     {
         return(base.GetExplanationUnfinalized(req, numberSense));
     }
     return("StatsReport_MarketValueFromStuffsAndWork".Translate().TrimEnd(new char[]
     {
         '.'
     }) + ": " + StatWorker_MarketValue.CalculatedBaseMarketValue(req.Def, req.StuffDef).ToStringByStyle(this.stat.ToStringStyleUnfinalized, numberSense));
 }