// Token: 0x06000005 RID: 5 RVA: 0x000020B4 File Offset: 0x000002B4 public override void PawnDied(Corpse corpse) { float value = (float)corpse.InnerPawn.ageTracker.AgeBiologicalYears; float value2 = (float)corpse.InnerPawn.ageTracker.AgeChronologicalYears; Name name = corpse.InnerPawn.Name; Pawn_PlayerSettings playerSettings = corpse.InnerPawn.playerSettings; Pawn_TrainingTracker training = corpse.InnerPawn.training; Pawn_HealthTracker health = corpse.InnerPawn.health; Pawn_RecordsTracker records = corpse.InnerPawn.records; Pawn_RelationsTracker relations = corpse.InnerPawn.relations; Pawn_SkillTracker skills = corpse.InnerPawn.skills; Faction faction = corpse.InnerPawn.Faction; Comp_TimeLord timeLord = corpse.InnerPawn.TryGetComp <Comp_TimeLord>(); if (timeLord != null) { if (timeLord.TimesRegenerated < 13) { int regens = timeLord.TimesRegenerated; regens++; Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(corpse.InnerPawn.kindDef, faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 0f, false, false, false, false, false, false, false, false, 0, null, 1, null, null, null)); pawn.TryGetComp <Comp_TimeLord>().TimesRegenerated = regens; GenSpawn.Spawn(pawn, corpse.Position, corpse.Map, Rot4.Random); pawn.Name = name; pawn.relations = relations; pawn.training = training; pawn.records = records; pawn.skills = skills; pawn.playerSettings = playerSettings; corpse.Destroy(0); } } }
public static bool CheckPredicateAfterAddingHediff(Pawn_HealthTracker __instance, ref bool __result, Hediff hediff, Func <bool> pred) { lock (__instance.hediffSet) //added { List <Hediff> newHediffs = new List <Hediff>(__instance.hediffSet.hediffs); //added HashSet <Hediff> missing = __instance.CalculateMissingPartHediffsFromInjury(hediff); newHediffs.Add(hediff); if (missing != null) { newHediffs.AddRange(missing); } __instance.hediffSet.hediffs = newHediffs;//added __instance.hediffSet.DirtyCache(); int num = pred() ? 1 : 0; if (missing != null) { newHediffs.RemoveAll(x => missing.Contains(x)); } newHediffs.Remove(hediff); __instance.hediffSet.hediffs = newHediffs;//added __instance.hediffSet.DirtyCache(); __result = num != 0; } return(false); }
public static void Postfix(Pawn_HealthTracker __instance) { var traverse = Traverse.Create(__instance); var pawn = traverse.Field("pawn").GetValue <Pawn>(); if (!pawn.IsWarframe()) { return; } if (!pawn.Drafted) { return; } if (!WFModBase.Instance._WFcontrolstorage.checkBeControlerExist(pawn)) { pawn.drafter.Drafted = false; } else { var bc = WFModBase.Instance._WFcontrolstorage.BeControlerAndControlCell.TryGetValue(pawn); if (!bc.HasAnyContents) { pawn.drafter.Drafted = false; } } //WFModBase.Instance._WFcontrolstorage.checkControlerExist(pawn); }
public static void Postfix(Pawn_HealthTracker __instance) { var traverse = Traverse.Create(__instance); var pawn = traverse.Field("pawn").GetValue <Pawn>(); if (pawn.kindDef.defName.EqualsIgnoreCase("ra2_yuriyuri")) { if (pawn.story == null) { return; } pawn.story.hairDef = DefDatabase <HairDef> .GetNamed("Shaved"); pawn.story.bodyType = BodyTypeDefOf.Thin; pawn.gender = Gender.Male; pawn.story.melanin = 0f; } else if (pawn.kindDef.defName.EqualsIgnoreCase("ra2_yuribrute")) { if (pawn.story == null) { return; } pawn.story.melanin = 10f; pawn.story.bodyType = BodyTypeDefOf.Hulk; } }
public static bool PreApplyDamage_PrePatch(Pawn_HealthTracker __instance, ref DamageInfo dinfo, out bool absorbed) { var pawn = (Pawn)AccessTools.Field(typeof(Pawn_HealthTracker), "pawn").GetValue(__instance); //Log.Message("Entry"); if (pawn != null && !StopPreApplyDamageCheck) { //Log.Message("0"); if (pawn?.health?.hediffSet?.hediffs != null && pawn?.health?.hediffSet?.hediffs?.Count > 0) { //Log.Message("1"); //A list will stack. var fortitudeHediffs = pawn?.health?.hediffSet?.hediffs?.FindAll(x => x.TryGetComp <HediffComp_DamageSoak>() != null); if (!fortitudeHediffs.NullOrEmpty()) { //Log.Message("2"); try { if (PreApplyDamage_ApplyDamageSoakers(ref dinfo, out absorbed, fortitudeHediffs, pawn)) { return(false); } } catch (NullReferenceException e) { } } if (dinfo.Weapon is ThingDef weaponDef && !weaponDef.IsRangedWeapon) { if (dinfo.Instigator is Pawn instigator) { try { if (PreApplyDamage_ApplyExtraDamages(out absorbed, instigator, pawn)) { return(false); } } catch (NullReferenceException e) { } try { PreApplyDamage_ApplyKnockback(instigator, pawn); } catch (NullReferenceException e) { } } } } } tempDamageAmount = (int)dinfo.Amount; absorbed = false; //Log.Message("Current Damage :" + dinfo.Amount); return(true); }
static void Postfix(Pawn_HealthTracker __instance, ref bool __result) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (!pawn.RaceProps.IsMechanoid) { return; } if (__result == true) { if (__instance.hediffSet.HasHediff(WTH_DefOf.WTH_HeavilyDamaged)) { __result = false; return; } if (Rand.Chance(Base.downedOnDeathThresholdChance.Value / 100f))//Chance mech goes down instead of dying when lethal threshold is achieved. { __instance.AddHediff(WTH_DefOf.WTH_HeavilyDamaged); if (pawn.mindState == null) { pawn.mindState = new Pawn_MindState(pawn); } __result = false; } } else { if (__instance.hediffSet.HasHediff(WTH_DefOf.WTH_HeavilyDamaged)) { __instance.RemoveHediff(__instance.hediffSet.GetFirstHediffOfDef(WTH_DefOf.WTH_HeavilyDamaged)); } } }
// Verse.Pawn_HealthTracker public static bool PreApplyDamage_PreFix(Pawn_HealthTracker __instance, DamageInfo dinfo, out bool absorbed) { Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_HealthTracker), "pawn").GetValue(__instance); if (pawn != null) { if (pawn.health.hediffSet.hediffs != null && pawn.health.hediffSet.hediffs.Count > 0) { Hediff shieldHediff = pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff x) => x.TryGetComp <HediffComp_Shield>() != null); if (shieldHediff != null) { HediffComp_Shield shield = shieldHediff.TryGetComp <HediffComp_Shield>(); if (shield != null) { if (shield.CheckPreAbsorbDamage(dinfo)) { absorbed = true; return(false); } } } } } absorbed = false; return(true); }
public static void Postfix(Pawn_HealthTracker __instance, Pawn ___pawn) { if (!__instance.Downed && ___pawn.OffHandShield() is Apparel shield) { // Not enough hands to use shields if (!___pawn.CanUseShields()) { ___pawn.apparel.TryDrop(shield, out Apparel s, ___pawn.PositionHeld); } // Cannot manipulate else if (!__instance.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { if (___pawn.kindDef.destroyGearOnDrop) { shield.Destroy(DestroyMode.Vanish); } // Taranchuk: no idea how to handle this //else if (___pawn.InContainerEnclosed) // ___pawn.equipment.TryTransferEquipmentToContainer(shield, ___pawn.holdingOwner); else if (___pawn.SpawnedOrAnyParentSpawned) { ___pawn.apparel.TryDrop(shield, out Apparel s, ___pawn.PositionHeld, true); } else { shield.Destroy(DestroyMode.Vanish); } } } }
public static bool Prefix(Pawn_HealthTracker __instance) { var traverse = Traverse.Create(__instance); var pawn = traverse.Field("pawn").GetValue <Pawn>(); return(!pawn.IsWarframe()); }
// Token: 0x06000015 RID: 21 RVA: 0x00002480 File Offset: 0x00000680 public float MSAdjustment(Pawn p, float sev, HediffGrowthMode gm) { float newSev = sev; if (gm == HediffGrowthMode.Growing) { HediffSet hediffSet; if (p == null) { hediffSet = null; } else { Pawn_HealthTracker health = p.health; hediffSet = (health?.hediffSet); } HediffSet hSet = hediffSet; if (hSet != null) { HediffDef drugDef = DefDatabase <HediffDef> .GetNamed("MSVinacol_High", false); if (drugDef != null && hSet.GetFirstHediffOfDef(drugDef, false) != null) { newSev *= Rand.Range(0f, 0.1f); } } } return(newSev); }
private static void Pawn_HealthTracker_PreApplyDamagePostfix(Pawn_HealthTracker __instance, DamageInfo dinfo) { if (dinfo.Instigator != null && VEF_ReflectionData.FI_Pawn_HealthTracker_pawn.GetValue(__instance) is Pawn pawn) { foreach (Hediff hediff in pawn.health.hediffSet.hediffs) { if (hediff.TryGetComp <VEF_HediffComp_SmokepopDefense>() != null) { hediff.TryGetComp <VEF_HediffComp_SmokepopDefense>().TryTriggerSmokepopDefense(dinfo); } if (VEF_ModCompatibilityCheck.enabled_SmokepopDefenseFramework) { try { ((Action)(() => { if (hediff.TryGetComp <SmokepopCompFramework.SCF_HediffComp_SmokepopDefense>() != null) { hediff.TryGetComp <SmokepopCompFramework.SCF_HediffComp_SmokepopDefense>().TryTriggerSmokepopDefense(dinfo); } }))(); } catch (TypeLoadException ex) { } } } } return; }
// Token: 0x06000050 RID: 80 RVA: 0x000054F0 File Offset: 0x000036F0 private static bool ImmuneNow(Pawn pawn, HediffDef chkhdef) { if (pawn != null && chkhdef != null) { HediffSet hediffSet; if (pawn == null) { hediffSet = null; } else { Pawn_HealthTracker health = pawn.health; hediffSet = (health?.hediffSet); } HediffSet set = hediffSet; if (set != null) { Hediff chk = set.GetFirstHediffOfDef(chkhdef, false); if (chk != null && HediffUtility.FullyImmune(chk)) { return(true); } } } return(false); }
public override void OnIntervalPassed(Pawn pawn, Hediff cause) { foreach (PartStateRule rule in rules) { Pawn_HealthTracker pawnHealth = pawn.health; float partEfficiency = PawnCapacityUtility.CalculateTagEfficiency(pawnHealth.hediffSet, rule.tag); float severity = rule.curve.Evaluate(partEfficiency); Hediff hediff = pawnHealth.hediffSet.GetFirstHediffOfDef(rule.hediff); if (hediff == null) { if (severity == 0f) { continue; } hediff = HediffMaker.MakeHediff(rule.hediff, pawn, null); pawnHealth.AddHediff(hediff); } if (rule.mode != PartStateMode.AddRemove || severity == 0f) { hediff.Severity = severity; } } }
public PawnHealth(Pawn p, Pawn_HealthTracker h, Settings settings) { foreach (Hediff hd in h.hediffSet.hediffs) { hediffs.Add(new HediffData(hd)); } }
public static void PostFix(ref Pawn_HealthTracker __instance, ref Hediff __result, ref Pawn ___pawn, HediffDef def, BodyPartRecord part = null, DamageInfo?dinfo = null, DamageWorker.DamageResult result = null) { if (!Controller.Settings.DoAilments || GenDate.DaysPassed < Controller.Settings.CAStartDays || __result == null || Controller.Settings.CAChance <= 0 || ___pawn == null || part == null || !CommonAilments.PawnCanAcceptCA(___pawn) || def?.addedPartProps == null || !def.addedPartProps.solid) { return; } var offset = CommonAilmentsUtility.AugmentOffset(___pawn); if (!CommonAilments.CanAddCA(Math.Max(12, Controller.Settings.CAChance * 2), offset)) { return; } var hdef = DefDatabase <HediffDef> .GetNamed("CA_PhantomPain", false); if (hdef == null) { return; } var sev = CommonAilmentsUtility.RandNum(0.5f, 3f); if (CommonAilmentsUtility.HediffEffect(hdef, sev, ___pawn, part, out _)) { CommonAilments.SendCAMsg(___pawn, hdef); } }
public static bool Patch_ShouldBeDeadFromRequiredCapacity(ref Pawn_HealthTracker __instance, ref PawnCapacityDef __result) { // Check if consciousness is there. If it is then its okay. Pawn_HealthTracker health = __instance; Pawn pawn = health.hediffSet.pawn; if (!health.hediffSet.HasHediff(LifeSupportDefOf.QE_LifeSupport)) { // not on life support return(true); } else if (!pawn.ValidLifeSupportNearby()) { // life support is unpowered return(true); } else if (!health.capacities.CapableOf(PawnCapacityDefOf.Consciousness)) { // no consciousness return(true); } __result = null; return(false); }
// Token: 0x06000070 RID: 112 RVA: 0x00006B18 File Offset: 0x00004D18 private static bool RelativeHealthOk(Pawn pawn) { if (pawn != null) { Pawn_HealthTracker health = pawn.health; bool flag; if (health == null) { flag = false; } else { SummaryHealthHandler summaryHealth = health.summaryHealth; if (summaryHealth == null) { flag = false; } else { _ = summaryHealth.SummaryHealthPercent; flag = true; } } if (flag && pawn.health.summaryHealth.SummaryHealthPercent >= 0.75f) { return(true); } } return(false); }
// Token: 0x0600004D RID: 77 RVA: 0x000043D8 File Offset: 0x000025D8 public static bool CompatPatch_ShouldBeDeadFromRequiredCapacity(ref Pawn_HealthTracker __instance, ref PawnCapacityDef __result) { Pawn pawn = HarmonyPatches.Pawn_HealthTracker_GetPawn(__instance); bool flag = pawn.def.HasModExtension <MechanicalPawnProperties>(); bool result; if (flag) { List <PawnCapacityDef> allDefsListForReading = DefDatabase <PawnCapacityDef> .AllDefsListForReading; for (int i = 0; i < allDefsListForReading.Count; i++) { PawnCapacityDef pawnCapacityDef = allDefsListForReading[i]; bool flag2 = allDefsListForReading[i] == PawnCapacityDefOf.Consciousness && !__instance.capacities.CapableOf(pawnCapacityDef); if (flag2) { __result = pawnCapacityDef; return(false); } } __result = null; result = false; } else { result = true; } return(result); }
public static bool IsDownedOrIncapable(this Pawn pawn) { if (pawn.Downed) { return(true); } PawnCapacitiesHandler pawnCapacitiesHandler; if (pawn == null) { pawnCapacitiesHandler = null; } else { Pawn_HealthTracker health = pawn.health; pawnCapacitiesHandler = ((health != null) ? health.capacities : null); } PawnCapacitiesHandler pawnCapacitiesHandler2 = pawnCapacitiesHandler; if (pawnCapacitiesHandler2 == null) { return(true); } if (pawnCapacitiesHandler2.GetLevel(PawnCapacityDefOf.Consciousness) < 0.1f) { return(true); } if (pawnCapacitiesHandler2.GetLevel(PawnCapacityDefOf.Moving) < 0.1f) { return(true); } return(false); }
private void TryFillQuota() { BodyParts = new List <BodyPartRecord>(); if (Surgery?.Worker == null || Surgery.addsHediff == null) { return; } Pawn_HealthTracker pHealth = Patient.health; foreach (BodyPartRecord part in Surgery.Worker.GetPartsToApplyOn(Patient, Surgery)) { if (pHealth.surgeryBills.Bills.Any(b => b is Bill_Medical bill && bill.Part == part && bill.recipe == Surgery)) { continue; } if (pHealth.hediffSet.hediffs.Where(h => h.def.defName == Surgery.addsHediff.defName).Any(h => h.Part == part)) { continue; } BodyParts.Add(part); } BodyParts.SortBy(part => HealHelper.GetAverageHealthOfPart(Patient, part)); BodyParts = BodyParts.Take(Quantity).ToList(); }
// Token: 0x06000066 RID: 102 RVA: 0x00006030 File Offset: 0x00004230 internal static bool HasHediff(Pawn pawn, HediffDef def) { Pawn_HealthTracker health = pawn.health; HediffSet HS = health?.hediffSet; return(HS != null && HS.GetFirstHediffOfDef(def, false) != null); }
public static void Postfix(Pawn_HealthTracker __instance) { var traverse = Traverse.Create(__instance); var pp = traverse.Field("pawn").GetValue <Pawn>(); if (!pp.IsWarframe()) { return; } if (!pp.Spawned) { return; } if (!WarframeStaticMethods.PawnInControlCell(pp)) { var job = new Job(DefDatabase <JobDef> .GetNamed("WFWait")); pp.jobs.TryTakeOrderedJob(job, JobTag.Misc); } else { if (pp.jobs.curJob.def == DefDatabase <JobDef> .GetNamed("WFWait")) { pp.jobs.EndCurrentJob(JobCondition.None); } } }
static void Postfix(Pawn_HealthTracker __instance, DamageInfo dinfo, float totalDamageDealt) { MutationBloodHealerDef def = dinfo.WeaponLinkedHediff as MutationBloodHealerDef; if (def == null) { return; } Pawn pawn = dinfo.Instigator as Pawn; if (pawn == null) { return; } Pawn target = __instance.hediffSet.pawn; if (target?.RaceProps == null || !target.RaceProps.IsFlesh) { return; } def.Heal(pawn, target, dinfo, totalDamageDealt); }
static void Postfix(Pawn_HealthTracker __instance) { if (Multiplayer.Client != null) { Multiplayer.WorldComp.DirtyColonyTradeForMap(__instance.pawn.Map); } }
// Verse.Pawn_HealthTracker public static bool PreApplyDamage_PreFix(Pawn_HealthTracker __instance, DamageInfo dinfo, out bool absorbed) { var pawn = (Pawn)AccessTools.Field(typeof(Pawn_HealthTracker), "pawn").GetValue(__instance); if (pawn != null) { if (pawn.health.hediffSet.hediffs is { Count : > 0 })
private static void Postfix(Pawn_HealthTracker __instance, Pawn ___pawn, DamageInfo?dinfo, Hediff hediff) { if (dinfo != null && ___pawn.health.hediffSet.GetNotMissingParts() .Where(x => x.def == BodyPartDefOf.Neck).Count() == 0) { Hediff stackHediff = ___pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff x) => x.def == AlteredCarbonDefOf.AC_CorticalStack); Random random = new Random(); if (stackHediff != null) { if (random.Next(0, 100) <= 25) { if (stackHediff.def.spawnThingOnRemoved != null) { Notify_ColonistKilled_Patch.DisableKilledEffect = true; var corticalStack = ThingMaker.MakeThing(stackHediff.def.spawnThingOnRemoved) as CorticalStack; corticalStack.SavePawnToCorticalStack(___pawn); GenPlace.TryPlaceThing(corticalStack, ___pawn.Position, ___pawn.Map, ThingPlaceMode.Near); } ___pawn.health.RemoveHediff(stackHediff); } if (!___pawn.Dead) { ___pawn.Kill(null); Notify_ColonistKilled_Patch.DisableKilledEffect = false; } } } }
public static bool AddCustomHediffs(Pawn_HealthTracker tracker, Pawn pawn, PawnCapacityDef pawnCapacityDef) { if (pawn.health.hediffSet.GetBrain() == null) { return(false); } if (pawn.RaceProps.IsFlesh && pawnCapacityDef.lethalFlesh && !tracker.capacities.CapableOf(pawnCapacityDef) && ailmentDictionary.ContainsKey(pawnCapacityDef.defName)) { HediffDef def = ailmentDictionary[pawnCapacityDef.defName]; if (def == null) { if ((pawn.health.hediffSet.GetNotMissingParts(depth: BodyPartDepth.Inside).FirstOrDefault(p => p.def.defName == "Liver") == null) && !pawn.health.hediffSet.HasHediff(HediffDefOfDeathRattle.LiverFailure)) { def = HediffDefOfDeathRattle.LiverFailure; } else if (pawn.health.hediffSet.GetNotMissingParts(depth: BodyPartDepth.Inside).FirstOrDefault(p => p.def.defName.Contains("Kidney")) == null) { def = HediffDefOfDeathRattle.KidneyFailure; } } if (def != null && !pawn.health.hediffSet.HasHediff(def)) { Hediff_DeathRattle ailment = HediffMaker.MakeHediff(def, pawn) as Hediff_DeathRattle; ailment.cause = pawnCapacityDef; pawn.health.AddHediff(ailment); } return(true); } return(false); }
private void ResolveSeverityChange() { List <Hediff> list = new List <Hediff>(); List <Hediff> arg_32_0 = list; Pawn pawn = this.Pawn; IEnumerable <Hediff> arg_32_1; if (pawn == null) { arg_32_1 = null; } else { Pawn_HealthTracker expr_1A = pawn.health; if (expr_1A == null) { arg_32_1 = null; } else { HediffSet expr_26 = expr_1A.hediffSet; arg_32_1 = (expr_26 != null) ? expr_26.hediffs : null; } } arg_32_0.AddRange(arg_32_1); Pawn expr_3E = this.Pawn; int? arg_84_0; if (expr_3E == null) { arg_84_0 = null; } else { Pawn_HealthTracker expr_52 = expr_3E.health; if (expr_52 == null) { arg_84_0 = null; } else { HediffSet expr_66 = expr_52.hediffSet; arg_84_0 = (expr_66 != null) ? new int?(expr_66.hediffs.Count <Hediff>()) : null; } } bool flag = (arg_84_0 ?? 0) > 0; if (flag) { foreach (Hediff current in list) { if (current.def.defName == "TM_HediffShield") { SevChange = lastSev - current.Severity; lastSev = current.Severity; } } } list.Clear(); }
static bool Prefix(Pawn_HealthTracker __instance, ref Pawn ___pawn) { if (___pawn.RaceProps.IsMechanoid && ___pawn.IsHacked()) { return(false); } return(true); }