Esempio n. 1
0
 public static float GetStatValueAbstract(this BuildableDef def, StatDef stat, ThingDef stuff = null)
 {
     return(stat.Worker.GetValueAbstract(def, stuff));
 }
Esempio n. 2
0
        private static string InfoTextLineFromGear(Thing gear, StatDef stat)
        {
            float f = StatOffsetFromGear(gear, stat);

            return("    " + gear.LabelCap + ": " + f.ToStringByStyle(stat.finalizeEquippedStatOffset ? stat.toStringStyle : stat.ToStringStyleUnfinalized, ToStringNumberSense.Offset));
        }
Esempio n. 3
0
        public override void Randomize()
        {
            stat = DefDatabase <StatDef> .AllDefs.Where((StatDef d) => d.scenarioRandomizable).RandomElement();

            factor = GenMath.RoundedHundredth(Rand.Range(0.1f, 3f));
        }
Esempio n. 4
0
        public virtual string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            StringBuilder stringBuilder = new StringBuilder();
            float         baseValueFor  = GetBaseValueFor(req);

            if (baseValueFor != 0f || stat.showZeroBaseValue)
            {
                stringBuilder.AppendLine("StatsReport_BaseValue".Translate() + ": " + stat.ValueToString(baseValueFor, numberSense));
            }
            Pawn pawn = req.Thing as Pawn;

            if (pawn != null)
            {
                if (pawn.skills != null)
                {
                    if (stat.skillNeedOffsets != null)
                    {
                        stringBuilder.AppendLine("StatsReport_Skills".Translate());
                        for (int i = 0; i < stat.skillNeedOffsets.Count; i++)
                        {
                            SkillNeed skillNeed = stat.skillNeedOffsets[i];
                            int       level     = pawn.skills.GetSkill(skillNeed.skill).Level;
                            float     val       = skillNeed.ValueFor(pawn);
                            stringBuilder.AppendLine((string)("    " + skillNeed.skill.LabelCap + " (") + level + "): " + val.ToStringSign() + ValueToString(val, finalized: false));
                        }
                    }
                }
                else if (stat.noSkillOffset != 0f)
                {
                    stringBuilder.AppendLine("StatsReport_Skills".Translate());
                    stringBuilder.AppendLine("    " + "default".Translate().CapitalizeFirst() + " : " + stat.noSkillOffset.ToStringSign() + ValueToString(stat.noSkillOffset, finalized: false));
                }
                if (stat.capacityOffsets != null)
                {
                    stringBuilder.AppendLine("StatsReport_Health".CanTranslate() ? "StatsReport_Health".Translate() : "StatsReport_HealthFactors".Translate());
                    foreach (PawnCapacityOffset item in stat.capacityOffsets.OrderBy((PawnCapacityOffset hfa) => hfa.capacity.listOrder))
                    {
                        string text   = item.capacity.GetLabelFor(pawn).CapitalizeFirst();
                        float  level2 = pawn.health.capacities.GetLevel(item.capacity);
                        float  offset = item.GetOffset(pawn.health.capacities.GetLevel(item.capacity));
                        string text2  = ValueToString(offset, finalized: false);
                        string text3  = Mathf.Min(level2, item.max).ToStringPercent() + ", " + "HealthOffsetScale".Translate(item.scale + "x");
                        if (item.max < 999f)
                        {
                            text3 += ", " + "HealthFactorMaxImpact".Translate(item.max.ToStringPercent());
                        }
                        stringBuilder.AppendLine("    " + text + ": " + offset.ToStringSign() + text2 + " (" + text3 + ")");
                    }
                }
                if ((int)pawn.RaceProps.intelligence >= 1)
                {
                    if (pawn.story != null && pawn.story.traits != null)
                    {
                        List <Trait> list  = pawn.story.traits.allTraits.Where((Trait tr) => tr.CurrentData.statOffsets != null && tr.CurrentData.statOffsets.Any((StatModifier se) => se.stat == stat)).ToList();
                        List <Trait> list2 = pawn.story.traits.allTraits.Where((Trait tr) => tr.CurrentData.statFactors != null && tr.CurrentData.statFactors.Any((StatModifier se) => se.stat == stat)).ToList();
                        if (list.Count > 0 || list2.Count > 0)
                        {
                            stringBuilder.AppendLine("StatsReport_RelevantTraits".Translate());
                            for (int j = 0; j < list.Count; j++)
                            {
                                Trait  trait = list[j];
                                string valueToStringAsOffset = trait.CurrentData.statOffsets.First((StatModifier se) => se.stat == stat).ValueToStringAsOffset;
                                stringBuilder.AppendLine("    " + trait.LabelCap + ": " + valueToStringAsOffset);
                            }
                            for (int k = 0; k < list2.Count; k++)
                            {
                                Trait  trait2           = list2[k];
                                string toStringAsFactor = trait2.CurrentData.statFactors.First((StatModifier se) => se.stat == stat).ToStringAsFactor;
                                stringBuilder.AppendLine("    " + trait2.LabelCap + ": " + toStringAsFactor);
                            }
                        }
                    }
                    if (RelevantGear(pawn, stat).Any())
                    {
                        stringBuilder.AppendLine("StatsReport_RelevantGear".Translate());
                        if (pawn.apparel != null)
                        {
                            for (int l = 0; l < pawn.apparel.WornApparel.Count; l++)
                            {
                                Apparel apparel = pawn.apparel.WornApparel[l];
                                if (GearAffectsStat(apparel.def, stat))
                                {
                                    stringBuilder.AppendLine(InfoTextLineFromGear(apparel, stat));
                                }
                            }
                        }
                        if (pawn.equipment != null && pawn.equipment.Primary != null && (GearAffectsStat(pawn.equipment.Primary.def, stat) || GearHasCompsThatAffectStat(pawn.equipment.Primary, stat)))
                        {
                            stringBuilder.AppendLine(InfoTextLineFromGear(pawn.equipment.Primary, stat));
                        }
                    }
                }
                bool          flag    = false;
                List <Hediff> hediffs = pawn.health.hediffSet.hediffs;
                for (int m = 0; m < hediffs.Count; m++)
                {
                    HediffStage curStage = hediffs[m].CurStage;
                    if (curStage == null)
                    {
                        continue;
                    }
                    float num = curStage.statOffsets.GetStatOffsetFromList(stat);
                    if (num != 0f)
                    {
                        float val2 = num;
                        if (curStage.statOffsetEffectMultiplier != null)
                        {
                            num *= pawn.GetStatValue(curStage.statOffsetEffectMultiplier);
                        }
                        if (!flag)
                        {
                            stringBuilder.AppendLine("StatsReport_RelevantHediffs".Translate());
                            flag = true;
                        }
                        stringBuilder.Append("    " + hediffs[m].LabelBaseCap + ": " + ValueToString(num, finalized: false, ToStringNumberSense.Offset));
                        if (curStage.statOffsetEffectMultiplier != null)
                        {
                            stringBuilder.Append(" (" + ValueToString(val2, finalized: false, ToStringNumberSense.Offset) + " x " + ValueToString(pawn.GetStatValue(curStage.statOffsetEffectMultiplier), finalized: true, curStage.statOffsetEffectMultiplier.toStringNumberSense) + " " + curStage.statOffsetEffectMultiplier.LabelCap + ")");
                        }
                        stringBuilder.AppendLine();
                    }
                    float num2 = curStage.statFactors.GetStatFactorFromList(stat);
                    if (Math.Abs(num2 - 1f) > float.Epsilon)
                    {
                        float val3 = num2;
                        if (curStage.statFactorEffectMultiplier != null)
                        {
                            num2 = ScaleFactor(num2, pawn.GetStatValue(curStage.statFactorEffectMultiplier));
                        }
                        if (!flag)
                        {
                            stringBuilder.AppendLine("StatsReport_RelevantHediffs".Translate());
                            flag = true;
                        }
                        stringBuilder.Append("    " + hediffs[m].LabelBaseCap + ": " + ValueToString(num2, finalized: false, ToStringNumberSense.Factor));
                        if (curStage.statFactorEffectMultiplier != null)
                        {
                            stringBuilder.Append(" (" + ValueToString(val3, finalized: false, ToStringNumberSense.Factor) + " x " + ValueToString(pawn.GetStatValue(curStage.statFactorEffectMultiplier), finalized: false) + " " + curStage.statFactorEffectMultiplier.LabelCap + ")");
                        }
                        stringBuilder.AppendLine();
                    }
                }
                float statFactorFromList = pawn.ageTracker.CurLifeStage.statFactors.GetStatFactorFromList(stat);
                if (statFactorFromList != 1f)
                {
                    stringBuilder.AppendLine("StatsReport_LifeStage".Translate() + " (" + pawn.ageTracker.CurLifeStage.label + "): " + statFactorFromList.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor));
                }
            }
            if (req.StuffDef != null)
            {
                if (baseValueFor > 0f || stat.applyFactorsIfNegative)
                {
                    float statFactorFromList2 = req.StuffDef.stuffProps.statFactors.GetStatFactorFromList(stat);
                    if (statFactorFromList2 != 1f)
                    {
                        stringBuilder.AppendLine("StatsReport_Material".Translate() + " (" + req.StuffDef.LabelCap + "): " + statFactorFromList2.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor));
                    }
                }
                float statOffsetFromList = req.StuffDef.stuffProps.statOffsets.GetStatOffsetFromList(stat);
                if (statOffsetFromList != 0f)
                {
                    stringBuilder.AppendLine("StatsReport_Material".Translate() + " (" + req.StuffDef.LabelCap + "): " + statOffsetFromList.ToStringByStyle(stat.toStringStyle, ToStringNumberSense.Offset));
                }
            }
            req.Thing.TryGetComp <CompAffectedByFacilities>()?.GetStatsExplanation(stat, stringBuilder);
            if (stat.statFactors != null)
            {
                stringBuilder.AppendLine("StatsReport_OtherStats".Translate());
                for (int n = 0; n < stat.statFactors.Count; n++)
                {
                    StatDef statDef = stat.statFactors[n];
                    stringBuilder.AppendLine("    " + statDef.LabelCap + ": x" + statDef.Worker.GetValue(req).ToStringPercent());
                }
            }
            if (pawn != null)
            {
                if (pawn.skills != null)
                {
                    if (stat.skillNeedFactors != null)
                    {
                        stringBuilder.AppendLine("StatsReport_Skills".Translate());
                        for (int num3 = 0; num3 < stat.skillNeedFactors.Count; num3++)
                        {
                            SkillNeed skillNeed2 = stat.skillNeedFactors[num3];
                            int       level3     = pawn.skills.GetSkill(skillNeed2.skill).Level;
                            stringBuilder.AppendLine((string)("    " + skillNeed2.skill.LabelCap + " (") + level3 + "): x" + skillNeed2.ValueFor(pawn).ToStringPercent());
                        }
                    }
                }
                else if (stat.noSkillFactor != 1f)
                {
                    stringBuilder.AppendLine("StatsReport_Skills".Translate());
                    stringBuilder.AppendLine("    " + "default".Translate().CapitalizeFirst() + " : x" + stat.noSkillFactor.ToStringPercent());
                }
                if (stat.capacityFactors != null)
                {
                    stringBuilder.AppendLine("StatsReport_Health".CanTranslate() ? "StatsReport_Health".Translate() : "StatsReport_HealthFactors".Translate());
                    if (stat.capacityFactors != null)
                    {
                        foreach (PawnCapacityFactor item2 in stat.capacityFactors.OrderBy((PawnCapacityFactor hfa) => hfa.capacity.listOrder))
                        {
                            string text4 = item2.capacity.GetLabelFor(pawn).CapitalizeFirst();
                            string text5 = item2.GetFactor(pawn.health.capacities.GetLevel(item2.capacity)).ToStringPercent();
                            string text6 = "HealthFactorPercentImpact".Translate(item2.weight.ToStringPercent());
                            if (item2.max < 999f)
                            {
                                text6 += ", " + "HealthFactorMaxImpact".Translate(item2.max.ToStringPercent());
                            }
                            if (item2.allowedDefect != 0f)
                            {
                                text6 += ", " + "HealthFactorAllowedDefect".Translate((1f - item2.allowedDefect).ToStringPercent());
                            }
                            stringBuilder.AppendLine("    " + text4 + ": x" + text5 + " (" + text6 + ")");
                        }
                    }
                }
                if (pawn.Inspired)
                {
                    float statOffsetFromList2 = pawn.InspirationDef.statOffsets.GetStatOffsetFromList(stat);
                    if (statOffsetFromList2 != 0f)
                    {
                        stringBuilder.AppendLine("StatsReport_Inspiration".Translate(pawn.Inspiration.def.LabelCap) + ": " + ValueToString(statOffsetFromList2, finalized: false, ToStringNumberSense.Offset));
                    }
                    float statFactorFromList3 = pawn.InspirationDef.statFactors.GetStatFactorFromList(stat);
                    if (statFactorFromList3 != 1f)
                    {
                        stringBuilder.AppendLine("StatsReport_Inspiration".Translate(pawn.Inspiration.def.LabelCap) + ": " + statFactorFromList3.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor));
                    }
                }
            }
            return(stringBuilder.ToString());
        }
