Decompiled source of PeakGravity v1.0.0

BepInEx/plugins/PeakGravity.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
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("TestModUsingPEAKLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestModUsingPEAKLib")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7cf5d272-03b0-4eec-a562-aa66bdc210eb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.Pope0.peak.gravitymod", "Gravity Mod", "1.0.0")]
public class GravityMod : BaseUnityPlugin
{
	private Harmony _harmony;

	public static float gravityMultiplier = 1f;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		_harmony = new Harmony("com.Pope0.peak.gravitymod");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Gravity Mod loaded!");
	}

	private void Update()
	{
		HandleGravityInput();
	}

	private void HandleGravityInput()
	{
		if (Input.GetKey((KeyCode)103))
		{
			float axis = Input.GetAxis("Mouse ScrollWheel");
			if (Mathf.Abs(axis) > 0.01f)
			{
				gravityMultiplier += axis * 0.5f;
				gravityMultiplier = Mathf.Clamp(gravityMultiplier, 0.1f, 5f);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Gravity multiplier set to: {gravityMultiplier:F2}");
			}
		}
	}

	private void OnDestroy()
	{
		_harmony.UnpatchAll("com.Pope0.peak.gravitymod");
	}
}
[HarmonyPatch(typeof(CharacterMovement), "GetGravityForce")]
public class CharacterMovement_GetGravityForce_Patch
{
	private static void Postfix(ref Vector3 __result)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		__result *= GravityMod.gravityMultiplier;
	}
}
[HarmonyPatch(typeof(CharacterMovement), "JumpRpc")]
public class CharacterMovement_JumpForce_Patch
{
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Expected O, but got Unknown
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Expected O, but got Unknown
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Expected O, but got Unknown
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		Type typeFromHandle = typeof(CharacterMovement);
		Type nestedType = typeFromHandle.GetNestedType("<>c__DisplayClass37_0", BindingFlags.NonPublic);
		FieldInfo fieldInfo = AccessTools.Field(nestedType, "jumpMult");
		for (int i = 0; i < list.Count - 1; i++)
		{
			if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 1f && list[i + 1].opcode == OpCodes.Stfld && list[i + 1].operand as FieldInfo == fieldInfo)
			{
				list[i] = new CodeInstruction(OpCodes.Ldc_R4, (object)1f);
				list.Insert(i + 1, new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(GravityMod), "gravityMultiplier")));
				list.Insert(i + 2, new CodeInstruction(OpCodes.Div, (object)null));
				break;
			}
		}
		return list;
	}
}