예제 #1
0
        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);
                    }
                }
            }
        }
예제 #2
0
        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);
                    }
                }
            }
        }