Decompiled source of BetterLaddersContinued v0.217.24

BetterLaddersContinued.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
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("BetterLaddersContinued")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterLaddersContinued")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7FC991FC-68C4-4647-9F0B-D829BEE2F80B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterLaddersContinued;

[BepInPlugin("BetterLaddersContinued", "BetterLaddersContinued", "0.217.24")]
[BepInProcess("valheim.exe")]
public class BetterLaddersContinued : BaseUnityPlugin
{
	[HarmonyPatch(typeof(AutoJumpLedge), "OnTriggerStay")]
	public static class Ladder_Patch
	{
		private static bool Prefix(AutoJumpLedge __instance, Collider collider)
		{
			Character component = ((Component)collider).GetComponent<Character>();
			if ((Object)(object)component == (Object)null || (Object)(object)component != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			MoveCharacterUp(__instance, component);
			return false;
		}

		private static void MoveCharacterUp(AutoJumpLedge __instance, Character character)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)character).transform;
			Quaternion rotation = ((Component)__instance).gameObject.transform.rotation;
			float y = ((Quaternion)(ref rotation)).eulerAngles.y;
			rotation = transform.rotation;
			float y2 = ((Quaternion)(ref rotation)).eulerAngles.y;
			if (Mathf.Abs(Mathf.DeltaAngle(y, y2)) <= 12f)
			{
				float num = (character.GetWalk() ? 0.06f : 0.08f);
				transform.position = transform.position + new Vector3(0f, num, 0f) + transform.forward * 0.08f;
			}
		}
	}

	private readonly Harmony m_harmony = new Harmony("BetterLaddersContinued");

	private void Awake()
	{
		m_harmony.PatchAll();
	}

	private void OnDestroy()
	{
		m_harmony.UnpatchSelf();
	}
}