public static float GetHighOffsetPerDay(ThingDef d) { IngestionOutcomeDoer_GiveHediff drugHighGiver = GetDrugHighGiver(d); if (drugHighGiver == null) { return(0f); } return(drugHighGiver.hediffDef.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay ?? 0f); }
public static string GetSafeDoseIntervalReadout(ThingDef d) { IngestionOutcomeDoer_GiveHediff toleranceGiver = GetToleranceGiver(d); float safeDoseInterval = GetSafeDoseInterval(d); float num = (toleranceGiver != null) ? (GetDrugComp(d).minToleranceToAddict / toleranceGiver.severity) : 0f; if (safeDoseInterval == 0f) { return("AlwaysSafe".Translate()); } if (num < 1f) { return("NeverSafe".Translate()); } return("PeriodDays".Translate(safeDoseInterval.ToString("F1"))); }
public static IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef def) { CompProperties_Drug drugComp = GetDrugComp(def); if (drugComp == null) { yield break; } IngestionOutcomeDoer_GiveHediff highGiver = GetDrugHighGiver(def); if (highGiver != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Drug, "HighGain".Translate(), highGiver.severity.ToStringPercent(), "Stat_Thing_Drug_HighGainPerDose_Desc".Translate(), 2480)); float highFall = Mathf.Abs(GetHighOffsetPerDay(def)); if (highFall > 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Drug, "HighFallRate".Translate(), "PerDay".Translate(highFall.ToStringPercent()), "Stat_Thing_Drug_HighFallPerDay_Desc".Translate(), 2470)); yield return(new StatDrawEntry(StatCategoryDefOf.Drug, "HighDuration".Translate(), "PeriodDays".Translate((highGiver.severity / highFall).ToString("F1")), "Stat_Thing_Drug_HighDurationPerDose_Desc".Translate(), 2460)); } } if (GetTolerance(def) != null) { float toleranceGain = GetToleranceGain(def); if (toleranceGain > 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Drug, "ToleranceGain".Translate(), toleranceGain.ToStringPercent(), "Stat_Thing_Drug_ToleranceGainPerDose_Desc".Translate(), 2450)); } float num = Mathf.Abs(GetToleranceOffsetPerDay(def)); if (num > 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Drug, "ToleranceFallRate".Translate(), "PerDay".Translate(num.ToStringPercent()), "Stat_Thing_Drug_ToleranceFallPerDay_Desc".Translate(), 2440)); } } if (drugComp.Addictive) { HediffDef addictionHediff = GetChemical(def)?.addictionHediff; if (addictionHediff != null) { float num2 = Mathf.Abs(GetAddictionOffsetPerDay(def)); if (num2 > 0f) { yield return(new StatDrawEntry(valueString: "PeriodDays".Translate((addictionHediff.initialSeverity / num2).ToString("F1")), category: StatCategoryDefOf.DrugAddiction, label: "AddictionRecoveryTime".Translate(), reportText: "Stat_Thing_Drug_AddictionRecoveryTime_Desc".Translate(), displayPriorityWithinCategory: 2395)); } yield return(new StatDrawEntry(StatCategoryDefOf.DrugAddiction, "AddictionSeverityInitial".Translate(), addictionHediff.initialSeverity.ToStringPercent(), "Stat_Thing_Drug_AddictionSeverityInitial_Desc".Translate(), 2427)); } yield return(new StatDrawEntry(StatCategoryDefOf.DrugAddiction, "AddictionNeedFallRate".Translate(), "PerDay".Translate(GetNeed(def).fallPerDay.ToStringPercent()), "Stat_Thing_Drug_AddictionNeedFallRate_Desc".Translate(), 2410)); yield return(new StatDrawEntry(StatCategoryDefOf.DrugAddiction, "AddictionCost".Translate(), "PerDay".Translate(GetAddictionNeedCostPerDay(def).ToStringMoney()), "Stat_Thing_Drug_AddictionCost_Desc".Translate(), 2390)); yield return(new StatDrawEntry(StatCategoryDefOf.DrugAddiction, "AddictionNeedDoseInterval".Translate(), "PeriodDays".Translate((drugComp.needLevelOffset / GetNeed(def).fallPerDay).ToString("F1")), "Stat_Thing_Drug_AddictionNeedDoseInterval_Desc".Translate(), 2400)); if (drugComp.chemical != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Drug, "Chemical".Translate(), drugComp.chemical.LabelCap, "Stat_Thing_Drug_Chemical_Desc".Translate(), 2490)); } yield return(new StatDrawEntry(StatCategoryDefOf.DrugAddiction, "Addictiveness".Translate(), drugComp.addictiveness.ToStringPercent(), "Stat_Thing_Drug_Addictiveness_Desc".Translate(), 2428)); yield return(new StatDrawEntry(StatCategoryDefOf.DrugAddiction, "AddictionNeedOffset".Translate(), drugComp.needLevelOffset.ToStringPercent(), "Stat_Thing_Drug_AddictionNeedOffset_Desc".Translate(), 2420)); yield return(new StatDrawEntry(StatCategoryDefOf.DrugAddiction, "MinimumToleranceForAddiction".Translate(), drugComp.minToleranceToAddict.ToStringPercent(), "Stat_Thing_Drug_MinToleranceForAddiction_Desc".Translate(), 2437)); yield return(new StatDrawEntry(StatCategoryDefOf.DrugAddiction, "AddictionSeverityPerDose".Translate(), drugComp.existingAddictionSeverityOffset.ToStringPercent(), "Stat_Thing_Drug_AddictionSeverityPerDose_Desc".Translate(), 2424)); } yield return(new StatDrawEntry(StatCategoryDefOf.Drug, "RandomODChance".Translate(), drugComp.largeOverdoseChance.ToStringPercent(), "Stat_Thing_Drug_RandomODChance_Desc".Translate(), 2380)); yield return(new StatDrawEntry(StatCategoryDefOf.Drug, "SafeDoseInterval".Translate(), GetSafeDoseIntervalReadout(def), "Stat_Thing_Drug_SafeDoseInterval_Desc".Translate(), 2435)); }