Esempio n. 5
0
 public virtual string GetStatDrawEntryLabel(StatDef stat, float value, ToStringNumberSense numberSense, StatRequest optionalReq, bool finalized = true)
 {
     return(stat.ValueToString(value, numberSense, finalized));
 }
 public float GetStatValue(StatDef stat)
 {
     return(stat.Worker.GetValue(StatRequest.For(thing, stuff, Quality)));
 }
Esempio n. 7
0
 public static float GetStatFactorFromList(this List <StatModifier> modList, StatDef stat)
 {
     return(modList.GetStatValueFromList(stat, 1f));
 }
Esempio n. 8
0
 private static float StatOffsetFromGear(Thing gear, StatDef stat)
 {
     return(gear.def.equippedStatOffsets.GetStatOffsetFromList(stat));
 }
Esempio n. 9
0
 internal void <> m__0()
 {
     this.$this.stat = this.localSd;
 }
Esempio n. 10
0
        public virtual string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            StringBuilder stringBuilder = new StringBuilder();
            float         baseValueFor  = this.GetBaseValueFor(req.Def);

            if (baseValueFor != 0f)
            {
                stringBuilder.AppendLine("StatsReport_BaseValue".Translate() + ": " + this.stat.ValueToString(baseValueFor, numberSense));
                stringBuilder.AppendLine();
            }
            Pawn pawn = req.Thing as Pawn;

            if (pawn != null)
            {
                if (pawn.skills != null)
                {
                    if (this.stat.skillNeedOffsets != null)
                    {
                        stringBuilder.AppendLine("StatsReport_Skills".Translate());
                        for (int i = 0; i < this.stat.skillNeedOffsets.Count; i++)
                        {
                            SkillNeed skillNeed = this.stat.skillNeedOffsets[i];
                            int       level     = pawn.skills.GetSkill(skillNeed.skill).Level;
                            float     val       = skillNeed.ValueFor(pawn);
                            stringBuilder.AppendLine(string.Concat(new object[]
                            {
                                "    ",
                                skillNeed.skill.LabelCap,
                                " (",
                                level,
                                "): ",
                                val.ToStringSign(),
                                this.ValueToString(val, false, ToStringNumberSense.Absolute)
                            }));
                        }
                        stringBuilder.AppendLine();
                    }
                }
                else if (this.stat.noSkillOffset != 0f)
                {
                    stringBuilder.AppendLine("StatsReport_Skills".Translate());
                    stringBuilder.AppendLine(string.Concat(new string[]
                    {
                        "    ",
                        "default".Translate().CapitalizeFirst(),
                        " : ",
                        this.stat.noSkillOffset.ToStringSign(),
                        this.ValueToString(this.stat.noSkillOffset, false, ToStringNumberSense.Absolute)
                    }));
                    stringBuilder.AppendLine();
                }
                if (this.stat.capacityOffsets != null)
                {
                    stringBuilder.AppendLine((!"StatsReport_Health".CanTranslate()) ? "StatsReport_HealthFactors".Translate() : "StatsReport_Health".Translate());
                    foreach (PawnCapacityOffset current in from hfa in this.stat.capacityOffsets
                             orderby hfa.capacity.listOrder
                             select hfa)
                    {
                        string text   = current.capacity.GetLabelFor(pawn).CapitalizeFirst();
                        float  level2 = pawn.health.capacities.GetLevel(current.capacity);
                        float  offset = current.GetOffset(pawn.health.capacities.GetLevel(current.capacity));
                        string text2  = this.ValueToString(offset, false, ToStringNumberSense.Absolute);
                        string text3  = Mathf.Min(level2, current.max).ToStringPercent() + ", " + "HealthOffsetScale".Translate(new object[]
                        {
                            current.scale.ToString() + "x"
                        });
                        if (current.max < 999f)
                        {
                            text3 = text3 + ", " + "HealthFactorMaxImpact".Translate(new object[]
                            {
                                current.max.ToStringPercent()
                            });
                        }
                        stringBuilder.AppendLine(string.Concat(new string[]
                        {
                            "    ",
                            text,
                            ": ",
                            offset.ToStringSign(),
                            text2,
                            " (",
                            text3,
                            ")"
                        }));
                    }
                    stringBuilder.AppendLine();
                }
                if (pawn.RaceProps.intelligence >= Intelligence.ToolUser)
                {
                    if (pawn.story != null && pawn.story.traits != null)
                    {
                        List <Trait> list = (from tr in pawn.story.traits.allTraits
                                             where tr.CurrentData.statOffsets != null && tr.CurrentData.statOffsets.Any((StatModifier se) => se.stat == this.stat)
                                             select tr).ToList <Trait>();
                        List <Trait> list2 = (from tr in pawn.story.traits.allTraits
                                              where tr.CurrentData.statFactors != null && tr.CurrentData.statFactors.Any((StatModifier se) => se.stat == this.stat)
                                              select tr).ToList <Trait>();
                        if (list.Count > 0 || list2.Count > 0)
                        {
                            stringBuilder.AppendLine("StatsReport_RelevantTraits".Translate());
                            for (int j = 0; j < list.Count; j++)
                            {
                                Trait  trait = list[j];
                                string valueToStringAsOffset = trait.CurrentData.statOffsets.First((StatModifier se) => se.stat == this.stat).ValueToStringAsOffset;
                                stringBuilder.AppendLine("    " + trait.LabelCap + ": " + valueToStringAsOffset);
                            }
                            for (int k = 0; k < list2.Count; k++)
                            {
                                Trait  trait2           = list2[k];
                                string toStringAsFactor = trait2.CurrentData.statFactors.First((StatModifier se) => se.stat == this.stat).ToStringAsFactor;
                                stringBuilder.AppendLine("    " + trait2.LabelCap + ": " + toStringAsFactor);
                            }
                            stringBuilder.AppendLine();
                        }
                    }
                    if (StatWorker.RelevantGear(pawn, this.stat).Any <Thing>())
                    {
                        stringBuilder.AppendLine("StatsReport_RelevantGear".Translate());
                        if (pawn.apparel != null)
                        {
                            for (int l = 0; l < pawn.apparel.WornApparel.Count; l++)
                            {
                                Apparel gear = pawn.apparel.WornApparel[l];
                                stringBuilder.AppendLine(StatWorker.InfoTextLineFromGear(gear, this.stat));
                            }
                        }
                        if (pawn.equipment != null && pawn.equipment.Primary != null)
                        {
                            stringBuilder.AppendLine(StatWorker.InfoTextLineFromGear(pawn.equipment.Primary, this.stat));
                        }
                        stringBuilder.AppendLine();
                    }
                }
                bool          flag    = false;
                List <Hediff> hediffs = pawn.health.hediffSet.hediffs;
                for (int m = 0; m < hediffs.Count; m++)
                {
                    HediffStage curStage = hediffs[m].CurStage;
                    if (curStage != null)
                    {
                        float statOffsetFromList = curStage.statOffsets.GetStatOffsetFromList(this.stat);
                        if (statOffsetFromList != 0f)
                        {
                            if (!flag)
                            {
                                stringBuilder.AppendLine("StatsReport_RelevantHediffs".Translate());
                                flag = true;
                            }
                            stringBuilder.AppendLine("    " + hediffs[m].LabelBase.CapitalizeFirst() + ": " + this.ValueToString(statOffsetFromList, false, ToStringNumberSense.Offset));
                            stringBuilder.AppendLine();
                        }
                    }
                }
                float statFactorFromList = pawn.ageTracker.CurLifeStage.statFactors.GetStatFactorFromList(this.stat);
                if (statFactorFromList != 1f)
                {
                    stringBuilder.AppendLine(string.Concat(new string[]
                    {
                        "StatsReport_LifeStage".Translate(),
                        " (",
                        pawn.ageTracker.CurLifeStage.label,
                        "): ",
                        statFactorFromList.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor)
                    }));
                    stringBuilder.AppendLine();
                }
            }
            if (req.StuffDef != null)
            {
                if (baseValueFor > 0f || this.stat.applyFactorsIfNegative)
                {
                    float statFactorFromList2 = req.StuffDef.stuffProps.statFactors.GetStatFactorFromList(this.stat);
                    if (statFactorFromList2 != 1f)
                    {
                        stringBuilder.AppendLine(string.Concat(new string[]
                        {
                            "StatsReport_Material".Translate(),
                            " (",
                            req.StuffDef.LabelCap,
                            "): ",
                            statFactorFromList2.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor)
                        }));
                        stringBuilder.AppendLine();
                    }
                }
                float statOffsetFromList2 = req.StuffDef.stuffProps.statOffsets.GetStatOffsetFromList(this.stat);
                if (statOffsetFromList2 != 0f)
                {
                    stringBuilder.AppendLine(string.Concat(new string[]
                    {
                        "StatsReport_Material".Translate(),
                        " (",
                        req.StuffDef.LabelCap,
                        "): ",
                        statOffsetFromList2.ToStringByStyle(this.stat.toStringStyle, ToStringNumberSense.Offset)
                    }));
                    stringBuilder.AppendLine();
                }
            }
            CompAffectedByFacilities compAffectedByFacilities = req.Thing.TryGetComp <CompAffectedByFacilities>();

            if (compAffectedByFacilities != null)
            {
                compAffectedByFacilities.GetStatsExplanation(this.stat, stringBuilder);
            }
            if (this.stat.statFactors != null)
            {
                stringBuilder.AppendLine("StatsReport_OtherStats".Translate());
                for (int n = 0; n < this.stat.statFactors.Count; n++)
                {
                    StatDef statDef = this.stat.statFactors[n];
                    stringBuilder.AppendLine("    " + statDef.LabelCap + ": x" + statDef.Worker.GetValue(req, true).ToStringPercent());
                }
                stringBuilder.AppendLine();
            }
            if (pawn != null)
            {
                if (pawn.skills != null)
                {
                    if (this.stat.skillNeedFactors != null)
                    {
                        stringBuilder.AppendLine("StatsReport_Skills".Translate());
                        for (int num = 0; num < this.stat.skillNeedFactors.Count; num++)
                        {
                            SkillNeed skillNeed2 = this.stat.skillNeedFactors[num];
                            int       level3     = pawn.skills.GetSkill(skillNeed2.skill).Level;
                            stringBuilder.AppendLine(string.Concat(new object[]
                            {
                                "    ",
                                skillNeed2.skill.LabelCap,
                                " (",
                                level3,
                                "): x",
                                skillNeed2.ValueFor(pawn).ToStringPercent()
                            }));
                        }
                        stringBuilder.AppendLine();
                    }
                }
                else if (this.stat.noSkillFactor != 1f)
                {
                    stringBuilder.AppendLine("StatsReport_Skills".Translate());
                    stringBuilder.AppendLine("    " + "default".Translate().CapitalizeFirst() + " : x" + this.stat.noSkillFactor.ToStringPercent());
                    stringBuilder.AppendLine();
                }
                if (this.stat.capacityFactors != null)
                {
                    stringBuilder.AppendLine((!"StatsReport_Health".CanTranslate()) ? "StatsReport_HealthFactors".Translate() : "StatsReport_Health".Translate());
                    if (this.stat.capacityFactors != null)
                    {
                        foreach (PawnCapacityFactor current2 in from hfa in this.stat.capacityFactors
                                 orderby hfa.capacity.listOrder
                                 select hfa)
                        {
                            string text4  = current2.capacity.GetLabelFor(pawn).CapitalizeFirst();
                            float  factor = current2.GetFactor(pawn.health.capacities.GetLevel(current2.capacity));
                            string text5  = factor.ToStringPercent();
                            string text6  = "HealthFactorPercentImpact".Translate(new object[]
                            {
                                current2.weight.ToStringPercent()
                            });
                            if (current2.max < 999f)
                            {
                                text6 = text6 + ", " + "HealthFactorMaxImpact".Translate(new object[]
                                {
                                    current2.max.ToStringPercent()
                                });
                            }
                            if (current2.allowedDefect != 0f)
                            {
                                text6 = text6 + ", " + "HealthFactorAllowedDefect".Translate(new object[]
                                {
                                    (1f - current2.allowedDefect).ToStringPercent()
                                });
                            }
                            stringBuilder.AppendLine(string.Concat(new string[]
                            {
                                "    ",
                                text4,
                                ": x",
                                text5,
                                " (",
                                text6,
                                ")"
                            }));
                        }
                    }
                    stringBuilder.AppendLine();
                }
                if (pawn.Inspired)
                {
                    float statOffsetFromList3 = pawn.InspirationDef.statOffsets.GetStatOffsetFromList(this.stat);
                    if (statOffsetFromList3 != 0f)
                    {
                        stringBuilder.AppendLine("StatsReport_Inspiration".Translate(new object[]
                        {
                            pawn.Inspiration.def.LabelCap
                        }) + ": " + this.ValueToString(statOffsetFromList3, false, ToStringNumberSense.Offset));
                        stringBuilder.AppendLine();
                    }
                    float statFactorFromList3 = pawn.InspirationDef.statFactors.GetStatFactorFromList(this.stat);
                    if (statFactorFromList3 != 1f)
                    {
                        stringBuilder.AppendLine("StatsReport_Inspiration".Translate(new object[]
                        {
                            pawn.Inspiration.def.LabelCap
                        }) + ": " + statFactorFromList3.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor));
                        stringBuilder.AppendLine();
                    }
                }
            }
            return(stringBuilder.ToString().TrimEndNewlines());
        }
