//Pawn_DrugPolicyTracker.ShouldTryToTakeScheduledNow public static bool VampiresDontHaveDrugSchedules(Pawn_DrugPolicyTracker __instance, ThingDef ingestible, ref bool __result) { if (__instance?.pawn?.IsVampire() == true) { __result = false; return(false); } return(true); }
static bool Prefix(ref bool __result, ref Pawn_DrugPolicyTracker __instance, ref ThingDef thingDef) { if (!Settings.drugs_use_potential_mood) { return(true); } //i've failed trying to inject "actually changed part" in exact part of a code (result looked too monstrous to me) //so I've used a simple solution // //duplicating initial part if (!thingDef.IsIngestible) { Log.Error(thingDef + " is not ingestible."); __result = false; return(false); } if (!thingDef.IsDrug) { Log.Error("AllowedToTakeScheduledEver on non-drug " + thingDef); __result = false; return(false); } if (!__instance.AllowedToTakeScheduledEver(thingDef)) { __result = false; return(false); } DrugPolicyEntry drugPolicyEntry = __instance.CurrentPolicy[thingDef]; //actually changed part if (drugPolicyEntry.onlyIfMoodBelow < 1f && __instance.pawn.needs.mood != null && (__instance.pawn.needs.mood.CurLevelPercentage >= drugPolicyEntry.onlyIfMoodBelow || __instance.pawn.needs.mood.CurInstantLevelPercentage >= drugPolicyEntry.onlyIfMoodBelow)) { __result = false; return(false); } return(true); }
// Token: 0x0600004C RID: 76 RVA: 0x00005168 File Offset: 0x00003368 public static bool IsOKtoAdmin(Pawn pawn, HediffDef hdef, ThingDef def) { DrugPolicy drugPolicy; if (pawn == null) { drugPolicy = null; } else { Pawn_DrugPolicyTracker drugs = pawn.drugs; drugPolicy = (drugs?.CurrentPolicy); } DrugPolicy policy = drugPolicy; if (policy != null) { if (!MSDrugUtility.DPExists(policy, def)) { Messages.Message(TranslatorFormattedStringExtensions.Translate("MSPainless.ErrDrugPolicy", pawn?.LabelShort, def?.label), pawn, MessageTypeDefOf.NeutralEvent, false); return(false); } if (policy[def] != null) { DrugPolicyEntry entry = policy[def]; if (entry != null && entry.allowScheduled && entry != null && entry.daysFrequency > 0f) { return(false); } } } if (!DRSettings.DoIfImmune && MSDrugUtility.ImmuneNow(pawn, hdef)) { return(false); } if (hdef != null && hdef.defName == "Anesthetic") { HediffSet hediffSet; if (pawn == null) { hediffSet = null; } else { Pawn_HealthTracker health = pawn.health; hediffSet = (health?.hediffSet); } HediffSet set = hediffSet; if (set != null) { Hediff Anesthetic = set.GetFirstHediffOfDef(hdef, false); if (Anesthetic != null && Anesthetic.Severity >= 0.8f) { return(false); } } } if (def.IsIngestible) { List <IngestionOutcomeDoer> ODs = def.ingestible.outcomeDoers; if (ODs.Count > 0) { bool toohighsev = false; HediffSet hediffSet2; if (pawn == null) { hediffSet2 = null; } else { Pawn_HealthTracker health2 = pawn.health; hediffSet2 = (health2?.hediffSet); } HediffSet hediffset = hediffSet2; if (hediffset != null) { foreach (IngestionOutcomeDoer OD in ODs) { if (OD is IngestionOutcomeDoer_GiveHediff) { IngestionOutcomeDoer_GiveHediff ingestionOutcomeDoer_GiveHediff = OD as IngestionOutcomeDoer_GiveHediff; HediffDef ODhediffdef = ingestionOutcomeDoer_GiveHediff?.hediffDef; if (ODhediffdef != null) { float ODSev = (OD as IngestionOutcomeDoer_GiveHediff).severity; if (ODSev > 0f) { Hediff ODhediff = hediffset.GetFirstHediffOfDef(ODhediffdef, false); if (ODhediff != null && ODhediff.Severity / ODSev > 0.75f) { toohighsev = true; } } } } } if (toohighsev) { return(false); } } } return(true); } return(false); }