Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WiresDecimalsBegone v0.1.0
WiresDecimalsBegone.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("WiresDecimalsBegone")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WiresDecimalsBegone")] [assembly: AssemblyTitle("WiresDecimalsBegone")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WiresDecimalsBegone { [HarmonyPatch(typeof(DamageText), "ShowText", new Type[] { typeof(TextType), typeof(Vector3), typeof(float), typeof(bool) })] internal static class FloatNumberPatch { [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(ref float dmg) { dmg = WholeNumbers.Round(dmg); } } [HarmonyPatch(typeof(DamageText), "ShowText", new Type[] { typeof(TextType), typeof(Vector3), typeof(string), typeof(bool) })] internal static class StringNumberPatch { [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(ref string text) { text = WholeNumbers.RoundLabel(text); } } [HarmonyPatch(typeof(DamageText), "AddInworldText")] internal static class IncomingNumberPatch { [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(ref string text) { text = WholeNumbers.RoundLabel(text); } } [BepInPlugin("wire.valheim.decimalsbegone", "Wire's Decimals Begone", "0.1.0")] [BepInProcess("valheim.exe")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "wire.valheim.decimalsbegone"; public const string Name = "Wire's Decimals Begone"; public const string Version = "0.1.0"; private Harmony _harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _harmony = new Harmony("wire.valheim.decimalsbegone"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wire's Decimals Begone 0.1.0 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class WholeNumbers { private static readonly Regex NumberLabel = new Regex("^(?<leading>\\s*)(?<sign>[+\\-]?)(?<value>\\d+(?:[\\.,]\\d+)?)(?<trailing>\\s*)$", RegexOptions.Compiled | RegexOptions.CultureInvariant); internal static float Round(float value) { if (float.IsNaN(value) || float.IsInfinity(value)) { return value; } return (float)Math.Round(value, 0, MidpointRounding.AwayFromZero); } internal static string RoundLabel(string text) { if (string.IsNullOrEmpty(text)) { return text; } Match match = NumberLabel.Match(text); if (!match.Success) { return text; } string value = match.Groups["value"].Value; if (value.IndexOf('.') < 0 && value.IndexOf(',') < 0) { return text; } if (!double.TryParse(value.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var result) || double.IsInfinity(result) || double.IsNaN(result)) { return text; } double num = Math.Round(result, 0, MidpointRounding.AwayFromZero); return match.Groups["leading"].Value + match.Groups["sign"].Value + num.ToString("0", CultureInfo.InvariantCulture) + match.Groups["trailing"].Value; } } }