Decompiled source of ValheimGaldrFix v1.0.6

ValheimGaldrFix.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ValheimGaldrFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Fixes Galdr Table UI freeze")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("ValheimGaldrFix")]
[assembly: AssemblyTitle("ValheimGaldrFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[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 ValheimGaldrFix
{
	[BepInPlugin("com.apres.galdrfix", "Valheim Galdr Table Fix", "1.0.6")]
	public class GaldrFixPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			try
			{
				Harmony val = new Harmony("com.apres.galdrfix");
				MethodInfo method = typeof(AccessTools).GetMethod("Method", new Type[4]
				{
					typeof(Type),
					typeof(string),
					typeof(Type[]),
					typeof(Type[])
				});
				MethodInfo method2 = typeof(GaldrFixPlugin).GetMethod("PostMethodResolve", BindingFlags.Static | BindingFlags.NonPublic);
				if (method != null && method2 != null)
				{
					val.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[GaldrFix] Профессиональный перехватчик Harmony запущен!");
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("[GaldrFix] Ошибка запуска: " + ex.Message));
			}
		}

		private static void PostMethodResolve(ref MethodInfo __result, Type type, string name, Type[] parameters)
		{
			if (type == typeof(Character) && name == "Message" && parameters != null && parameters.Length == 4 && __result == null)
			{
				__result = typeof(GaldrFixPlugin).GetMethod("FakeMessage", BindingFlags.Static | BindingFlags.NonPublic);
			}
		}

		private static void FakeMessage(MessageType type, string text, int pulse, Sprite icon)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage(type, text, pulse, icon, false, true);
			}
		}
	}
}