protected float FinalizeAndAddInjury(Pawn pawn, Hediff_Injury injury, DamageInfo dinfo, ref DamageWorker.DamageResult result) { this.CalculateOldInjuryDamageThreshold(pawn, injury); pawn.health.AddHediff(injury, null, new DamageInfo?(dinfo)); float num = Mathf.Min(injury.Severity, pawn.health.hediffSet.GetPartHealth(injury.Part)); result.totalDamageDealt += num; result.wounded = true; result.AddPart(pawn, injury.Part); return(num); }
private void ApplyDamageToPart(DamageInfo dinfo, Pawn pawn, DamageWorker.DamageResult result) { BodyPartRecord exactPartFromDamageInfo = this.GetExactPartFromDamageInfo(dinfo, pawn); if (exactPartFromDamageInfo != null) { dinfo.SetHitPart(exactPartFromDamageInfo); float num = dinfo.Amount; bool flag = !dinfo.InstantPermanentInjury; bool deflectedByMetalArmor = false; if (flag) { DamageDef def = dinfo.Def; bool diminishedByMetalArmor; num = ArmorUtility.GetPostArmorDamage(pawn, num, dinfo.ArmorPenetrationInt, dinfo.HitPart, ref def, out deflectedByMetalArmor, out diminishedByMetalArmor); dinfo.Def = def; if (num < dinfo.Amount) { result.diminished = true; result.diminishedByMetalArmor = diminishedByMetalArmor; } } if (num <= 0f) { result.AddPart(pawn, dinfo.HitPart); result.deflected = true; result.deflectedByMetalArmor = deflectedByMetalArmor; } else { if (DamageWorker_AddInjury.IsHeadshot(dinfo, pawn)) { result.headshot = true; } if (dinfo.InstantPermanentInjury) { HediffDef hediffDefFromDamage = HealthUtility.GetHediffDefFromDamage(dinfo.Def, pawn, dinfo.HitPart); if (hediffDefFromDamage.CompPropsFor(typeof(HediffComp_GetsPermanent)) == null || dinfo.HitPart.def.permanentInjuryBaseChance == 0f || dinfo.HitPart.def.IsSolid(dinfo.HitPart, pawn.health.hediffSet.hediffs) || pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(dinfo.HitPart)) { return; } } if (!dinfo.AllowDamagePropagation) { this.FinalizeAndAddInjury(pawn, num, dinfo, result); } else { this.ApplySpecialEffectsToPart(pawn, num, dinfo, result); } } } }
protected float FinalizeAndAddInjury(Pawn pawn, Hediff_Injury injury, DamageInfo dinfo, DamageWorker.DamageResult result) { HediffComp_GetsPermanent hediffComp_GetsPermanent = injury.TryGetComp <HediffComp_GetsPermanent>(); if (hediffComp_GetsPermanent != null) { hediffComp_GetsPermanent.PreFinalizeInjury(); } pawn.health.AddHediff(injury, null, new DamageInfo?(dinfo), result); float num = Mathf.Min(injury.Severity, pawn.health.hediffSet.GetPartHealth(injury.Part)); result.totalDamageDealt += num; result.wounded = true; result.AddPart(pawn, injury.Part); result.AddHediff(injury); return(num); }