/// <summary> /// Applied before GetDescription runs. /// </summary> internal static bool Prefix(AsPercentAmountDisplayer __instance, Amount master, AmountInstance instance, ref string __result) { // The string builder was a push, but this sure beats string.Format! __result = master.Name + ": " + __instance.Formatter.GetFormattedValue( __instance.ToPercent(instance.value, instance), TimeSlice.None); return(false); }
/// <summary> /// Applied before GetTooltip runs. /// </summary> internal static bool Prefix(AsPercentAmountDisplayer __instance, Amount master, AmountInstance instance, ref string __result) { var text = CACHED_BUILDER; var formatter = __instance.Formatter; var timeSlice = formatter.DeltaTimeSlice; var modifiers = instance.deltaAttribute.Modifiers; int n = modifiers.Count; var delta = instance.deltaAttribute; text.Clear().Append(master.description).Replace("{0}", formatter. GetFormattedValue(instance.value, TimeSlice.None)).AppendLine(). AppendLine(); if (timeSlice == TimeSlice.PerCycle) { text.Append(STRINGS.UI.CHANGEPERCYCLE).Replace("{0}", formatter. GetFormattedValue(__instance.ToPercent(delta.GetTotalDisplayValue(), instance), TimeSlice.PerCycle)); } else if (timeSlice == TimeSlice.PerSecond) { text.Append(STRINGS.UI.CHANGEPERSECOND).Replace("{0}", formatter. GetFormattedValue(__instance.ToPercent(delta.GetTotalDisplayValue(), instance), TimeSlice.PerCycle)); } for (int i = 0; i < n; i++) { var modifier = modifiers[i]; text.AppendLine().Append(Constants.TABBULLETSTRING).Append(modifier. GetDescription()).Append(": ").Append(formatter.GetFormattedValue( __instance.ToPercent(delta.GetModifierContribution(modifier), instance), timeSlice)); } __result = text.ToString(); return(false); }