private float ValueFromReq(StatRequest req)
        {
            float wildness = ((ThingDef)req.Def).race.wildness;

            return(Mathf.Clamp(GenMath.LerpDouble(0.15f, 1f, 0f, 10f, wildness), 0f, 20f));
        }
Пример #2
0
        private bool IsWildMan(StatRequest req)
        {
            Pawn pawn = req.Thing as Pawn;

            return(pawn != null && pawn.IsWildMan());
        }
Пример #3
0
 public float GetValue(Thing thing, bool applyPostProcess = true)
 {
     return(this.GetValue(StatRequest.For(thing), true));
 }
Пример #4
0
 public override void TransformValue(StatRequest req, ref float val)
 {
     val *= OutdoorsFactor(req);
 }
Пример #5
0
        // Token: 0x06003966 RID: 14694 RVA: 0x001B4210 File Offset: 0x001B2610
        public override float GetValueUnfinalized(StatRequest req, bool applyPostProcess = true)
        {
            ThingDef thingDef = req.Def as ThingDef;

            if (thingDef == null)
            {
                return(0f);
            }
            if (thingDef.race == null)
            {
                return(0f);
            }
            if (req.Thing != null)
            {
                p             = (Pawn)req.Thing;
                intelligence  = p.RaceProps.intelligence;
                meleepower    = 0;
                meleecooldown = 0;

                p.def.tools.ForEach(x => meleepower    += x.power);
                p.def.tools.ForEach(x => meleecooldown += x.cooldownTime);
                MeleeDPS          = meleepower / meleecooldown;
                meleeDamageFactor = p.ageTracker.CurLifeStage.meleeDamageFactor;
                baseHealthScale   = p.def.race.baseHealthScale;
                healthScaleFactor = p.ageTracker.CurLifeStage.healthScaleFactor;
                baseBodySize      = p.def.race.baseBodySize;
                bodySizeFactor    = p.ageTracker.CurLifeStage.bodySizeFactor;
                ArmorRating_Blunt = TryDrawOverallArmor(p, StatDefOf.ArmorRating_Blunt);
                ArmorRating_Sharp = TryDrawOverallArmor(p, StatDefOf.ArmorRating_Sharp);
                ArmorRating_Heat  = TryDrawOverallArmor(p, StatDefOf.ArmorRating_Heat);
                MeleeHitChance    = p.def.GetStatValueAbstract(StatDefOf.MeleeHitChance);
                MeleeDodgeChance  = p.def.GetStatValueAbstract(StatDefOf.MeleeDodgeChance);
                Humanlike         = p.RaceProps.Humanlike;
                Predator          = p.RaceProps.predator;
                factionLeader     = p.kindDef.factionLeader;
            }
            else
            {
                intelligence = thingDef.race.intelligence;
                if (!thingDef.tools.NullOrEmpty())
                {
                    thingDef.tools.ForEach(x => meleepower    += x.power);
                    thingDef.tools.ForEach(x => meleecooldown += x.cooldownTime);
                    MeleeDPS          = meleepower / meleecooldown;
                    meleeDamageFactor = 1f;
                }
                else
                {
                    MeleeDPS          = 0;
                    meleeDamageFactor = 0;
                }
                try
                {
                    baseHealthScale   = thingDef.race.baseHealthScale;
                    healthScaleFactor = 1f;
                }
                catch (Exception)
                {
                    //    Log.Message(string.Format("health"));
                }
                try
                {
                    baseBodySize   = thingDef.race.baseBodySize;
                    bodySizeFactor = 1f;
                }
                catch (Exception)
                {
                    //    Log.Message(string.Format("size"));
                }
                try
                {
                    ArmorRating_Blunt = thingDef.GetStatValueAbstract(StatDefOf.ArmorRating_Blunt);
                    ArmorRating_Sharp = thingDef.GetStatValueAbstract(StatDefOf.ArmorRating_Sharp);
                    ArmorRating_Heat  = thingDef.GetStatValueAbstract(StatDefOf.ArmorRating_Heat);
                }
                catch (Exception)
                {
                    //    Log.Message(string.Format("armour"));
                }
                try
                {
                    MeleeHitChance   = thingDef.GetStatValueAbstract(StatDefOf.MeleeHitChance);
                    MeleeDodgeChance = thingDef.GetStatValueAbstract(StatDefOf.MeleeDodgeChance);
                }
                catch (Exception)
                {
                    //    Log.Message(string.Format("melee chances"));
                }
                try
                {
                    Humanlike = thingDef.race.Humanlike;
                }
                catch (Exception)
                {
                    //    Log.Message(string.Format("Humanlike"));
                }
                try
                {
                    Predator = thingDef.race.predator;
                }
                catch (Exception)
                {
                    //    Log.Message(string.Format("predator"));
                }
            }
            num = 1f;
            if (Humanlike)
            {
                num += 0.5f;
            }
            if (Predator)
            {
                num += 0.75f;
            }
            if (factionLeader)
            {
                num += 1f;
            }
            num        += (float)intelligence;
            basescore   = num;
            meleescore  = (MeleeDPS * meleeDamageFactor) * (1 * (MeleeHitChance + MeleeDodgeChance));
            healthscore = (baseHealthScale * healthScaleFactor);
            sizescore   = (baseBodySize * bodySizeFactor);
            armourscore = (ArmorRating_Blunt + ArmorRating_Sharp + ArmorRating_Heat) / 3;
            num         = meleescore + ((basescore) + ((healthscore + sizescore) * (1 + armourscore)));
            // num *= (((MeleeDPS * meleeDamageFactor) * ((baseHealthScale * healthScaleFactor) + (baseBodySize * bodySizeFactor))) * (1 * ((ArmorRating_Blunt + ArmorRating_Sharp + ArmorRating_Heat) + (MeleeHitChance + MeleeDodgeChance))));

            //    Log.Message(string.Format("markscore for thing"));
            return(num);
        }
