public static float CalculateLimbEfficiency(HediffSet diffSet, BodyPartTagDef limbCoreTag, BodyPartTagDef limbSegmentTag, BodyPartTagDef limbDigitTag, float appendageWeight, out float functionalPercentage, List <PawnCapacityUtility.CapacityImpactor> impactors)
        {
            BodyDef body = diffSet.pawn.RaceProps.body;
            float   num  = 0f;
            int     num2 = 0;
            int     num3 = 0;

            foreach (BodyPartRecord bodyPartRecord in body.GetPartsWithTag(limbCoreTag))
            {
                float num4 = PawnCapacityUtility.CalculateImmediatePartEfficiencyAndRecord(diffSet, bodyPartRecord, impactors);
                foreach (BodyPartRecord part in bodyPartRecord.GetConnectedParts(limbSegmentTag))
                {
                    num4 *= PawnCapacityUtility.CalculateImmediatePartEfficiencyAndRecord(diffSet, part, impactors);
                }
                if (bodyPartRecord.HasChildParts(limbDigitTag))
                {
                    num4 = Mathf.Lerp(num4, num4 * bodyPartRecord.GetChildParts(limbDigitTag).Average((BodyPartRecord digitPart) => PawnCapacityUtility.CalculateImmediatePartEfficiencyAndRecord(diffSet, digitPart, impactors)), appendageWeight);
                }
                num += num4;
                num2++;
                if (num4 > 0f)
                {
                    num3++;
                }
            }
            float result;

            if (num2 == 0)
            {
                functionalPercentage = 0f;
                result = 0f;
            }
            else
            {
                functionalPercentage = (float)num3 / (float)num2;
                result = num / (float)num2;
            }
            return(result);
        }