private string InfoTextLineFrom(Thing gear) { float statValue = gear.GetStatValue(apparelStat); statValue += StatWorker.StatOffsetFromGear(gear, apparelStat); if (subtract) { statValue = 0f - statValue; } return(" " + gear.LabelCap + ": " + statValue.ToStringByStyle(parentStat.toStringStyle, ToStringNumberSense.Offset)); }
public override void TransformValue(StatRequest req, ref float val) { if (!req.HasThing || req.Thing == null) { return; } Pawn pawn = req.Thing as Pawn; if (pawn == null) { return; } if (pawn.apparel != null) { for (int i = 0; i < pawn.apparel.WornApparel.Count; i++) { float statValue = pawn.apparel.WornApparel[i].GetStatValue(apparelStat); statValue += StatWorker.StatOffsetFromGear(pawn.apparel.WornApparel[i], apparelStat); if (subtract) { val -= statValue; } else { val += statValue; } } } if (includeWeapon && pawn.equipment != null && pawn.equipment.Primary != null) { float statValue2 = pawn.equipment.Primary.GetStatValue(apparelStat); statValue2 += StatWorker.StatOffsetFromGear(pawn.equipment.Primary, apparelStat); if (subtract) { val -= statValue2; } else { val += statValue2; } } }
private bool PawnWearingRelevantGear(Pawn pawn) { if (pawn.apparel != null) { for (int i = 0; i < pawn.apparel.WornApparel.Count; i++) { Apparel apparel = pawn.apparel.WornApparel[i]; if (apparel.GetStatValue(apparelStat) != 0f) { return(true); } if (StatWorker.StatOffsetFromGear(apparel, apparelStat) != 0f) { return(true); } } } if (includeWeapon && pawn.equipment != null && pawn.equipment.Primary != null && StatWorker.StatOffsetFromGear(pawn.equipment.Primary, apparelStat) != 0f) { return(true); } return(false); }
private static string InfoTextLineFromGear(Thing gear, StatDef stat) { float f = StatWorker.StatOffsetFromGear(gear, stat); return(" " + gear.LabelCap + ": " + f.ToStringByStyle(stat.toStringStyle, ToStringNumberSense.Offset)); }
public virtual float GetValueUnfinalized(StatRequest req, bool applyPostProcess = true) { if (Prefs.DevMode && this.IsDisabledFor(req.Thing)) { Log.ErrorOnce(string.Format("Attempted to calculate value for disabled stat {0}; this is meant as a consistency check, either set the stat to neverDisabled or ensure this pawn cannot accidentally use this stat (thing={1})", this.stat, req.Thing.ToStringSafe <Thing>()), 75193282 + (int)this.stat.index, false); } float num = this.GetBaseValueFor(req.Def); Pawn pawn = req.Thing as Pawn; if (pawn != null) { if (pawn.skills != null) { if (this.stat.skillNeedOffsets != null) { for (int i = 0; i < this.stat.skillNeedOffsets.Count; i++) { num += this.stat.skillNeedOffsets[i].ValueFor(pawn); } } } else { num += this.stat.noSkillOffset; } if (this.stat.capacityOffsets != null) { for (int j = 0; j < this.stat.capacityOffsets.Count; j++) { PawnCapacityOffset pawnCapacityOffset = this.stat.capacityOffsets[j]; num += pawnCapacityOffset.GetOffset(pawn.health.capacities.GetLevel(pawnCapacityOffset.capacity)); } } if (pawn.story != null) { for (int k = 0; k < pawn.story.traits.allTraits.Count; k++) { num += pawn.story.traits.allTraits[k].OffsetOfStat(this.stat); } } List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (int l = 0; l < hediffs.Count; l++) { HediffStage curStage = hediffs[l].CurStage; if (curStage != null) { num += curStage.statOffsets.GetStatOffsetFromList(this.stat); } } if (pawn.apparel != null) { for (int m = 0; m < pawn.apparel.WornApparel.Count; m++) { num += StatWorker.StatOffsetFromGear(pawn.apparel.WornApparel[m], this.stat); } } if (pawn.equipment != null && pawn.equipment.Primary != null) { num += StatWorker.StatOffsetFromGear(pawn.equipment.Primary, this.stat); } if (pawn.story != null) { for (int n = 0; n < pawn.story.traits.allTraits.Count; n++) { num *= pawn.story.traits.allTraits[n].MultiplierOfStat(this.stat); } } num *= pawn.ageTracker.CurLifeStage.statFactors.GetStatFactorFromList(this.stat); } if (req.StuffDef != null) { if (num > 0f || this.stat.applyFactorsIfNegative) { num *= req.StuffDef.stuffProps.statFactors.GetStatFactorFromList(this.stat); } num += req.StuffDef.stuffProps.statOffsets.GetStatOffsetFromList(this.stat); } if (req.HasThing) { CompAffectedByFacilities compAffectedByFacilities = req.Thing.TryGetComp <CompAffectedByFacilities>(); if (compAffectedByFacilities != null) { num += compAffectedByFacilities.GetStatOffset(this.stat); } if (this.stat.statFactors != null) { for (int num2 = 0; num2 < this.stat.statFactors.Count; num2++) { num *= req.Thing.GetStatValue(this.stat.statFactors[num2], true); } } if (pawn != null) { if (pawn.skills != null) { if (this.stat.skillNeedFactors != null) { for (int num3 = 0; num3 < this.stat.skillNeedFactors.Count; num3++) { num *= this.stat.skillNeedFactors[num3].ValueFor(pawn); } } } else { num *= this.stat.noSkillFactor; } if (this.stat.capacityFactors != null) { for (int num4 = 0; num4 < this.stat.capacityFactors.Count; num4++) { PawnCapacityFactor pawnCapacityFactor = this.stat.capacityFactors[num4]; float factor = pawnCapacityFactor.GetFactor(pawn.health.capacities.GetLevel(pawnCapacityFactor.capacity)); num = Mathf.Lerp(num, num * factor, pawnCapacityFactor.weight); } } if (pawn.Inspired) { num += pawn.InspirationDef.statOffsets.GetStatOffsetFromList(this.stat); num *= pawn.InspirationDef.statFactors.GetStatFactorFromList(this.stat); } } } return(num); }