Esempio n. 11
0
        private static string InfoTextLineFromGear(Thing gear, StatDef stat)
        {
            float f = StatWorker.StatOffsetFromGear(gear, stat);

            return("    " + gear.LabelCap + ": " + f.ToStringByStyle(stat.toStringStyle, ToStringNumberSense.Offset));
        }
 public float GetStatValue(StatDef stat)
 {
     return(stat.Worker.GetValue(StatRequest.For(this.thing, this.stuff, this.Quality), true));
 }
Esempio n. 13
0
 public static float GetStatValueAbstract(this AbilityDef def, StatDef stat)
 {
     return(stat.Worker.GetValueAbstract(def));
 }
Esempio n. 14
0
 public static float GetStatOffsetFromList(this List <StatModifier> modList, StatDef stat)
 {
     return(modList.GetStatValueFromList(stat, 0f));
 }
Esempio n. 15
0
 public static void SetStatBaseValue(this BuildableDef def, StatDef stat, float newBaseValue)
 {
     StatUtility.SetStatValueInList(ref def.statBases, stat, newBaseValue);
 }
Esempio n. 16
0
 private static bool <Randomize> m__0(StatDef d)
 {
     return(d.scenarioRandomizable);
 }
Esempio n. 17
0
 public static float GetStatValue(this Thing thing, StatDef stat, bool applyPostProcess = true)
 {
     return(stat.Worker.GetValue(thing, applyPostProcess));
 }
Esempio n. 18
0
 public void InitSetStat(StatDef newStat)
 {
     stat = newStat;
 }
Esempio n. 19
0
 public override string GetStatDrawEntryLabel(StatDef stat, float value, ToStringNumberSense numberSense, StatRequest optionalReq)
 {
     return(string.Format("{0} ( {1} x {2} / {3} )", value.ToStringByStyle(stat.toStringStyle, numberSense), GetMeleeDamage(optionalReq).ToString("0.##"), StatDefOf.MeleeHitChance.ValueToString(GetMeleeHitChance(optionalReq)), GetMeleeCooldown(optionalReq).ToString("0.##")));
 }
 public static void TryGiveMentalStateWithDuration(MentalStateDef def, Pawn p, AbilityDef ability, StatDef multiplierStat)
 {
     if (p.mindState.mentalStateHandler.TryStartMentalState(def, null, forceWake: true))
     {
         float num = ability.statBases.GetStatValueFromList(StatDefOf.Ability_Duration, 10f);
         if (multiplierStat != null)
         {
             num *= p.GetStatValue(multiplierStat);
         }
         p.mindState.mentalStateHandler.CurState.forceRecoverAfterTicks = num.SecondsToTicks();
     }
 }