Пример #6
0
        public override bool ShouldShowFor(StatRequest req)
        {
            ThingDef thingDef = req.Def as ThingDef;

            return(thingDef != null && thingDef.IsWeapon && !thingDef.tools.NullOrEmpty <Tool>());
        }
Пример #7
0
 public override string ExplanationPart(StatRequest req)
 {
     return("StatsReport_DifficultyMultiplier".Translate() + ": x" + this.Multiplier(Find.Storyteller.difficulty).ToStringPercent());
 }
Пример #8
0
 public static void DrawStatsReport(Rect rect, Def def, ThingDef stuff)
 {
     if (cachedDrawEntries.NullOrEmpty())
     {
         BuildableDef buildableDef = def as BuildableDef;
         StatRequest  req          = (buildableDef == null) ? StatRequest.ForEmpty() : StatRequest.For(buildableDef, stuff);
         cachedDrawEntries.AddRange(def.SpecialDisplayStats(req));
         cachedDrawEntries.AddRange(from r in StatsToDraw(def, stuff)
                                    where r.ShouldDisplay
                                    select r);
         FinalizeCachedDrawEntries(cachedDrawEntries);
     }
     DrawStatsWorker(rect, null, null);
 }
Пример #9
0
 public override string ExplanationPart(StatRequest req)
 {
     return("StatsReport_DifficultyMultiplier".Translate(Find.Storyteller.difficulty.label) + ": " + Find.Storyteller.difficultyValues.butcherYieldFactor.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor));
 }
