public override void TransformValue(StatRequest req, ref float val)
 {
     if (req.HasThing)
     {
         Thing thing        = req.Thing as Apparel;
         float armorPenalty = 0f;
         foreach (ArmorFactor factor in armorFactors)
         {
             armorPenalty += thing.GetStatValue(factor.armorType) * factor.weight;
         }
         float weightPenalty = thing.GetStatValue(StatDefOf.Mass);
         if (val == 0f)
         {
             val = armorPenalty * weightPenalty;
         }
         else
         {
             val *= armorPenalty * weightPenalty;
         }
         List <BodyPartGroupDef> allBodyParts = thing.def.apparel.bodyPartGroups;
         float baseDiscomfort = 0f;
         for (int i = 0; i < allBodyParts.Count; i++)
         {
             BodyPartGroupDef bodyPart = allBodyParts[i];
             baseDiscomfort += bodyPart.GetModExtension <ApparelDiscomfortExtension>().baseDiscomfort;
         }
         val *= baseDiscomfort;
     }
 }
        public override string ExplanationPart(StatRequest req)
        {
            StringBuilder explanation = new StringBuilder();

            explanation.AppendLine("AIU_DiscomfortExplanation1".Translate());
            if (req.HasThing)
            {
                Thing thing = req.Thing;
                List <BodyPartGroupDef> allBodyParts = thing.def.apparel.bodyPartGroups;
                float sizeFactor = 0f;
                explanation.AppendLine();
                explanation.AppendLine("AIU_DiscomfortExplanation2".Translate());
                for (int i = 0; i < allBodyParts.Count; i++)
                {
                    BodyPartGroupDef bodyPart = allBodyParts[i];
                    sizeFactor += bodyPart.GetModExtension <ApparelDiscomfortExtension>().baseDiscomfort;
                    explanation.AppendLine("   " + bodyPart.label + ": +" + bodyPart.GetModExtension <ApparelDiscomfortExtension>().baseDiscomfort.ToStringByStyle(ToStringStyle.FloatTwo));
                }
                explanation.AppendLine();
                explanation.AppendLine("AIUDiscomfortExplanation4".Translate());
                for (int i = 0; i < armorFactors.Count; i++)
                {
                    if (i == 0)
                    {
                        explanation.AppendLine("   (" + armorFactors[i].armorType.label + ": " + thing.GetStatValue(armorFactors[i].armorType).ToStringPercent() + " x " + armorFactors[i].weight.ToStringByStyle(ToStringStyle.FloatTwoOrThree) + ")");
                    }
                    else
                    {
                        explanation.Append("+ (" + armorFactors[i].armorType.label + ": " + thing.GetStatValue(armorFactors[i].armorType).ToStringPercent() + " x " + armorFactors[i].weight.ToStringByStyle(ToStringStyle.FloatTwoOrThree) + ")");
                    }
                }
                explanation.AppendLine();
                float armorFactor = 0f;
                foreach (ArmorFactor factor in armorFactors)
                {
                    armorFactor += thing.GetStatValue(factor.armorType) * factor.weight;
                }
                explanation.AppendLine();
                explanation.AppendLine("AIUDiscomfortExplanation5".Translate());
                explanation.AppendLine("   " + thing.GetStatValue(StatDefOf.Mass).ToStringByStyle(ToStringStyle.FloatTwo));
                explanation.AppendLine();
                explanation.AppendLine("AIUDiscomfortExplanation6".Translate());
                explanation.AppendLine("x(" + sizeFactor.ToStringByStyle(ToStringStyle.FloatTwo) + " x " + armorFactor.ToStringByStyle(ToStringStyle.PercentZero) + " x " + thing.GetStatValue(StatDefOf.Mass).ToStringByStyle(ToStringStyle.FloatTwo) + " = " + (sizeFactor * armorFactor * thing.GetStatValue(StatDefOf.Mass)).ToStringByStyle(ToStringStyle.FloatTwoOrThree) + ")");
            }
            return(explanation.ToString());
        }