using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using Jotunn.Utils;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WhichModAddedThis")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WhichModAddedThis")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.1.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
namespace WhichModAddedThis;
[HarmonyPatch]
public static class Patches
{
[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
{
typeof(ItemData),
typeof(int),
typeof(bool),
typeof(float),
typeof(int)
})]
[HarmonyPostfix]
[HarmonyPriority(0)]
[HarmonyAfter(new string[] { "randyknapp.mods.epicloot" })]
public static void AppendModName(ref string __result, ItemData item)
{
if (item != null)
{
IModPrefab prefab = ModQuery.GetPrefab(PrefabName(item));
string text = __result.TrimEnd(Array.Empty<char>());
object obj;
if (prefab == null)
{
obj = null;
}
else
{
BepInPlugin sourceMod = prefab.SourceMod;
obj = ((sourceMod != null) ? sourceMod.Name : null);
}
if (obj == null)
{
obj = "Valheim";
}
__result = text + "\n" + GetTooltipModName((string)obj);
}
}
[HarmonyPatch(typeof(Hud), "SetupPieceInfo")]
[HarmonyPostfix]
public static void SetupPieceInfoPatch(Hud __instance, Piece piece)
{
if (Object.op_Implicit((Object)(object)piece))
{
IModPrefab prefab = ModQuery.GetPrefab(((Object)piece).name);
TMP_Text pieceDescription = __instance.m_pieceDescription;
string text = __instance.m_pieceDescription.text.TrimEnd(Array.Empty<char>());
object obj;
if (prefab == null)
{
obj = null;
}
else
{
BepInPlugin sourceMod = prefab.SourceMod;
obj = ((sourceMod != null) ? sourceMod.Name : null);
}
if (obj == null)
{
obj = "Valheim";
}
pieceDescription.text = text + GetTooltipModName((string)obj);
}
}
public static string GetTooltipModName(string modName)
{
string text = "orange";
if (Chainloader.PluginInfos.ContainsKey("randyknapp.mods.epicloot"))
{
text = "#ADD8E6FF";
}
return "\n<color=" + text + ">" + modName + "</color>";
}
private static string PrefabName(ItemData item)
{
if (item == null)
{
return string.Empty;
}
if ((Object)(object)item.m_dropPrefab != (Object)null)
{
return ((Object)item.m_dropPrefab).name;
}
return item.m_shared.m_name;
}
}
[BepInPlugin("com.maxsch.valheim.WhichModAddedThis", "WhichModAddedThis", "0.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class WhichModAddedThis : BaseUnityPlugin
{
public const string PluginGUID = "com.maxsch.valheim.WhichModAddedThis";
public const string PluginName = "WhichModAddedThis";
public const string PluginVersion = "0.1.1";
private Harmony harmony;
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
harmony = new Harmony("com.maxsch.valheim.WhichModAddedThis");
harmony.PatchAll();
ModQuery.Enable();
}
}