Пример #10
0
        private static IEnumerable <StatDrawEntry> StatsToDraw(Thing thing)
        {
            yield return(StatsReportUtility.DescriptionEntry(thing));

            StatDrawEntry qe = StatsReportUtility.QualityEntry(thing);

            if (qe != null)
            {
                yield return(qe);
            }
            foreach (StatDef stat in from st in DefDatabase <StatDef> .AllDefs
                     where st.Worker.ShouldShowFor(thing.def)
                     select st)
            {
                if (!stat.Worker.IsDisabledFor(thing))
                {
                    yield return(new StatDrawEntry(stat.category, stat, thing.GetStatValue(stat, true), StatRequest.For(thing), ToStringNumberSense.Undefined));
                }
                yield return(new StatDrawEntry(stat.category, stat));
            }
            if (thing.def.useHitPoints)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsNonPawn, "HitPointsBasic".Translate().CapitalizeFirst(), thing.HitPoints.ToString() + " / " + thing.MaxHitPoints.ToString(), 0, string.Empty)
                {
                    overrideReportText = string.Concat(new string[]
                    {
                        "HitPointsBasic".Translate().CapitalizeFirst(),
                        ":\n\n",
                        thing.HitPoints.ToString(),
                        "\n\n",
                        StatDefOf.MaxHitPoints.LabelCap,
                        ":\n\n",
                        StatDefOf.MaxHitPoints.Worker.GetExplanationUnfinalized(StatRequest.For(thing), ToStringNumberSense.Absolute)
                    })
                });
            }
            foreach (StatDrawEntry stat2 in thing.SpecialDisplayStats)
            {
                yield return(stat2);
            }
            if (!thing.def.equippedStatOffsets.NullOrEmpty <StatModifier>())
            {
                for (int i = 0; i < thing.def.equippedStatOffsets.Count; i++)
                {
                    yield return(new StatDrawEntry(StatCategoryDefOf.EquippedStatOffsets, thing.def.equippedStatOffsets[i].stat, thing.def.equippedStatOffsets[i].value, StatRequest.ForEmpty(), ToStringNumberSense.Offset));
                }
            }
            if (thing.def.IsStuff)
            {
                if (!thing.def.stuffProps.statFactors.NullOrEmpty <StatModifier>())
                {
                    for (int j = 0; j < thing.def.stuffProps.statFactors.Count; j++)
                    {
                        yield return(new StatDrawEntry(StatCategoryDefOf.StuffStatFactors, thing.def.stuffProps.statFactors[j].stat, thing.def.stuffProps.statFactors[j].value, StatRequest.ForEmpty(), ToStringNumberSense.Factor));
                    }
                }
                if (!thing.def.stuffProps.statOffsets.NullOrEmpty <StatModifier>())
                {
                    for (int k = 0; k < thing.def.stuffProps.statOffsets.Count; k++)
                    {
                        yield return(new StatDrawEntry(StatCategoryDefOf.StuffStatOffsets, thing.def.stuffProps.statOffsets[k].stat, thing.def.stuffProps.statOffsets[k].value, StatRequest.ForEmpty(), ToStringNumberSense.Offset));
                    }
                }
            }
        }
Пример #11
0
        private static void DrawStatsWorker(Rect rect, Thing optionalThing, WorldObject optionalWorldObject)
        {
            Rect rect2 = new Rect(rect);

            rect2.width *= 0.5f;
            Rect rect3 = new Rect(rect);

            rect3.x     = rect2.xMax;
            rect3.width = rect.xMax - rect3.x;
            Text.Font   = GameFont.Small;
            Rect viewRect = new Rect(0f, 0f, rect2.width - 16f, listHeight);

            Widgets.BeginScrollView(rect2, ref scrollPosition, viewRect);
            float  curY = 0f;
            string b    = null;

            mousedOverEntry = null;
            for (int i = 0; i < cachedDrawEntries.Count; i++)
            {
                StatDrawEntry ent = cachedDrawEntries[i];
                if (ent.category.LabelCap != b)
                {
                    Widgets.ListSeparator(ref curY, viewRect.width, ent.category.LabelCap);
                    b = ent.category.LabelCap;
                }
                curY += ent.Draw(8f, curY, viewRect.width - 8f, selectedEntry == ent, delegate
                {
                    SelectEntry(ent);
                }, delegate
                {
                    mousedOverEntry = ent;
                }, scrollPosition, rect2);
            }
            listHeight = curY + 100f;
            Widgets.EndScrollView();
            Rect rect4 = rect3.ContractedBy(10f);

            GUI.BeginGroup(rect4);
            StatDrawEntry statDrawEntry = selectedEntry ?? mousedOverEntry ?? cachedDrawEntries.FirstOrDefault();

            if (statDrawEntry != null)
            {
                StatRequest optionalReq     = statDrawEntry.hasOptionalReq ? statDrawEntry.optionalReq : ((optionalThing == null) ? StatRequest.ForEmpty() : StatRequest.For(optionalThing));
                string      explanationText = statDrawEntry.GetExplanationText(optionalReq);
                Rect        rect5           = rect4.AtZero();
                Widgets.Label(rect5, explanationText);
            }
            GUI.EndGroup();
        }
