Decompiled source of HighJump v1.0.2

HighJump.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HighJump")]
[assembly: AssemblyDescription("A client-side sprint double jump for Valheim.")]
[assembly: AssemblyCompany("Landoria")]
[assembly: AssemblyProduct("Landoria.HighJump")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.2.32030")]
[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 HighJump
{
	[HarmonyPatch(typeof(Character), "ForceJump")]
	internal static class ForceJumpPatch
	{
		private static void Postfix(Character __instance)
		{
			if (JumpPatch.SprintJumpCall && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				JumpPatch.StartJump(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Jump", new Type[] { typeof(bool) })]
	internal static class JumpPatch
	{
		private static Character _activeCharacter;

		private static float _launchSpeed;

		private static bool _secondJumpUsed;

		internal static bool SprintJumpCall { get; private set; }

		private static bool Prefix(Character __instance)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if (__instance.IsDead())
			{
				ResetJump();
				return true;
			}
			if (__instance.IsOnGround())
			{
				ResetJump();
				SprintJumpCall = __instance.IsRunning();
				return true;
			}
			return !TrySecondJump(__instance);
		}

		private static Exception Finalizer(Exception __exception)
		{
			SprintJumpCall = false;
			return __exception;
		}

		internal static void StartJump(Character character)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			_activeCharacter = character;
			_launchSpeed = character.GetVelocity().y;
			_secondJumpUsed = false;
		}

		private static void ResetJump()
		{
			_activeCharacter = null;
			_launchSpeed = 0f;
			_secondJumpUsed = false;
		}

		private static bool TrySecondJump(Character character)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)character != (Object)(object)_activeCharacter || _secondJumpUsed || _launchSpeed <= 0f || character.IsSwimming() || character.IsAttached() || character.IsDebugFlying())
			{
				return false;
			}
			Vector3 val = character.GetVelocity();
			if (val.y <= 0f)
			{
				return false;
			}
			_secondJumpUsed = true;
			val.y = _launchSpeed;
			if (!character.HaveStamina(character.m_jumpStaminaUsage))
			{
				val *= character.m_jumpForceTiredFactor;
			}
			character.ForceJump(val, true);
			return true;
		}
	}
	[BepInPlugin("HighJump", "HighJump", "1.0.2")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "HighJump";

		public const string PluginName = "HighJump";

		public const string PluginVersion = "1.0.2";

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_harmony = new Harmony("HighJump");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"HighJump 1.0.2 loaded.");
		}

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