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); } } } }
private void ApplyDamageToPart(DamageInfo dinfo, Pawn pawn, ref DamageResult result) { BodyPartRecord exactPartFromDamageInfo = this.GetExactPartFromDamageInfo(dinfo, pawn); if (exactPartFromDamageInfo != null) { dinfo.SetHitPart(exactPartFromDamageInfo); int num = dinfo.Amount; if (!dinfo.InstantOldInjury) { num = ArmorUtility.GetPostArmorDamage(pawn, dinfo.Amount, dinfo.HitPart, dinfo.Def); } if (num <= 0) { result.deflected = true; } else { if (DamageWorker_AddInjury.IsHeadshot(dinfo, pawn)) { result.headshot = true; } if (dinfo.InstantOldInjury) { HediffDef hediffDefFromDamage = HealthUtility.GetHediffDefFromDamage(dinfo.Def, pawn, dinfo.HitPart); if (hediffDefFromDamage.CompPropsFor(typeof(HediffComp_GetsOld)) == null) { return; } if (dinfo.HitPart.def.oldInjuryBaseChance == 0.0) { return; } if (dinfo.HitPart.def.IsSolid(dinfo.HitPart, pawn.health.hediffSet.hediffs)) { return; } if (pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(dinfo.HitPart)) { return; } } if (!dinfo.AllowDamagePropagation) { this.FinalizeAndAddInjury(pawn, (float)num, dinfo, ref result); } else { this.ApplySpecialEffectsToPart(pawn, (float)num, dinfo, ref result); } } } }
private void ApplyDamageToPart(DamageInfo dinfo, Pawn pawn, DamageResult result) { BodyPartRecord exactPartFromDamageInfo = GetExactPartFromDamageInfo(dinfo, pawn); if (exactPartFromDamageInfo == null) { return; } dinfo.SetHitPart(exactPartFromDamageInfo); float num = dinfo.Amount; bool num2 = !dinfo.InstantPermanentInjury && !dinfo.IgnoreArmor; bool deflectedByMetalArmor = false; if (num2) { DamageDef damageDef = dinfo.Def; num = ArmorUtility.GetPostArmorDamage(pawn, num, dinfo.ArmorPenetrationInt, dinfo.HitPart, ref damageDef, out deflectedByMetalArmor, out bool diminishedByMetalArmor); dinfo.Def = damageDef; if (num < dinfo.Amount) { result.diminished = true; result.diminishedByMetalArmor = diminishedByMetalArmor; } } if (dinfo.Def.ExternalViolenceFor(pawn)) { num *= pawn.GetStatValue(StatDefOf.IncomingDamageFactor); } if (num <= 0f) { result.AddPart(pawn, dinfo.HitPart); result.deflected = true; result.deflectedByMetalArmor = deflectedByMetalArmor; return; } if (IsHeadshot(dinfo, pawn)) { result.headshot = true; } if (!dinfo.InstantPermanentInjury || (HealthUtility.GetHediffDefFromDamage(dinfo.Def, pawn, dinfo.HitPart).CompPropsFor(typeof(HediffComp_GetsPermanent)) != null && dinfo.HitPart.def.permanentInjuryChanceFactor != 0f && !pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(dinfo.HitPart))) { if (!dinfo.AllowDamagePropagation) { FinalizeAndAddInjury(pawn, num, dinfo, result); } else { ApplySpecialEffectsToPart(pawn, num, dinfo, result); } } }