Пример #12
0
        private static IEnumerable <StatDrawEntry> StatsToDraw(Def def, ThingDef stuff)
        {
            yield return(StatsReportUtility.DescriptionEntry(def));

            BuildableDef eDef = def as BuildableDef;

            if (eDef != null)
            {
                foreach (StatDef stat in from st in DefDatabase <StatDef> .AllDefs
                         where st.Worker.ShouldShowFor(eDef)
                         select st)
                {
                    yield return(new StatDrawEntry(stat.category, stat, eDef.GetStatValueAbstract(stat, stuff), StatRequest.For(eDef, stuff, QualityCategory.Normal), ToStringNumberSense.Undefined));
                }
            }
        }
 private bool TryGetValue(StatRequest req, out float value)
 {
     return(PawnOrCorpseStatUtility.TryGetPawnOrCorpseStat(req, (Pawn x) => MassUtility.GearAndInventoryMass(x), (ThingDef x) => 0f, out value));
 }
 public override float GetValueUnfinalized(StatRequest req, bool applyPostProcess = true)
 {
     return(ValueFromReq(req));
 }
Пример #15
0
 private void DrawForagedFoodPerDay(Rect rect, TransferableOneWay trad)
 {
     if (trad.HasAnyThing)
     {
         Pawn p = trad.AnyThing as Pawn;
         if (p != null)
         {
             bool  skip;
             float foragedNutritionPerDay = ForagedFoodPerDayCalculator.GetBaseForagedNutritionPerDay(p, out skip);
             if (!skip)
             {
                 Widgets.DrawHighlightIfMouseover(rect);
                 GUI.color = ((foragedNutritionPerDay != 0f) ? Color.green : Color.gray);
                 Widgets.Label(rect, "+" + foragedNutritionPerDay.ToString("0.##"));
                 GUI.color = Color.white;
                 TooltipHandler.TipRegion(rect, () => "NutritionForagedPerDayTip".Translate(StatDefOf.ForagedNutritionPerDay.Worker.GetExplanationFull(StatRequest.For(p), StatDefOf.ForagedNutritionPerDay.toStringNumberSense, foragedNutritionPerDay)), trad.GetHashCode() ^ 0x74BEF43E);
             }
         }
     }
 }
Пример #16
0
        public override void TransformValue(StatRequest req, ref float val)
        {
            float num = ((Find.Storyteller != null) ? Find.Storyteller.difficultyValues.butcherYieldFactor : 1f);

            val *= num;
        }
Пример #17
0
 public float GetStatValue(StatDef stat)
 {
     return(stat.Worker.GetValue(StatRequest.For(thing, stuff, Quality)));
 }
Пример #18
0
 private bool TryGetValue(StatRequest req, out float value)
 {
     return(PawnOrCorpseStatUtility.TryGetPawnOrCorpseStat(req, (Pawn x) => x.health.hediffSet.GetCoverageOfNotMissingNaturalParts(x.RaceProps.body.corePart), (ThingDef x) => 1f, out value));
 }
Пример #19
0
 public override void TransformValue(StatRequest req, ref float val)
 {
     val *= this.Multiplier(Find.Storyteller.difficulty);
 }
Пример #20
0
 public override void TransformValue(StatRequest req, ref float val)
 {
     TransformAndExplain(req, ref val, null);
 }
