示例#1
0
        public static int GetPostArmorDamage(Pawn pawn, int amountInt, BodyPartRecord part, DamageDef damageDef)
        {
            float num = (float)amountInt;

            if (damageDef.armorCategory == null)
            {
                return(amountInt);
            }
            StatDef deflectionStat = damageDef.armorCategory.deflectionStat;

            if (pawn.apparel != null)
            {
                List <Apparel> wornApparel = pawn.apparel.WornApparel;
                for (int i = 0; i < wornApparel.Count; i++)
                {
                    Apparel apparel = wornApparel[i];
                    if (apparel.def.apparel.CoversBodyPart(part))
                    {
                        ArmorUtility.ApplyArmor(ref num, apparel.GetStatValue(deflectionStat, true), apparel, damageDef);
                        if (num < 0.001f)
                        {
                            return(0);
                        }
                    }
                }
            }
            ArmorUtility.ApplyArmor(ref num, pawn.GetStatValue(deflectionStat, true), null, damageDef);
            return(GenMath.RoundRandom(num));
        }
示例#2
0
        public static float GetPostArmorDamage(Pawn pawn, float amount, float armorPenetration, BodyPartRecord part, ref DamageDef damageDef, out bool deflectedByMetalArmor, out bool diminishedByMetalArmor)
        {
            deflectedByMetalArmor  = false;
            diminishedByMetalArmor = false;
            float result;

            if (damageDef.armorCategory == null)
            {
                result = amount;
            }
            else
            {
                StatDef armorRatingStat = damageDef.armorCategory.armorRatingStat;
                if (pawn.apparel != null)
                {
                    List <Apparel> wornApparel = pawn.apparel.WornApparel;
                    for (int i = wornApparel.Count - 1; i >= 0; i--)
                    {
                        Apparel apparel = wornApparel[i];
                        if (apparel.def.apparel.CoversBodyPart(part))
                        {
                            float num = amount;
                            bool  flag;
                            ArmorUtility.ApplyArmor(ref amount, armorPenetration, apparel.GetStatValue(armorRatingStat, true), apparel, ref damageDef, pawn, out flag);
                            if (amount < 0.001f)
                            {
                                deflectedByMetalArmor = flag;
                                return(0f);
                            }
                            if (amount < num && flag)
                            {
                                diminishedByMetalArmor = true;
                            }
                        }
                    }
                }
                float num2 = amount;
                bool  flag2;
                ArmorUtility.ApplyArmor(ref amount, armorPenetration, pawn.GetStatValue(armorRatingStat, true), null, ref damageDef, pawn, out flag2);
                if (amount < 0.001f)
                {
                    deflectedByMetalArmor = flag2;
                    result = 0f;
                }
                else
                {
                    if (amount < num2 && flag2)
                    {
                        diminishedByMetalArmor = true;
                    }
                    result = amount;
                }
            }
            return(result);
        }