public override IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef) { foreach (StatDrawEntry s in hediffDefAdd.SpecialDisplayStats(StatRequest.ForEmpty())) { yield return(s); } yield break; }
public override IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef) { if (parentDef.IsDrug && chance >= 1f) { foreach (StatDrawEntry item in hediffDef.SpecialDisplayStats(StatRequest.ForEmpty())) { yield return(item); } } }
// Token: 0x06000AEE RID: 2798 RVA: 0x00057198 File Offset: 0x00055598 public override IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef) { if (parentDef.IsDrug && this.chance >= 1f) { foreach (StatDrawEntry s in this.hediffDef.SpecialDisplayStats(StatRequest.ForEmpty())) { yield return(s); } } yield break; }
public override IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef) { if (!parentDef.IsDrug || !(chance >= 1f)) { yield break; } foreach (var s in hediffDef.SpecialDisplayStats(StatRequest.ForEmpty())) { yield return(s); } }
public static bool Prefix(IEnumerable <StatDrawEntry> original) { IEnumerable <StatDrawEntry> affected = (from de in original where de.stat == StatDefOf.ComfyTemperatureMin || de.stat == StatDefOf.ComfyTemperatureMax select de); foreach (StatDrawEntry target in affected) { StatRequest req = target.optionalReq; Pawn pawn = req.Thing as Pawn; StringBuilder alteredText = new StringBuilder(); if (!pawn.InBed()) { alteredText.AppendLine(target.GetExplanationText(target.optionalReq)); } else { alteredText.AppendLine(target.GetExplanationText(StatRequest.ForEmpty())); alteredText.AppendLine(); //reflection MethodInfo baseValueInfo = AccessTools.Method(typeof(StatWorker), "GetBaseValueFor", new[] { typeof(BuildableDef) }); float baseValueFor = (float)baseValueInfo.Invoke(target.stat.Worker, new[] { req.Def }); FieldInfo numberSenseInfo = AccessTools.Field(typeof(StatDrawEntry), "numberSense"); ToStringNumberSense numberSense = (ToStringNumberSense)numberSenseInfo.GetValue(target); // alteredText.AppendLine(target.stat.Worker.GetExplanationUnfinalized(req, numberSense)); alteredText.AppendLine(); bool subtract = target.stat == StatDefOf.ComfyTemperatureMin; StatDef modifier = subtract ? BedInsulationCold.Bed_Insulation_Cold : BedInsulationHeat.Bed_Insulation_Heat; float bedStatValue = pawn.CurrentBed().GetStatValue(modifier, true); float bedOffset = subtract ? bedStatValue * -1 : bedStatValue; string signal = subtract ? null : "+"; alteredText.AppendLine("StatsReport_BedInsulation".Translate() + ": " + signal + bedOffset.ToStringTemperature()); alteredText.AppendLine(); alteredText.Append("StatsReport_FinalValue".Translate() + ": " + target.stat.ValueToString(baseValueFor + bedOffset, target.stat.toStringNumberSense)); //alteredText.AppendLine(); //alteredText.Append("DEBUG: subtract: " + subtract + " modifier: " + modifier.ToString() + " bedStatValue: " + bedStatValue + " bedOffset: " + bedOffset + " signal: " + signal); } target.overrideReportText = alteredText.ToString().TrimEndNewlines(); } return(true); }
public static StatRequest For(ThingWithComps tool, ToolType toolType) { IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { var Thing_def = AccessTools.Field(typeof(Thing), "def"); var instructionList = instructions.ToList(); for (int i = 0; i < instructionList.Count; i++) { var instruction = instructionList[i]; if (instruction.LoadsField(Thing_def)) { instructionList[i] = new CodeInstruction(OpCodes.Ldarg_1, null); instructionList.RemoveAt(i - 1); break; } } return(instructionList); } _ = Transpiler(null); return(StatRequest.ForEmpty()); }
public override IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef) { if (parentDef.IsDrug && base.chance >= 1f) { using (IEnumerator <StatDrawEntry> enumerator = this.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; /*Error near IL_00e4: Unexpected return in MoveNext()*/ ; }
private void DrawStatsWorker(Rect rect) { 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, true); float num = 0f; string b = null; cachedDrawEntries = this.StatsToDraw(this.thing).ToList(); this.FinalizeCachedDrawEntries(); mousedOverEntry = null; foreach (StatDrawEntry stat in cachedDrawEntries) { if (stat.category.LabelCap != b) { Widgets.ListSeparator(ref num, viewRect.width, stat.category.LabelCap); b = stat.category.LabelCap; } num += stat.Draw(8f, num, viewRect.width - 8f, selectedEntry == stat, delegate { selectedEntry = stat; SoundDefOf.Tick_High.PlayOneShotOnCamera(null); }, delegate { mousedOverEntry = stat; }, scrollPosition, rect2); } listHeight = num + 100f; Widgets.EndScrollView(); Rect rect4 = rect3.ContractedBy(10f); GUI.BeginGroup(rect4); StatDrawEntry statDrawEntry; if ((statDrawEntry = selectedEntry) is null) { statDrawEntry = mousedOverEntry ?? cachedDrawEntries.FirstOrDefault <StatDrawEntry>(); } StatDrawEntry statDrawEntry2 = statDrawEntry; if (statDrawEntry2 != null) { StatRequest optionalReq; if (statDrawEntry2.hasOptionalReq) { optionalReq = statDrawEntry2.optionalReq; } else if (this.thing != null) { optionalReq = StatRequest.For(this.thing); } else { optionalReq = StatRequest.ForEmpty(); } string explanation = statDrawEntry2.GetExplanationText(optionalReq); Rect rect5 = rect4.AtZero(); Widgets.Label(rect5, explanation); } GUI.EndGroup(); }
public static void Postfix(ThingDef __instance, StatRequest req, ref IEnumerable <StatDrawEntry> __result) { // Add mortar shell stats to the list of stat draw entries if (__instance.IsShell) { var shellThing = ThingMaker.MakeThing(__instance.projectileWhenLoaded); var shellProps = __instance.projectileWhenLoaded.projectile; var shellDamage = shellProps.GetDamageAmount(shellThing); var shellArmorPenetration = shellProps.GetArmorPenetration(shellThing); var shellStoppingPower = shellProps.StoppingPower; var shellDamageDef = shellProps.damageDef.label.CapitalizeFirst(); var shellExplosionRadius = shellProps.explosionRadius; __result = __result.AddItem(new StatDrawEntry(StatCategoryDefOf.TurretAmmo, "Damage".Translate(), shellDamage.ToString(), "Stat_Thing_Damage_Desc".Translate(), 20)); __result = __result.AddItem(new StatDrawEntry(StatCategoryDefOf.TurretAmmo, "TurretExtensions.ShellDamageType".Translate(), shellDamageDef, "TurretExtensions.ShellDamageType_Desc".Translate(), 19)); __result = __result.AddItem(new StatDrawEntry(StatCategoryDefOf.TurretAmmo, "ArmorPenetration".Translate(), shellArmorPenetration.ToStringPercent(), "ArmorPenetrationExplanation".Translate(), 18)); __result = __result.AddItem(new StatDrawEntry(StatCategoryDefOf.TurretAmmo, "StoppingPower".Translate(), shellStoppingPower.ToString(), "StoppingPowerExplanation".Translate(), 17)); if (shellExplosionRadius > 0) { __result = __result.AddItem(new StatDrawEntry(StatCategoryDefOf.TurretAmmo, "TurretExtensions.ShellExplosionRadius".Translate(), shellExplosionRadius.ToString(), "TurretExtensions.ShellExplosionRadius_Desc".Translate(), 16)); } } // Minimum range if (__instance.Verbs.FirstOrDefault(v => v.isPrimary) is VerbProperties verb) { var verbStatCategory = __instance.category != ThingCategory.Pawn ? RimWorld.StatCategoryDefOf.Weapon : RimWorld.StatCategoryDefOf.PawnCombat; if (verb.LaunchesProjectile) { if (verb.minRange > default(float)) { __result = __result.AddItem(new StatDrawEntry(verbStatCategory, "MinimumRange".Translate(), verb.minRange.ToString("F0"), "TurretExtensions.MinimumRange_Desc".Translate(), 5385)); } } } // Add turret weapons stats to the list of SpecialDisplayStats var buildingProps = __instance.building; if (buildingProps == null || !buildingProps.IsTurret) { return; } var gunStatList = new List <StatDrawEntry>(); if (req.Def is ThingDef tDef) { // Add upgradability string upgradableString; CompProperties_Upgradable upgradableCompProps; if (req.HasThing && req.Thing.IsUpgradable(out var upgradableComp)) { upgradableString = (upgradableComp.upgraded ? "TurretExtensions.NoAlreadyUpgraded" : "TurretExtensions.YesClickForDetails").Translate(); upgradableCompProps = upgradableComp.Props; } else { upgradableString = (tDef.IsUpgradable(out upgradableCompProps) ? "TurretExtensions.YesClickForDetails" : "No").Translate(); } var upgradeHyperlinks = new List <Dialog_InfoCard.Hyperlink>(); if (upgradableCompProps?.turretGunDef != null) { upgradeHyperlinks.Add(new Dialog_InfoCard.Hyperlink(upgradableCompProps.turretGunDef)); } gunStatList.Add(new StatDrawEntry(RimWorld.StatCategoryDefOf.BasicsNonPawn, "TurretExtensions.Upgradable".Translate(), upgradableString, TurretExtensionsUtility.UpgradeReadoutReportText(req), 999, hyperlinks: upgradeHyperlinks)); // Add firing arc var firingArc = req.HasThing ? TurretExtensionsUtility.FiringArcFor(req.Thing) : TurretFrameworkExtension.Get(tDef).FiringArc; gunStatList.Add(new StatDrawEntry(RimWorld.StatCategoryDefOf.Weapon, "TurretExtensions.FiringArc".Translate(), firingArc.ToStringDegrees(), "TurretExtensions.FiringArc_Desc".Translate(), 5380)); } // Replace cooldown __result = __result.Where(s => s.stat != StatDefOf.RangedWeapon_Cooldown); var cooldownStat = StatDefOf.RangedWeapon_Cooldown; gunStatList.Add(new StatDrawEntry(cooldownStat.category, cooldownStat, TurretCooldown(req, buildingProps), StatRequest.ForEmpty(), cooldownStat.toStringNumberSense)); // Replace warmup __result = __result.Where(s => s.LabelCap != "WarmupTime".Translate().CapitalizeFirst()); gunStatList.Add(new StatDrawEntry(RimWorld.StatCategoryDefOf.Weapon, "WarmupTime".Translate(), $"{TurretWarmup(req, buildingProps).ToString("0.##")} s", "Stat_Thing_Weapon_MeleeWarmupTime_Desc".Translate(), StatDisplayOrder.Thing_Weapon_MeleeWarmupTime)); __result = __result.Concat(gunStatList); }
public static IEnumerable <StatDrawEntry> Postfix( IEnumerable <StatDrawEntry> statdrawentries, HediffDef __instance ) { List <StatDrawEntry> statDrawEntryList = statdrawentries.ToList(); foreach (StatDrawEntry sDE in statDrawEntryList) { yield return(sDE); } if (!Settings.Store.HediffLightMods.TryGetValue(__instance, out Hediff_LightModifiers hlm) || !hlm.HasAnyModifier()) { yield break; } VisionType vt = hlm.Setting; if (vt < VisionType.NVCustom) { #if RW10 yield return(new StatDrawEntry( Defs_Rimworld.BasicStats, "NVGrantsVisionType".Translate(), vt.ToString().Translate(), 0, hlm.AffectsEye ? "NVHediffQualifier".Translate() : "" )); #else yield return(new StatDrawEntry( Defs_Rimworld.BasicStats, "NVGrantsVisionType".Translate().RawText, vt.ToString().Translate().RawText, hlm.AffectsEye ? "NVHediffQualifier".Translate().RawText : "", 0 )); #endif } else { #if RW10 yield return(new StatDrawEntry( Defs_Rimworld.BasicStats, "NVGrantsVisionType".Translate(), vt.ToString(), 0, hlm.AffectsEye ? "NVHediffQualifier".Translate(): "" )); #else yield return(new StatDrawEntry( Defs_Rimworld.BasicStats, "NVGrantsVisionType".Translate().RawText, vt.ToString(), hlm.AffectsEye ? "NVHediffQualifier".Translate().RawText: "", 0 )); #endif yield return(new StatDrawEntry( Defs_Rimworld.BasicStats, Defs_NightVision.NightVision, hlm[0], StatRequest.ForEmpty(), ToStringNumberSense.Offset )); yield return(new StatDrawEntry( Defs_Rimworld.BasicStats, Defs_NightVision.LightSensitivity, hlm[1], StatRequest.ForEmpty(), ToStringNumberSense.Offset )); } }
public static IEnumerable <StatDrawEntry> SpecialDisplayStats(HediffStage stage, HediffDef instance, IEnumerable <StatDrawEntry> __result) { foreach (StatDrawEntry entry in __result) { yield return(entry); } if (instance.GetModExtension <DefModextension_Hediff>() is DefModextension_Hediff modExt) { if (modExt.armorOffset != 0) { yield return(new StatDrawEntry(StatCategoryDefOf.PawnCombat, StatDefOf.ArmorRating_Blunt, modExt.armorOffset, StatRequest.ForEmpty())); yield return(new StatDrawEntry(StatCategoryDefOf.PawnCombat, StatDefOf.ArmorRating_Sharp, modExt.armorOffset, StatRequest.ForEmpty())); } if (modExt.batteryCapacityOffset != 0) { yield return(new StatDrawEntry(WTH_DefOf.WTH_StatCategory_Hidden, WTH_DefOf.WTH_BatteryCapacityPercentage, modExt.batteryCapacityOffset, StatRequest.ForEmpty())); } if (modExt.powerRateOffset != 0) { yield return(new StatDrawEntry(WTH_DefOf.WTH_StatCategory_Hidden, WTH_DefOf.WTH_PowerRatePercentage, modExt.powerRateOffset, StatRequest.ForEmpty())); } if (modExt.firingRateOffset != 0) { yield return(new StatDrawEntry(StatCategoryDefOf.PawnCombat, StatDefOf.RangedWeapon_Cooldown, modExt.firingRateOffset, StatRequest.ForEmpty())); yield return(new StatDrawEntry(StatCategoryDefOf.PawnCombat, StatDefOf.MeleeWeapon_CooldownMultiplier, modExt.firingRateOffset, StatRequest.ForEmpty())); yield return(new StatDrawEntry(StatCategoryDefOf.PawnCombat, StatDefOf.AimingDelayFactor, modExt.firingRateOffset, StatRequest.ForEmpty())); } if (modExt.carryingCapacityOffset != 0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, StatDefOf.CarryingCapacity, modExt.carryingCapacityOffset, StatRequest.ForEmpty())); } } }
public override IEnumerable <StatDrawEntry> SpecialDisplayStats(StatRequest req) { if (!RequiredResearch.NullOrEmpty()) { foreach (var project in RequiredResearch) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, RequiredResearchKey.Translate(), project.LabelCap, RequiredResearchDescKey.Translate(), 4)); } } if (!RequiredAbilities.NullOrEmpty()) { foreach (var ability in RequiredAbilities) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, RequiredAbilitiesKey.Translate(), ability.LabelCap, RequiredAbilitiesDescKey.Translate(), 3)); } } if (!ConflictingAbilities.NullOrEmpty()) { foreach (var ability in ConflictingAbilities) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, ConflictingAbilitiesKey.Translate(), ability.LabelCap, ConflictingAbilitiesDescKey.Translate(), 2)); } } yield return(new StatDrawEntry(StatCategoryDefOf.Basics, TrainingTimeDaysKey.Translate(), TrainingTimeDays.ToString(CultureInfo.InvariantCulture), TrainingTimeDaysDescKey.Translate(), 1)); if (EnergyPerUse != 0) { yield return(new StatDrawEntry(PsiTechDefOf.PTAbilityStats, EnergyPerUseKey.Translate(), EnergyPerUse.ToString(CultureInfo.InvariantCulture), EnergyPerUseDescKey.Translate(), 99)); } if (EnergyPerSecondActive != 0) { yield return(new StatDrawEntry(PsiTechDefOf.PTAbilityStats, EnergyPerSecondActiveKey.Translate(), EnergyPerSecondActive.ToString(CultureInfo.InvariantCulture), EnergyPerSecondActiveDescKey.Translate(), 98)); } if (Range != 0) { yield return(new StatDrawEntry(PsiTechDefOf.PTAbilityStats, RangeKey.Translate(), Range.ToString(CultureInfo.InvariantCulture), RangeDescKey.Translate(), 97)); } if (CooldownSeconds != 0) { yield return(new StatDrawEntry(PsiTechDefOf.PTAbilityStats, CooldownSecondsKey.Translate(), CooldownSeconds.ToString(CultureInfo.InvariantCulture), CooldownSecondsDescKey.Translate(), 96)); } if (BaseSuccessChance != 0) { yield return(new StatDrawEntry(PsiTechDefOf.PTAbilityStats, BaseSuccessChanceKey.Translate(), BaseSuccessChance.ToStringPercent(), BaseSuccessChanceDescKey.Translate(), 95)); } if (!PossibleEffects.NullOrEmpty()) { foreach (var effect in PossibleEffects) { yield return(new StatDrawEntry(PsiTechDefOf.PTEffects, effect.Title, "", GenerateEffectValueString(effect), (int)Math.Round(effect.Weight * 10))); } } if (!PossibleEffectsOnUser.NullOrEmpty()) { foreach (var effect in PossibleEffectsOnUser) { yield return(new StatDrawEntry(PsiTechDefOf.PTEffectsOnUser, effect.Title, "", GenerateEffectValueString(effect, true), (int)Math.Round(effect.Weight * 10))); } } if (!StatOffsets.NullOrEmpty()) { foreach (var offset in StatOffsets) { yield return(new StatDrawEntry(PsiTechDefOf.PTStatOffsets, offset.stat.LabelCap, offset.value.ToStringByStyle(offset.stat.ToStringStyleUnfinalized, ToStringNumberSense.Offset), offset.stat.description, 0)); } } if (!StatFactors.NullOrEmpty()) { foreach (var factor in StatFactors) { yield return(new StatDrawEntry(PsiTechDefOf.PTStatFactors, factor.stat, factor.value, StatRequest.ForEmpty(), ToStringNumberSense.Factor)); } } if (!CapMods.NullOrEmpty()) { foreach (var mod in CapMods) { if (mod.offset != 0) { yield return(new StatDrawEntry(PsiTechDefOf.PTCapMods, mod.capacity.LabelCap, "+" + mod.offset.ToStringPercent(), mod.capacity.description, 0)); } if (mod.postFactor != 1) { yield return(new StatDrawEntry(PsiTechDefOf.PTCapMods, mod.capacity.LabelCap, "x" + mod.postFactor.ToStringPercent(), mod.capacity.description, 0)); } } } }
public static IEnumerable <StatDrawEntry> Postfix(IEnumerable <StatDrawEntry> __result, ThingDef __instance, StatRequest req) { foreach (var r in __result) { yield return(r); } var extension = __instance.GetModExtension <ApparelExtension>(); if (extension != null && !extension.equippedStatFactors.NullOrEmpty()) { if (!extension.equippedStatFactors.NullOrEmpty()) { for (int k = 0; k < extension.equippedStatFactors.Count; k++) { StatDef stat = extension.equippedStatFactors[k].stat; float num3 = extension.equippedStatFactors[k].value; StringBuilder stringBuilder5 = new StringBuilder(stat.description); if (req.HasThing && stat.Worker != null) { stringBuilder5.AppendLine(); stringBuilder5.AppendLine(); stringBuilder5.AppendLine("StatsReport_BaseValue".Translate() + ": " + stat.ValueToString(num3, ToStringNumberSense.Factor, stat.finalizeEquippedStatOffset)); num3 = StatWorker_GetValueUnfinalized_Transpiler.StatFactorFromGear(req.Thing as Apparel, stat); if (!stat.parts.NullOrEmpty()) { stringBuilder5.AppendLine(); for (int l = 0; l < stat.parts.Count; l++) { string text = stat.parts[l].ExplanationPart(req); if (!text.NullOrEmpty()) { stringBuilder5.AppendLine(text); } } } stringBuilder5.AppendLine(); stringBuilder5.AppendLine("StatsReport_FinalValue".Translate() + ": " + stat.ValueToString(num3, ToStringNumberSense.Factor, !stat.formatString.NullOrEmpty())); } yield return(new StatDrawEntry(VFEDefOf.VFE_EquippedStatFactors, extension.equippedStatFactors[k].stat, num3, StatRequest.ForEmpty(), ToStringNumberSense.Factor, null, forceUnfinalizedMode: true).SetReportText(stringBuilder5.ToString())); } } } }
public static StatRequest For(ToolType toolType, ThingDef stuffDef, QualityCategory quality = QualityCategory.Normal) { return(StatRequest.ForEmpty()); }