Пример #21
0
        public override IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef)
        {
            if (parentDef.IsDrug && chance >= 1f)
            {
                using (IEnumerator <StatDrawEntry> enumerator = hediffDef.SpecialDisplayStats(StatRequest.ForEmpty()).GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        StatDrawEntry s = enumerator.Current;
                        yield return(s);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
            }
            yield break;
IL_00e8:
            /*Error near IL_00e9: Unexpected return in MoveNext()*/;
        }
Пример #22
0
 protected override float CurveXGetter(StatRequest req)
 {
     return((float)req.Thing.HitPoints / (float)req.Thing.MaxHitPoints);
 }
        public override IEnumerable <Dialog_InfoCard.Hyperlink> GetInfoCardHyperlinks(StatRequest req)
        {
            Pawn pawn = req.Thing as Pawn;

            if (pawn == null || pawn.apparel == null)
            {
                yield break;
            }
            for (int i = 0; i < pawn.apparel.WornApparel.Count; i++)
            {
                Apparel thing = pawn.apparel.WornApparel[i];
                if (Mathf.Abs(thing.GetStatValue(apparelStat)) > 0f)
                {
                    yield return(new Dialog_InfoCard.Hyperlink(thing));
                }
            }
        }
Пример #24
0
 protected override bool AppliesTo(StatRequest req)
 {
     return(req.HasThing && req.Thing.def.useHitPoints);
 }
Пример #25
0
 private bool TryGetBodySize(StatRequest req, out float bodySize)
 {
     return(PawnOrCorpseStatUtility.TryGetPawnOrCorpseStat(req, (Pawn x) => x.BodySize, (ThingDef x) => x.race.baseBodySize, out bodySize));
 }
Пример #26
0
 private bool TryGetIsFleshFactor(StatRequest req, out float bodySize)
 {
     return(PawnOrCorpseStatUtility.TryGetPawnOrCorpseStat(req, (Pawn x) => (!x.RaceProps.IsFlesh) ? 0f : 1f, (ThingDef x) => (!x.race.IsFlesh) ? 0f : 1f, out bodySize));
 }
Пример #27
0
        public virtual string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            StringBuilder stringBuilder = new StringBuilder();
            float         baseValueFor  = this.GetBaseValueFor(req.Def);

            if (baseValueFor != 0.0)
            {
                stringBuilder.AppendLine("StatsReport_BaseValue".Translate());
                stringBuilder.AppendLine("    " + 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("    " + skillNeed.skill.LabelCap + " (" + level + "): " + val.ToStringSign() + this.ValueToString(val, false, ToStringNumberSense.Absolute));
                        }
                        stringBuilder.AppendLine();
                    }
                }
                else if (this.stat.noSkillOffset != 0.0)
                {
                    stringBuilder.AppendLine("StatsReport_Skills".Translate());
                    stringBuilder.AppendLine("    " + "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 item in from hfa in this.stat.capacityOffsets
                             orderby hfa.capacity.listOrder
                             select hfa)
                    {
                        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  = this.ValueToString(offset, false, ToStringNumberSense.Absolute);
                        string text3  = Mathf.Min(level2, item.max).ToStringPercent() + ", " + "HealthOffsetScale".Translate(item.scale.ToString() + "x");
                        if (item.max < 999.0)
                        {
                            text3 = text3 + ", " + "HealthFactorMaxImpact".Translate(item.max.ToStringPercent());
                        }
                        stringBuilder.AppendLine("    " + text + ": " + offset.ToStringSign() + text2 + " (" + text3 + ")");
                    }
                    stringBuilder.AppendLine();
                }
                if ((int)pawn.RaceProps.intelligence >= 1)
                {
                    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();
                        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();
                        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())
                    {
                        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 != 0.0)
                        {
                            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 != 1.0)
                {
                    stringBuilder.AppendLine("StatsReport_LifeStage".Translate() + " (" + pawn.ageTracker.CurLifeStage.label + "): " + statFactorFromList.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor));
                    stringBuilder.AppendLine();
                }
            }
            if (req.StuffDef != null && (baseValueFor > 0.0 || this.stat.applyFactorsIfNegative))
            {
                float statOffsetFromList2 = req.StuffDef.stuffProps.statOffsets.GetStatOffsetFromList(this.stat);
                if (statOffsetFromList2 != 0.0)
                {
                    stringBuilder.AppendLine("StatsReport_Material".Translate() + " (" + req.StuffDef.LabelCap + "): " + statOffsetFromList2.ToStringByStyle(this.stat.toStringStyle, ToStringNumberSense.Offset));
                    stringBuilder.AppendLine();
                }
                float statFactorFromList2 = req.StuffDef.stuffProps.statFactors.GetStatFactorFromList(this.stat);
                if (statFactorFromList2 != 1.0)
                {
                    stringBuilder.AppendLine("StatsReport_Material".Translate() + " (" + req.StuffDef.LabelCap + "): " + statFactorFromList2.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor));
                    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("    " + skillNeed2.skill.LabelCap + " (" + level3 + "): x" + skillNeed2.ValueFor(pawn).ToStringPercent());
                        }
                        stringBuilder.AppendLine();
                    }
                }
                else if (this.stat.noSkillFactor != 1.0)
                {
                    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 item2 in from hfa in this.stat.capacityFactors
                                 orderby hfa.capacity.listOrder
                                 select hfa)
                        {
                            string text4  = item2.capacity.GetLabelFor(pawn).CapitalizeFirst();
                            float  factor = item2.GetFactor(pawn.health.capacities.GetLevel(item2.capacity));
                            string text5  = factor.ToStringPercent();
                            string text6  = "HealthFactorPercentImpact".Translate(item2.weight.ToStringPercent());
                            if (item2.max < 999.0)
                            {
                                text6 = text6 + ", " + "HealthFactorMaxImpact".Translate(item2.max.ToStringPercent());
                            }
                            if (item2.allowedDefect != 0.0)
                            {
                                text6 = text6 + ", " + "HealthFactorAllowedDefect".Translate(((float)(1.0 - item2.allowedDefect)).ToStringPercent());
                            }
                            stringBuilder.AppendLine("    " + text4 + ": x" + text5 + " (" + text6 + ")");
                        }
                    }
                    stringBuilder.AppendLine();
                }
                if (pawn.Inspired)
                {
                    float statOffsetFromList3 = pawn.InspirationDef.statOffsets.GetStatOffsetFromList(this.stat);
                    if (statOffsetFromList3 != 0.0)
                    {
                        stringBuilder.AppendLine("StatsReport_Inspiration".Translate(pawn.Inspiration.def.LabelCap) + ": " + this.ValueToString(statOffsetFromList3, false, ToStringNumberSense.Offset));
                        stringBuilder.AppendLine();
                    }
                    float statFactorFromList3 = pawn.InspirationDef.statFactors.GetStatFactorFromList(this.stat);
                    if (statFactorFromList3 != 1.0)
                    {
                        stringBuilder.AppendLine("StatsReport_Inspiration".Translate(pawn.Inspiration.def.LabelCap) + ": " + statFactorFromList3.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor));
                        stringBuilder.AppendLine();
                    }
                }
            }
            return(stringBuilder.ToString().TrimEndNewlines());
        }
Пример #28
0
        public override void TransformValue(StatRequest req, ref float value)
        {
            float num = (req.StuffDef == null) ? 0f : req.StuffDef.GetStatValueAbstract(stuffPowerStat);

            value += GetMultiplier(req) * num;
        }
Пример #29
0
 public float GetValueAbstract(BuildableDef def, ThingDef stuffDef = null)
 {
     return(this.GetValue(StatRequest.For(def, stuffDef, QualityCategory.Normal), true));
 }
        public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            float wildness = ((ThingDef)req.Def).race.wildness;

            return("Wildness".Translate() + " " + wildness.ToStringPercent() + ": " + ValueFromReq(req).ToString("F0"));
        }