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 MkPovCompatibility v0.0.1
MkPovCompatibility/MkPovCompatibility.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Valheiman.Api; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("MkPovCompatibility")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyInformationalVersion("0.0.1")] [assembly: AssemblyProduct("MkPovCompatibility")] [assembly: AssemblyTitle("MkPovCompatibility")] [assembly: AssemblyVersion("0.0.1.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 MarketplacePoVCompat { [BepInPlugin("marlthon.marketplacepovcompat", "MkPoV Compatibility", "0.0.1")] [BepInDependency("MarketplaceAndServerNPCs", "10.0.8")] [BepInDependency("treextr.pathofvalheiman", "5.3.6")] public sealed class Plugin : BaseUnityPlugin { public const string PluginId = "marlthon.marketplacepovcompat"; private Harmony harmony; internal static ManualLogSource Log; private static bool reportedFailure; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("marlthon.marketplacepovcompat"); try { harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"PoV item descriptions enabled for Marketplace tooltips (built against Marketplace 10.0.8 / PoV 5.3.6)."); } catch (Exception ex) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)("Could not enable Marketplace PoV compatibility: " + ex)); } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } internal static void ReportFailure(Exception error) { if (!reportedFailure) { reportedFailure = true; Log.LogError((object)("Could not describe a PoV item; keeping its original Marketplace tooltip. " + error)); } } } [HarmonyPatch] internal static class MarketplaceTooltipPatch { internal sealed class Capture { internal ItemData Item; } private static MethodBase TargetMethod() { Type type = Type.GetType("Marketplace.Utils, kg.Marketplace", throwOnError: true); MethodInfo methodInfo = AccessTools.Method(type, "GetItemForTooltip", new Type[9] { typeof(string), typeof(int), typeof(int), typeof(int), typeof(long), typeof(string), typeof(string), typeof(byte), typeof(Action<ItemData>) }, (Type[])null); if (methodInfo == null || !methodInfo.IsStatic || methodInfo.ReturnType != typeof(string)) { throw new MissingMethodException("Unsupported Marketplace GetItemForTooltip signature."); } return methodInfo; } private static void Prefix(ref Action<ItemData> callback, out Capture __state) { Capture capture = new Capture(); __state = capture; Action<ItemData> original = callback; callback = delegate(ItemData item) { capture.Item = item; original?.Invoke(item); }; } private static void Postfix(Capture __state, ref string __result) { if (__state?.Item == null) { return; } try { string text = PovDescription.Create(__state.Item); if (text.Length != 0) { __result = __result + "\n\n" + text; } } catch (Exception error) { Plugin.ReportFailure(error); } } } internal static class PovDescription { private static readonly Regex LinkTags = new Regex("</?link\\b[^>]*>", RegexOptions.IgnoreCase); internal static string Create(ItemData item) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) bool flag = Items.IsIdentified(item); int num = Items.ItemLevel(item); StringBuilder stringBuilder = new StringBuilder(); string value = ""; if (flag) { IReadOnlyList<AffixRow> rows = default(IReadOnlyList<AffixRow>); value = Tooltip.Describe(item, ref rows); AppendRows(stringBuilder, Tooltip.Implicits(item)); AppendRows(stringBuilder, rows); } else { stringBuilder.Append('\n').Append(Texts.Get("ui.item.unidentified", "Unidentified")); } if (stringBuilder.Length == 0 && num <= 0) { return ""; } StringBuilder stringBuilder2 = new StringBuilder("<color=#E6C77A>Path of Valheim</color>"); string value2 = Items.RarityTitle(Items.RarityOf(item)); if (!string.IsNullOrWhiteSpace(value2)) { stringBuilder2.Append("\n").Append(value2); } if (!string.IsNullOrWhiteSpace(value)) { stringBuilder2.Append("\n").Append(value); } if (num > 0) { stringBuilder2.Append("\nilvl ").Append(num.ToString(CultureInfo.InvariantCulture)); } stringBuilder2.Append((object?)stringBuilder); return LinkTags.Replace(stringBuilder2.ToString(), ""); } private static void AppendRows(StringBuilder text, IReadOnlyList<AffixRow> rows) { if (rows == null) { return; } foreach (AffixRow row in rows) { string name = row.Name; string effect = row.Effect; if (string.IsNullOrWhiteSpace(name) && string.IsNullOrWhiteSpace(effect)) { continue; } text.Append('\n'); if (!string.IsNullOrWhiteSpace(name)) { text.Append(name); } if (!string.IsNullOrWhiteSpace(effect)) { if (!string.IsNullOrWhiteSpace(name)) { text.Append(": "); } text.Append(effect); } } } } }