NQualityOfLife.Utils.Common.FormatAsString - Niilo007/RimWorld-NQoL GitHub Wiki
public static string FormatAsString<T>(this List<T> list, FormatMode formatMode, DisplayMode displayMode = DisplayMode.Default, Func<T, string> specialFormatter = null, Func<T, string> specialSuffixMaker = null)
{
}
public static string FormatAsString<K, V>(this Dictionary<K, V> list, FormatMode formatMode, DisplayMode displayMode = DisplayMode.Default)
{
}
public static string FormatAsString<T>(this IEnumerable<T> list, FormatMode formatMode, DisplayMode displayMode = DisplayMode.Default, Func<T, string> specialFormatter = null, Func<T, string> specialSuffix = null)
{
}
Formats the given list into a string according to the provided parameters.
//[HarmonyPatch(typeof(RimWorld.SurgeryOutcomeEffectDef), nameof(RimWorld.SurgeryOutcomeEffectDef.GetOutcome), MethodType.Normal)]
//internal class SurgerySuccessInfo_Patch_1 : HarmonyPatch
//{
// public static string report_Quality;
// [HarmonyPrefix]
// [JetBrains.Annotations.UsedImplicitly]
// internal static void Prefix(RecipeDef recipe, Pawn surgeon, Pawn patient, List<Thing> ingredients, BodyPartRecord part, Bill bill)
// {
// try
// {
// float quality = recipe.surgeryOutcomeEffect.GetQuality(recipe, surgeon, patient, ingredients, part, bill);
string MakeSpecialSuffix(SurgeryOutcomeComp comp)
{
if (!comp.Affects(recipe, surgeon, patient, part)) { return string.Concat(": ", "NA".Translate()); }
float affect = 1f;
comp.AffectQuality(recipe, surgeon, patient, ingredients, part, bill, ref affect);
float delta = affect - 1f;
if (delta < 0)
{
return string.Concat($": {Utils.Log.Colors.Color_False_Tag}-</color>", (Math.Abs(delta)).RatioToColoredPercentage(true, alwaysGoodOrBadAbove: -0.01f));
}
else
{
return string.Concat($": {Utils.Log.Colors.Color_True_Tag}+</color>", (Math.Abs(delta)).RatioToColoredPercentage(false, alwaysGoodOrBadAbove: -0.01f));
}
}
string SpecialFormatter(SurgeryOutcomeComp comp)
{
string stringAfterDot = comp.OrNull().SubstringAfter('.');
return stringAfterDot.OrNull(null)?.TranslateOr(stringAfterDot.SubstringAfter('_').OrNull(stringAfterDot) ?? null).OrNull(comp);
}
report_Quality = string.Concat(
$"\n", "NQoL_Surgery_Quality".Translate(), $"'{quality.RatioToColoredPercentage()}'\n", "NQoL_Surgery_Quality_Factors".Translate(),
$"\n{recipe.surgeryOutcomeEffect.comps.FormatAsString(
Common.FormatMode.VerticalWithLines,
specialFormatter: (comp) => SpecialFormatter(comp),
specialSuffixMaker: (comp) => MakeSpecialSuffix(comp)
)}"
);
// }
// catch (Exception e)
// {
// Utils.Log.Error(e, $"({recipe.AsParam()}, {surgeon.AsParam(nameof(surgeon))}, {patient.AsParam(nameof(patient))}, {ingredients.AsParam()}, //{part.AsParam()}, {bill.AsParam()})");
// report_Quality = e.ExceptionInfo();
// }
// }
//}