示例#1
0
        public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            StringBuilder stringBuilder = new StringBuilder();
            ThingDef      thingDef      = req.Def as ThingDef;

            for (int i = 0; i < thingDef.tools.Count; i++)
            {
                Tool tool = thingDef.tools[i];
                for (int j = 0; j < tool.capacities.Count; j++)
                {
                    ToolCapacityDef           capacity = tool.capacities[j];
                    IEnumerable <ManeuverDef> source   = from maneuver in DefDatabase <ManeuverDef> .AllDefsListForReading
                                                         where maneuver.requiredCapacity == capacity
                                                         select maneuver;
                    if (source.Count <ManeuverDef>() != 1)
                    {
                        Log.ErrorOnce(string.Format("{0} maneuvers when trying to get armor penetration for weapon {1} tool {2} capacity {3}; average armor penetration explanation may be incorrect", new object[]
                        {
                            source.Count <ManeuverDef>(),
                            thingDef.label,
                            tool.Id,
                            capacity.defName
                        }), 40417826, false);
                    }
                    ManeuverDef maneuverDef = source.FirstOrDefault <ManeuverDef>();
                    if (maneuverDef != null)
                    {
                        float num = tool.armorPenetration;
                        if (num < 0f)
                        {
                            num = tool.AdjustedBaseMeleeDamageAmount(req.Thing, maneuverDef.verb.meleeDamageDef) * 0.015f;
                        }
                        stringBuilder.AppendLine(string.Format("  {0}: {1} ({2})", "Tool".Translate(), tool.LabelCap, capacity.defName));
                        stringBuilder.AppendLine("    " + num.ToStringPercent());
                        stringBuilder.AppendLine();
                    }
                }
            }
            return(stringBuilder.ToString());
        }