Decompiled source of NoVulkanWarning v1.0.4

plugins/NoVulkanWarning/NoVulkanWarning.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[BepInPlugin("local.valheim.novulkanwarning", "NoVulkanWarning", "1.0.0")]
[BepInProcess("valheim.exe")]
public sealed class NoVulkanWarning : BaseUnityPlugin
{
	internal const string Id = "local.valheim.novulkanwarning";

	private Harmony harmony;

	private void Awake()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Expected O, but got Unknown
		MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(StartupMessages), "DisplayWindowsVulkanAMDCrashMessage", Type.EmptyTypes, (Type[])null);
		if (methodInfo == null || methodInfo.IsStatic || methodInfo.ReturnType != typeof(void))
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Unsupported game: Vulkan warning method not found. No patch applied.");
			return;
		}
		try
		{
			harmony = new Harmony("local.valheim.novulkanwarning");
			harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(NoVulkanWarning).GetMethod("SkipWarning", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched StartupMessages.DisplayWindowsVulkanAMDCrashMessage only.");
		}
		catch (Exception ex)
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
		}
	}

	private static bool SkipWarning()
	{
		return false;
	}

	private void OnDestroy()
	{
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
	}
}