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() != 1)
                    {
                        Log.ErrorOnce(string.Format("{0} maneuvers when trying to get dps for weapon {1} tool {2} capacity {3}; average DPS explanation may be incorrect", source.Count(), thingDef.label, tool.Id, capacity.label), 40417826);
                    }
                    ManeuverDef maneuverDef = source.FirstOrDefault();
                    if (maneuverDef != null)
                    {
                        stringBuilder.AppendLine(string.Format("  Tool: {0} ({1})", tool.Id, capacity.label));
                        stringBuilder.AppendLine(string.Format("    {0} damage", tool.AdjustedMeleeDamageAmount(req.Thing, maneuverDef.verb.meleeDamageDef).ToString("F1")));
                        stringBuilder.AppendLine(string.Format("    {0} seconds per attack", tool.AdjustedCooldown(req.Thing).ToString("F2")));
                        stringBuilder.AppendLine();
                    }
                }
            }
            return(stringBuilder.ToString());
        }
Exemplo n.º 2
0
        public static bool TryGetFangsDmgInfo(HediffWithComps fangs, out string label, out float dmg, out DamageDef dDef, out RulePackDef rules)
        {
            label = "";
            dmg   = 0f;
            dDef  = null;
            rules = null;
            if (fangs != null && fangs.def.CompProps <HediffCompProperties_VerbGiver>()?
                .tools is List <Tool> tools && !tools.NullOrEmpty())
            {
                Tool            firstTool   = tools.First();
                ToolCapacityDef capacityDef = firstTool.capacities.First();
                ManeuverDef     manueverDef = DefDatabase <ManeuverDef> .AllDefs.FirstOrDefault(x => x.requiredCapacity == capacityDef);

                label = firstTool.label;
                dmg   = firstTool.power;
                dDef  = manueverDef.verb.meleeDamageDef;
                rules = manueverDef.combatLogRulesHit;
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
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());
        }
Exemplo n.º 4
0
 private static RulePackDef <TryCastShot> m__2(ManeuverDef maneuver)
 {
     return(maneuver.combatLogRulesMiss);
 }
Exemplo n.º 5
0
 private static RulePackDef <TryCastShot> m__1(ManeuverDef maneuver)
 {
     return(maneuver.combatLogRulesDodge);
 }
 private void InitVerb(Verb verb, VerbProperties properties, VerbTracker verbTracker, Tool tool, ManeuverDef maneuver, string id)
 {
     verb.loadID      = id;
     verb.verbProps   = properties;
     verb.verbTracker = verbTracker;
     verb.tool        = tool;
     verb.maneuver    = maneuver;
     verb.caster      = this;
 }