private float ApplyToPawn(DamageInfo dinfo, Pawn pawn)
        {
            if (dinfo.Amount <= 0)
            {
                return(0f);
            }
            if (!DebugSettings.enablePlayerDamage && pawn.Faction == Faction.OfPlayer)
            {
                return(0f);
            }
            LocalInjuryResult localInjuryResult = LocalInjuryResult.MakeNew();
            Map mapHeld = pawn.MapHeld;

            if (dinfo.Def.spreadOut)
            {
                if (pawn.apparel != null)
                {
                    List <Apparel> wornApparel = pawn.apparel.WornApparel;
                    for (int i = wornApparel.Count - 1; i >= 0; i--)
                    {
                        CheckApplySpreadDamage(dinfo, wornApparel[i]);
                    }
                }
                if (pawn.equipment != null && pawn.equipment.Primary != null)
                {
                    CheckApplySpreadDamage(dinfo, pawn.equipment.Primary);
                }
                if (pawn.inventory != null)
                {
                    ThingContainer innerContainer = pawn.inventory.innerContainer;
                    for (int j = innerContainer.Count - 1; j >= 0; j--)
                    {
                        this.CheckApplySpreadDamage(dinfo, innerContainer[j]);
                    }
                }
            }
            if (!FragmentDamageForDamageType(dinfo, pawn, ref localInjuryResult))
            {
                ApplyDamagePartial(dinfo, pawn, ref localInjuryResult);
                CheckDuplicateSmallPawnDamageToPartParent(dinfo, pawn, ref localInjuryResult);
            }
            if (localInjuryResult.wounded)
            {
                PlayWoundedVoiceSound(dinfo, pawn);
                pawn.Drawer.Notify_DamageApplied(dinfo);
                InformPsychology(dinfo, pawn);
            }
            if (localInjuryResult.headshot && pawn.Spawned)
            {
                MoteMaker.ThrowText(new Vector3((float)pawn.Position.x + 1f, (float)pawn.Position.y, (float)pawn.Position.z + 1f), pawn.Map, "Headshot".Translate(), Color.white, -1);
                if (dinfo.Instigator != null)
                {
                    Pawn pawn2 = dinfo.Instigator as Pawn;
                    if (pawn2 != null)
                    {
                        pawn2.records.Increment(RecordDefOf.Headshots);
                    }
                }
            }
            if (localInjuryResult.absorbed && pawn.Spawned)
            {
                if (pawn.health.deflectionEffecter == null)
                {
                    pawn.health.deflectionEffecter = EffecterDef.Named("ArmorRating").Spawn();
                }
                pawn.health.deflectionEffecter.Trigger(pawn, pawn);
            }
            else if (mapHeld != null)
            {
                ImpactSoundUtility.PlayImpactSound(pawn, dinfo.Def.impactSoundType, mapHeld);
            }
            return(localInjuryResult.totalDamageDealt);
        }
        private float ApplyToPawn(DamageInfo dinfo, Pawn pawn)
        {
            //Sanity checks
            if (dinfo.Amount <= 0)
            {
                return(0f);
            }
            if (!DebugSettings.enablePlayerDamage && pawn.Faction == Faction.OfColony)
            {
                return(0f);
            }
            if (!dinfo.Part.HasValue)
            {
                dinfo.SetPart(new BodyPartDamageInfo(null, null));
            }

            DamageWorker_AddInjuryCR.LocalInjuryResult localInjuryResult = DamageWorker_AddInjuryCR.LocalInjuryResult.MakeNew();

            //Code for damage sources which spread out
            if (dinfo.Def.spreadOut)
            {
                if (pawn.apparel != null)
                {
                    List <Apparel> wornApparel = pawn.apparel.WornApparel;
                    for (int i = wornApparel.Count - 1; i >= 0; i--)
                    {
                        this.CheckApplySpreadDamage(dinfo, wornApparel[i]);
                    }
                }
                if (pawn.equipment != null && pawn.equipment.Primary != null)
                {
                    this.CheckApplySpreadDamage(dinfo, pawn.equipment.Primary);
                }
                if (pawn.inventory != null)
                {
                    ThingContainer container = pawn.inventory.container;
                    for (int j = container.Count - 1; j >= 0; j--)
                    {
                        this.CheckApplySpreadDamage(dinfo, container[j]);
                    }
                }
            }
            if (!this.FragmentDamageForDamageType(dinfo, pawn, ref localInjuryResult))
            {
                this.ApplyDamagePartial(dinfo, pawn, ref localInjuryResult);
                this.CheckDuplicateSmallPawnDamageToPartParent(dinfo, pawn, ref localInjuryResult);
            }
            if (localInjuryResult.wounded)
            {
                DamageWorker_AddInjuryCR.PlayWoundedVoiceSound(dinfo, pawn);
                pawn.drawer.Notify_DamageApplied(dinfo);
                DamageWorker_AddInjuryCR.InformPsychology(dinfo, pawn);
            }
            if (localInjuryResult.headshot && pawn.SpawnedInWorld)
            {
                MoteThrower.ThrowText(new Vector3((float)pawn.Position.x + 1f, (float)pawn.Position.y, (float)pawn.Position.z + 1f), "Headshot".Translate(), Color.white, -1);
            }
            if (localInjuryResult.deflected)
            {
                if (pawn.health.deflectionEffecter == null)
                {
                    pawn.health.deflectionEffecter = EffecterDef.Named("ArmorRating").Spawn();
                }
                pawn.health.deflectionEffecter.Trigger(pawn, pawn);
            }
            else
            {
                ImpactSoundUtility.PlayImpactSound(pawn, dinfo.Def.impactSoundType);
            }
            return(localInjuryResult.totalDamageDealt);
        }