Example #1
0
        public static BodyPartRecord ResolvePrioritizedPart_External(BodyPartRecord part, DamageInfo dinfo, Pawn pawn)
        {
            BodyPartRecord newPart = part;

            if (dinfo.Instigator.CanUseTargetingModes(dinfo.Weapon) && dinfo.Instigator?.TryGetComp <CompTargetingMode>() != null)
            {
                CompTargetingMode targetingComp = dinfo.Instigator?.TryGetComp <CompTargetingMode>();
                TargetingModeDef  targetingMode = targetingComp.GetTargetingMode();
                if (!part.IsPrioritizedPart(targetingMode))
                {
                    newPart = RerollBodyPart(targetingMode, part, dinfo.Def, dinfo.Height, BodyPartDepth.Outside, pawn, dinfo.Instigator);
                }
            }
            return(newPart);
        }
Example #2
0
 public static void Postfix(Verb_MeleeAttack __instance, ref float __result)
 {
     if (typeof(Thing).Equals(__instance.caster))
     {
         Thing caster = __instance.caster;
         if (caster != null)
         {
             if (typeof(CompTargetingMode).Equals(caster.TryGetComp <CompTargetingMode>()))
             {
                 CompTargetingMode targetingComp = caster.TryGetComp <CompTargetingMode>();
                 if (targetingComp != null && __result == caster.GetStatValue(StatDefOf.MeleeHitChance))
                 {
                     __result *= __result * targetingComp.GetTargetingMode().HitChanceFactor;
                 }
             }
         }
     }
 }