Decompiled source of LSQ Valheim Modpack v1.0.8

BepInEx\plugins\LSQ_Vplus_ServerFix\LSQ_Vplus_ServerFix.dll

Decompiled 2 days ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace LSQ.VplusServerFix;

[BepInPlugin("LSQ.VplusServerFix", "LSQ Vplus ServerFix", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class Plugin : BaseUnityPlugin
{
	private Harmony _harmony;

	private static FieldInfo _hitPieceField;

	private void Awake()
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		try
		{
			Type type = AccessTools.TypeByName("ValheimPlus.AEM");
			if (type == null)
			{
				throw new TypeLoadException("ValheimPlus.AEM was not found.");
			}
			MethodInfo methodInfo = AccessTools.Method(type, "resetObjectTransform", (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				throw new MissingMethodException("ValheimPlus.AEM.resetObjectTransform was not found.");
			}
			_hitPieceField = AccessTools.Field(type, "HitPiece");
			if (_hitPieceField == null)
			{
				throw new MissingFieldException("ValheimPlus.AEM.HitPiece was not found.");
			}
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Plugin), "ResetObjectTransformPrefix", (Type[])null, (Type[])null);
			_harmony = new Harmony("LSQ.VplusServerFix");
			_harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"LSQ Vplus ServerFix active.");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("LSQ Vplus ServerFix failed to install: " + ex));
		}
	}

	private static bool ResetObjectTransformPrefix()
	{
		if (_hitPieceField == null)
		{
			return true;
		}
		object value = _hitPieceField.GetValue(null);
		Object val = (Object)((value is Object) ? value : null);
		return Object.op_Implicit(val);
	}

	private void OnDestroy()
	{
		if (_harmony != null)
		{
			_harmony.UnpatchSelf();
		}
	}
}