Decompiled source of BetterBetterFriendJump v1.0.2

BetterBetterFriendJump.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BetterBetterFriendJump")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterBetterFriendJump")]
[assembly: AssemblyTitle("BetterBetterFriendJump")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BetterBetterFriendJump
{
	[BepInPlugin("BetterBetterFriendJump", "BetterBetterFriendJump", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		public static ConfigEntry<float> PalJumpMultiplier;

		public static float GetPalJumpBonus()
		{
			return PalJumpMultiplier.Value - 1f;
		}

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			PalJumpMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Friend Jump Multiplier", 5f, new ConfigDescription("Multiplier used for Friend Jump. Vanilla is 2.0.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 25f), Array.Empty<object>()));
			new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
			Log.LogInfo((object)"BetterBetterFriendJump loaded.");
		}
	}
	[HarmonyPatch(typeof(CharacterMovement), "JumpRpc")]
	public static class PatchJumpRpcMultiplier
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			for (int i = 0; i < list.Count - 1; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && list[i].operand is float num && Mathf.Approximately(num, 1f) && list[i + 1].opcode == OpCodes.Add)
				{
					list[i].opcode = OpCodes.Call;
					list[i].operand = AccessTools.Method(typeof(Plugin), "GetPalJumpBonus", (Type[])null, (Type[])null);
					flag = true;
					Plugin.Log.LogInfo((object)"Replaced vanilla Friend Jump bonus with config value.");
					break;
				}
			}
			if (!flag)
			{
				Plugin.Log.LogWarning((object)"Could not find Friend Jump bonus in JumpRpc - mod has no effect. The game may have updated again.");
			}
			return list;
		}
	}
}