/// <summary> /// Returns a string that provides a breakdown of both accuracy and DPS over the full range of the given weapon. /// Shooter is optional, and if provided the DPS is adjusted to account for the shooter's shooting accuracy. /// </summary> /// <returns>A string providing a breakdown of the performance of the given weapon at various ranges.</returns> /// <param name="gun">The gun to caluclate a breakdown for.</param> /// <param name="shooter">(Optional) The shooter (pawn or turret) using the weapon.</param> protected static string DPSRangeBreakdown(RangedWeaponStats gun, Thing shooter = null) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("StatsReport_RangedDPSAccuracy".Translate()); // Min Range float minRange = Math.Max(gun.MinRange, 1f); float minRangeHitChance = gun.GetAdjustedHitChanceFactor(minRange, shooter); float minRangeDps = gun.GetAdjustedDPS(minRange, shooter); stringBuilder.AppendLine(FormatDPSRangeString(minRange, minRangeDps, minRangeHitChance)); // Ranges between Min - Max, in steps of 5 float startRange = (float)Math.Ceiling(minRange / 5) * 5; for (float range = startRange; range < gun.MaxRange; range += 5) { float hitChance = gun.GetAdjustedHitChanceFactor(range, shooter); float dps = gun.GetAdjustedDPS(range, shooter); stringBuilder.AppendLine(FormatDPSRangeString(range, dps, hitChance)); } // Max Range float maxRangeHitChance = gun.GetAdjustedHitChanceFactor(gun.MaxRange, shooter); float maxRangeDps = gun.GetAdjustedDPS(gun.MaxRange, shooter); stringBuilder.AppendLine(FormatDPSRangeString(gun.MaxRange, maxRangeDps, maxRangeHitChance)); return(stringBuilder.ToString()); }